This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
chore(deps): update terraform aws to ~> 4.67.0 #81
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "test-terraform" | |
on: | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
pre-commit: | |
name: "Run Terraform pre-commit checks" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out source | |
uses: actions/checkout@v3 | |
- name: Set up Terraform | |
uses: hashicorp/setup-terraform@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
- name: Install pre-commit and dependencies | |
shell: bash | |
run: | | |
pip install pre-commit | |
curl -sSLo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-$(uname)-amd64.tar.gz | |
sudo tar -xzf terraform-docs.tar.gz -C /usr/bin/ terraform-docs | |
rm terraform-docs.tar.gz 2> /dev/null | |
curl -sSL "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip | |
sudo unzip -qq tflint.zip tflint -d /usr/bin/ | |
rm tflint.zip 2> /dev/null | |
- name: Run pre-commit | |
shell: bash | |
run: pre-commit run --all-files --color always --show-diff-on-failure | |
test-deployment: | |
name: "Run test Terraform deployment" | |
runs-on: ubuntu-latest | |
needs: pre-commit | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.ROLE_TO_ASSUME }} | |
aws-region: us-east-1 | |
- name: Set up Terraform | |
uses: hashicorp/setup-terraform@v2 | |
- name: Build infrastructure | |
working-directory: infrastructure | |
run: | | |
aws ec2 create-key-pair --key-name ci-$GITHUB_RUN_ID | |
terraform init | |
terraform apply -auto-approve -var "key_name=ci-$GITHUB_RUN_ID" -var "env_name=ci-$GITHUB_RUN_ID" | |
- name: Deploy Kubernetes resources | |
working-directory: kubernetes | |
run: | | |
terraform init | |
terraform apply -auto-approve -var "cluster_name=ci-$GITHUB_RUN_ID-eks-cluster" | |
- name: Tear down Kubernetes resources | |
working-directory: kubernetes | |
run: | | |
terraform destroy -auto-approve -var "cluster_name=ci-$GITHUB_RUN_ID-eks-cluster" | |
- name: Tear down infrastructure | |
if: ${{ always() }} | |
working-directory: infrastructure | |
run: | | |
terraform destroy -auto-approve -var "key_name=ci-$GITHUB_RUN_ID" -var "env_name=ci-$GITHUB_RUN_ID" | |
aws ec2 delete-key-pair --key-name ci-$GITHUB_RUN_ID |