Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Terraform - Fundamental

Back


Terraform



Installation


Command: console

terraform console

HCL


<BLOCK TYPE> "<BLOCK LABEL>" "<BLOCK LABEL>" {
  # Block body
  <IDENTIFIER> = <EXPRESSION> # Argument
}

Files and Directories


Worksapce

# avoid naming collision
resource "aws_ssm_parameter" "my-parameter"{
  name = "/myapp/myname-${terraform.workspace}"
}

# conditional
resource "aws_instance" "myinstance" {
  count = terraform.workspace == "default" ? 1 :0
}
CMD DESC
terraform workspace new wsp_name Create a new workspace
terraform workspace select wsp_name Switch to a workspace

Debugging Mode

# Linux
terraform apply -var TF_LOG=DEBUG

# windows Powershell
$Env:TF_LOG="DEBUG"