Pipeline: Terraform

Pipeline for Terraform modules. This pipeline will run terraform fmt, terraform plan and terraform apply.

Flowchart apply_mode=manual or apply_mode=auto-approve

flowchart TD

classDef optional stroke-dasharray: 5 5

job:terraform-plan["terraform-plan"]
job:terraform-fmt{{"terraform-fmt"}}
job:terraform-apply["terraform-apply"]

subgraph stage:build["stage: build"]
job:terraform-plan
end

subgraph stage:test["stage: test"]
job:terraform-fmt
end

subgraph stage:deploy["stage: deploy"]
job:terraform-apply
end

stage:build --> stage:test
stage:test --> stage:deploy

Flowchart apply_mode=auto-approve-non-destructive

flowchart TD

classDef optional stroke-dasharray: 5 5

job:terraform-plan["terraform-plan"]
job:terraform-fmt{{"terraform-fmt"}}
job:terraform-apply:generate["terraform-apply:generate"]
job:terraform-apply:trigger["terraform-apply:trigger"]

subgraph stage:build["stage: build"]
job:terraform-plan
end

subgraph stage:test["stage: test"]
job:terraform-fmt
end

subgraph stage:deploy["stage: deploy"]
job:terraform-apply:generate
job:terraform-apply:trigger

job:terraform-apply:generate --> job:terraform-apply:trigger
end

stage:build --> stage:test
stage:test --> stage:deploy

subgraph child:terraform-apply["child pipeline: terraform-apply"]
child:terraform-apply:terraform-apply["terraform-apply"]
child:terraform-apply:gitlab-issue-361574["gitlab-issue-361574"]
end

job:terraform-apply:trigger -.- child:terraform-apply

Usage

include:
  - component: gitlab.com/release-process/terraform/pipeline@0.1.0

Inputs

NameDescriptionDefault
apply_modeThe mode to use when applying changes. See also: apply_mode Optionsmanual
dirthe directory to build.
nameThe name to prefix all job names withterraform
terraform_init_argsadditional arguments to pass to the terraform init command-lockfile=readonly
terraform_versionThe version of Terraform to use1.8

apply_mode Options

NameDescription
manualRequires manual approval before applying changes.
auto-approveAutomatically applies changes without requiring approval.
auto-approve-non-destructiveAutomatically applies changes without requiring approval, but only if the plan is non-destructive.