Amazon CodeCatalyst workflow for Terraform using GitHub Actions
Example CodeCatalyst workflow to apply Terraform infrastructure changes using GitHub Actions.
Published May 5, 2023
💻 Examples of
⏰ Last Updated
2023-05-05
This snippet shows a CodeCatalyst workflow using GitHub Actions that will run Terraform to apply infrastructure changes. It uses validate
and plan
to test if the Terraform code is valid. It is intended to be used on the main
branch, and run after merging a PR that has been validated - see this example of the PR branch workflow. Alternative version using standard CodeCatalyst workflow.
Used in:
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
Name: TerraformMainBranch
SchemaVersion: "1.0"
Triggers:
- Type: Push
Branches:
- main
Actions:
Terraform-Main-Branch-Apply:
Identifier: aws/github-actions-runner@v1
Inputs:
Sources:
- WorkflowSource
Environment:
Connections:
- Role: Main-Branch-Infrastructure
Name: "123456789012"
Name: TerraformBootstrap
Configuration:
Steps:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.3.7
- name: Terraform Format
run: terraform fmt -check -no-color
- name: Terraform Init
run: terraform init -no-color
- name: Terraform Validate
run: terraform validate -no-color
- name: Terraform Plan
run: terraform plan -no-color -input=false
- name: Terraform Apply
run: terraform apply -auto-approve -no-color -input=false
Compute:
Type: EC2