Made changes in main.tf. #1
This file contains hidden or 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: Terraform Checks | ||
| on: | ||
| workflow_call: | ||
| env: | ||
| TERRAFORM_DOCS_VERSION: v0.18.0 | ||
| TFLINT_VERSION: v0.52.0 | ||
| jobs: | ||
| test: | ||
| name: Test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Setup Terraform | ||
| uses: hashicorp/setup-terraform@v3 | ||
| with: | ||
| terraform_version: "1.13.0" | ||
| - name: Initialize Terraform | ||
| id: init | ||
| run: terraform init -input=false | ||
| - name: Terraform Test | ||
| id: fmt | ||
| run: terraform test | ||
| validateExamples: | ||
| name: Terraform Validate Examples | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Terraform | ||
| uses: hashicorp/setup-terraform@v3 | ||
| with: | ||
| terraform_version: "1.6.0" | ||
| - name: Validate all example folders | ||
| run: | | ||
| for dir in examples/*/; do | ||
| echo "Validating $dir" | ||
| terraform -chdir="$dir" init -input=false > /dev/null | ||
| terraform -chdir="$dir" validate | ||
| done | ||
| collectInputs: | ||
| name: Collect workflow inputs | ||
| needs: test | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| directories: ${{ steps.dirs.outputs.directories }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| - name: Get root directories | ||
| id: dirs | ||
| uses: clowdhaus/terraform-composite-actions/[email protected] | ||
| preCommitMinVersions: | ||
| name: Min TF pre-commit | ||
| needs: collectInputs | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| directory: ${{ fromJson(needs.collectInputs.outputs.directories) }} | ||
| steps: | ||
| # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449 | ||
| - name: Delete huge unnecessary tools folder | ||
| run: | | ||
| rm -rf /opt/hostedtoolcache/CodeQL | ||
| rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk | ||
| rm -rf /opt/hostedtoolcache/Ruby | ||
| rm -rf /opt/hostedtoolcache/go | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| - name: Terraform min/max versions | ||
| id: minMax | ||
| uses: clowdhaus/[email protected] | ||
| with: | ||
| directory: ${{ matrix.directory }} | ||
| - name: Inject CI provider configs | ||
| run: | | ||
| echo "Injecting provider configs for CI..." | ||
| for dir in examples/*/; do | ||
| cat <<EOF > $dir/ci-providers.tf | ||
| provider "aws" { | ||
| region = "ap-south-1" | ||
| } | ||
| provider "aws" { | ||
| alias = "cross_account_provider" | ||
| region = "ap-south-1" | ||
| } | ||
| EOF | ||
| done | ||
| - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} | ||
| # Run only validate pre-commit check on min version supported | ||
| if: ${{ matrix.directory != '.' }} | ||
| uses: clowdhaus/terraform-composite-actions/[email protected] | ||
| with: | ||
| terraform-version: ${{ steps.minMax.outputs.minVersion }} | ||
| tflint-version: ${{ env.TFLINT_VERSION }} | ||
| args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*' | ||
| - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} | ||
| # Run only validate pre-commit check on min version supported | ||
| if: ${{ matrix.directory == '.' }} | ||
| uses: clowdhaus/terraform-composite-actions/[email protected] | ||
| with: | ||
| terraform-version: ${{ steps.minMax.outputs.minVersion }} | ||
| tflint-version: ${{ env.TFLINT_VERSION }} | ||
| args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)' | ||
| preCommitMaxVersion: | ||
| name: Max TF pre-commit | ||
| runs-on: ubuntu-latest | ||
| needs: collectInputs | ||
| steps: | ||
| # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449 | ||
| - name: Delete huge unnecessary tools folder | ||
| run: | | ||
| rm -rf /opt/hostedtoolcache/CodeQL | ||
| rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk | ||
| rm -rf /opt/hostedtoolcache/Ruby | ||
| rm -rf /opt/hostedtoolcache/go | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Terraform min/max versions | ||
| id: minMax | ||
| uses: clowdhaus/[email protected] | ||
| - name: Inject CI provider configs | ||
| run: | | ||
| echo "Injecting provider configs for CI..." | ||
| for dir in examples/*/; do | ||
| cat <<EOF > $dir/ci-providers.tf | ||
| provider "aws" { | ||
| region = "ap-south-1" | ||
| } | ||
| provider "aws" { | ||
| alias = "cross_account_provider" | ||
| region = "ap-south-1" | ||
| } | ||
| EOF | ||
| done | ||
| - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }} | ||
| uses: clowdhaus/terraform-composite-actions/[email protected] | ||
| with: | ||
| terraform-version: ${{ steps.minMax.outputs.maxVersion }} | ||
| tflint-version: ${{ env.TFLINT_VERSION }} | ||
| terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }} | ||
| install-hcledit: true | ||