Wiki

Terraform

Terraform

No diff if you only updated outputs

To force a state change based on an output update, you need to update your code to include a resource that gets update based on output changes such as the following:

1
2
3
4
5
resource "random_uuid" "tfc_output_refresh" {
  keepers = {
    refresh = "${filesha256(${path.module}/output.tf)}"
  }
}

Switch between Terraform versions

Use tfswitch to update your local terraform CLI version. This is useful when you need to do terraform state surgery, because terraform states are versioned. Terraform will complain when operating on states with future versions, which happens when Terraform remote executor is using a dated version of terraform unlike yours.

Select specific resources

If your team (unfortunately) applies terraform manually and planning takes a long time, consider selecting only the subset of resources that you changed. You can provide as many -targets as you wish.

1
2
3
4
5
6
terraform plan -target=${RESOURCE_TYPE}.${RESOURCE_NAME}

# Example
terraform plan \
  -target=aws_route53_record.example-com-A \
  -target=aws_route53_record.www-example-com-CNAME