CI/CD for Docker infrastructure using Terraform
Build, change, and destroy Docker infrastructure using Terraform.
Use template →1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
steps: - label: ":terraform: terraform init" key: "init" plugins: - docker#v5.9.0: image: hashicorp/terraform:1.5 command: ["init", "-input=false"] - artifacts#v1.9.2: upload: [".terraform", ".terraform.lock.hcl"] compressed: terraform.tgz - label: ":terraform: terraform plan" depends_on: "init" key: "plan" plugins: - artifacts#v1.9.2: download: [".terraform", ".terraform.lock.hcl"] compressed: terraform.tgz - docker#v5.9.0: image: hashicorp/terraform:1.5 command: ["plan", "-out=tfplan", "-input=false"] volumes: - /var/run/docker.sock:/var/run/docker.sock artifact_paths: - "tfplan" - block: "Apply?" - label: ":terraform: terraform apply" plugins: - artifacts#v1.9.2: download: ["tfplan"] - artifacts#v1.9.2: download: [".terraform", ".terraform.lock.hcl"] compressed: terraform.tgz - docker#v5.9.0: image: hashicorp/terraform:1.5 command: ["apply", "-input=false", "-auto-approve", "tfplan"] volumes: - /var/run/docker.sock:/var/run/docker.sock
CI/CD for Docker using Terraform
Build, change, and destroy Docker infrastructure using Terraform.
Use template →CI/CD for Docker infrastructure using Terraform
This template gives you a continuous integration (CI) pipeline for building, changing, and destroying Docker infrastructure using Terraform.
At a glance:
How it works
This template:
- Validates the Terraform configuration in a Docker image.
- Initializes Terraform and plans changes, outputting a plan file, which is available as an artifact.
- Blocks for input before conditionally applying the proposed Terraform plan.
The pipeline runs all steps in a Docker container with the HashiCorp Terraform image.
Next steps
After you select Use template, you’ll:
- Connect the Git repository with your Terraform configuration.
- Configure the compute—run locally, on-premises, or in the cloud.
- Run the pipeline.
You can then play around with the pipeline settings. For example, run the pipeline locally while you iterate on the definition or set a schedule to trigger a nightly build.
If you need help, please check our documentation, raise an issue , or reach out to support.