Skip to content

feat: add a new vpc #317

feat: add a new vpc

feat: add a new vpc #317

Workflow file for this run

name: Terraform Preview
on:
pull_request:
branches:
- main
jobs:
preview:
name: Plan Terraform changes in changed stacks
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: write
checks: read
steps:
### Check out the code
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
### Install tooling
- name: Install Terramate
uses: terramate-io/terramate-action@v2
- name: Install asdf
uses: asdf-vm/actions/setup@v3
- name: Install Terraform with asdf
run: |
asdf plugin add terraform
asdf install terraform
- name: Install OpenTofu with asdf
run: |
asdf plugin add opentofu
asdf install opentofu
### Linting
- name: Check Terramate formatting
run: terramate fmt --check
- name: Check Terraform formatting
run: terraform fmt -recursive -check -diff
### Check for changed stacks
- name: List changed stacks
id: list-changed
run: terramate list -C stacks --changed
### Configure cloud credentials
- name: Configure AWS credentials
if: steps.list-changed.outputs.stdout
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/github
env:
AWS_REGION: us-east-1
AWS_ACCOUNT_ID: ${{ vars.AWS_ACCOUNT_ID }}
- name: Verify AWS credentials
if: steps.list-changed.outputs.stdout
run: aws sts get-caller-identity
### Run the Terraform preview via Terramate in each changed stack
- name: Run Terraform init in all changed stacks
if: steps.list-changed.outputs.stdout
run: |
terramate script run \
-C stacks \
--changed \
--parallel 1 \
init
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Plan Terraform changes in changed stacks
if: steps.list-changed.outputs.stdout
run: |
terramate script run \
-C stacks \
--changed \
--parallel 5 \
--continue-on-error \
-- \
preview
env:
GITHUB_TOKEN: ${{ github.token }}