Skip to content

Instantly share code, notes, and snippets.

@tbeyer567
Last active July 16, 2026 17:12
Show Gist options
  • Select an option

  • Save tbeyer567/15b5ee9afac72a9245d11f26e1f15aa3 to your computer and use it in GitHub Desktop.

Select an option

Save tbeyer567/15b5ee9afac72a9245d11f26e1f15aa3 to your computer and use it in GitHub Desktop.
gitlab ci
terraform_plan:
stage: plan
image: hashicorp/terraform:1.15
variables:
TF_TOKEN_app_terraform_io: $TF_CLOUD_TOKEN # Set this in GitLab CI/CD Variables
before_script:
- terraform --version
- terraform init
script:
- terraform plan -detailed-exitcode -out=plan.tfplan || true
artifacts:
reports:
terraform: plan.tfplan # Nice Terraform widget in GitLab UI
paths:
- plan.tfplan
expire_in: 7 days
rules:
# Run on pushes to any branch except main (when Terraform files change)
- if: $CI_COMMIT_BRANCH != "main" && $CI_PIPELINE_SOURCE == "push"
changes:
- "**/*.tf"
- "**/*.tfvars"
- ".gitlab-ci.yml"
when: always
# Always run on Merge Requests
- if: $CI_MERGE_REQUEST_IID
when: always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment