GitLab CI
Why Use GitLab CI/CD for Terraform?
Real-Life Scenarios
1. Deploying to AWS with GitLab CI/CD
stages:
- validate
- plan
- apply
variables:
TF_ROOT: "terraform"
validate:
stage: validate
image: hashicorp/terraform:1.7.5
script:
- cd $TF_ROOT
- terraform init -input=false
- terraform validate
plan:
stage: plan
image: hashicorp/terraform:1.7.5
script:
- cd $TF_ROOT
- terraform init -input=false
- terraform plan -out=tfplan
artifacts:
paths:
- $TF_ROOT/tfplan
apply:
stage: apply
image: hashicorp/terraform:1.7.5
script:
- cd $TF_ROOT
- terraform apply -auto-approve tfplan
when: manual
only:
- main
environment:
name: production
dependencies:
- plan2. Multi-Cloud Deployments with Secure Variables
3. NixOS-based Runners for Reproducible IaC
Best Practices for Security and Deployments
GitLab CI/CD vs GitHub Actions vs Azure DevOps Pipelines
Feature
GitLab CI/CD
GitHub Actions
Azure DevOps Pipelines
References
Last updated