YAML for Terraform Drift Detection
Run terraform/tofu init and plan in refresh-only mode to find resources that were changed or removed outside of Terraform, then render the drift per resource.
YAML examples for Terraform Drift Detection
Terraform Drift Detection
yaml- action: "Detect drift" type: "TERRAFORM_DRIFT_DETECTION" tool: "OPENTOFU" version: "1.9.0"
Terraform Drift Detection reporting the drift without failing
yaml- action: "Detect drift" type: "TERRAFORM_DRIFT_DETECTION" tool: "OPENTOFU" version: "1.9.0" working_directory: "./infrastructure/prod" tf_workspace: "production" additional_args: "-var-file=prod.tfvars -parallelism=20" fail_on_drift: false
Terraform Drift Detection with custom binary
yaml- action: "Detect drift" type: "TERRAFORM_DRIFT_DETECTION" tool: "CUSTOM" custom_binary_path: "/opt/terraform/bin/terraform" docker_image_name: "mycompany/terraform-runner" docker_image_tag: "1.9.5" working_directory: "./infrastructure/prod"
Terraform Drift Detection with custom image from a private registry
yaml- action: "Detect drift" type: "TERRAFORM_DRIFT_DETECTION" tool: "CUSTOM" custom_binary_path: "/usr/local/bin/tofu" docker_image_name: "mycompany/terraform-runner" docker_image_tag: "1.9.5" image_location: "PRIVATE_REGISTRY" docker_registry: "OTHER" registry: "my.registry.com" login: "buddyworks" password: "${top_secret_password}" working_directory: "./infrastructure/prod"
Terraform Drift Detection with state in a Buddy artifact
yaml- action: "Detect drift" type: "TERRAFORM_DRIFT_DETECTION" tool: "OPENTOFU" version: "1.9.0" working_directory: "./infrastructure/prod" backend: type: "ARTIFACT" artifact: "terraform-state" artifact_version: "1.0.0"
Terraform Drift Detection with state in Amazon S3
yaml- action: "Detect drift" type: "TERRAFORM_DRIFT_DETECTION" tool: "OPENTOFU" version: "1.9.0" working_directory: "./infrastructure/prod" backend: type: "AMAZON" integration: "amazon-web-services" region: "us-east-1"