Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

AWS Logo
Menu

Amazon CodeCatalyst workflow for a PR branch for Terraform using GitHub Actions

Example CodeCatalyst workflow to run Terraform plan on a PR branch using GitHub Actions.

AWS Admin
Amazon Employee
Published May 5, 2023
Last Modified Jun 21, 2024
About
💻 Examples ofHashicorp HCL
CodeCatalyst Workflow
GitHub Actions
⏰ Last Updated2023-03-01
This snippet shows a CodeCatalyst workflow that will run Terraform validate and plan to test if the Terraform code is valid on a PR. It is intended to be used on a PR branch - see this example of the main branch workflow. Alternative version using standard CodeCatalyst workflow.
Used in:

Snippet

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
Name: TerraformPRBranch
SchemaVersion: "1.0"

# Optional - Set automatic triggers.
Triggers:
- Type: PULLREQUEST
Branches:
- main
Events:
- OPEN
- REVISION

# Build actions
Actions:
Terraform-PR-Branch-Plan:
Identifier: aws/github-actions-runner@v1
Inputs:
Sources:
- WorkflowSource
Environment:
Connections:
- Role: PR-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
Compute:
Type: EC2

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments

Log in to comment