202302101155-terraform
Related notes:
Basic commands
terraform init
terraform plan -out main.tfplan
terraform apply main.tfplan (without specifying the plan, you do an implicit plan stage)
terraform destroy can destroy resources specified in a resource group.
terraform validate to syntactically check the configuration (also done as a first step when planning.)
Resource dependencies
There can be dependencies between resources. For example, if we have a statement to upload a blob to a storage container, this requires the storage container to be created first, which account requires a storage account.
You can specify this with a depends_on attribute, e.g.:
depends_on = [
azurerm_storage_container.data
]
Variable blocks
E.g. a variable that takes in a client secret from the user instead of specifying it in the Terraform configuration:
variable "client_secret" {
type = string
sensitive = true
}
When creating a plan, the user will be prompted to provide this variable.
Then you can reference this with var.client_secret where needed.