enhance: AWS BYOC I project example #97
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 Validation | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| terraform: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: latest | |
| - name: Configure Terraform plugin cache | |
| run: | | |
| echo "TF_PLUGIN_CACHE_DIR=$HOME/.terraform.d/plugin-cache" >>"$GITHUB_ENV" | |
| mkdir --parents "$HOME/.terraform.d/plugin-cache" | |
| - name: Cache Terraform Plugin | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.terraform.d/plugin-cache | |
| key: terraform-${{ runner.os }}-plugin-cache | |
| restore-keys: | | |
| terraform-${{ runner.os }}-plugin-cache | |
| - name: Terraform Validate in All Modules | |
| run: | | |
| export TF_PLUGIN_CACHE_DIR="${HOME}/.terraform.d/plugin-cache" | |
| for dir in modules/*; do | |
| if [ -d "$dir" ]; then | |
| echo "Validating $dir" | |
| cd "$dir" | |
| terraform init | |
| terraform validate | |
| cd - | |
| fi | |
| done |