Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions .github/workflows/tf-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ on:
type: boolean
default: false
description: 'Enable terraform plan step.'
show_plan:
required: false
type: boolean
default: true
description: 'Show full terraform plan output. If false, only shows summary (e.g. Plan: 4 to add, 1 to change).'
gcp_credentials:
required: false
type: string
Expand Down Expand Up @@ -270,20 +275,30 @@ jobs:
path: ${{ inputs.working_directory }}

- name: πŸ“‹ Terraform Plan
if: ${{ inputs.enable_plan }}
id: tf-plan
if: ${{ inputs.enable_plan }}
run: |
export exitcode=0
cd ${{ inputs.working_directory }}
if [ -n "${{ inputs.var_file }}" ]; then
terraform plan -detailed-exitcode -no-color -out tfplan --var-file=${{ inputs.var_file }} || export exitcode=$?
terraform plan -detailed-exitcode -no-color -out=tfplan --var-file=${{ inputs.var_file }} > plan.txt 2>&1 || exitcode=$?
else
terraform plan -detailed-exitcode -no-color -out tfplan || export exitcode=$?
terraform plan -detailed-exitcode -no-color -out=tfplan > plan.txt 2>&1 || exitcode=$?
fi
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT
if [ $exitcode -eq 1 ]; then
echo Terraform Plan Failed!
echo "Terraform Plan Failed!"
cat plan.txt
exit 1
fi
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT
if [ "${{ inputs.show_plan }}" == "true" ]; then
# Show full plan
cat plan.txt
else
exit 0
# Show only summary
grep -E '^Plan:|^No changes' plan.txt || echo "No changes."
fi
4 changes: 4 additions & 0 deletions docs/tf-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
working_directory: './examples/complete/'
provider: 'aws'
enable_plan: true
show_plan: false
var_file: 'vars/dev.tfvars'
aws_region: 'us-east-1'
secrets:
Expand Down Expand Up @@ -93,6 +94,7 @@ jobs:
working_directory: './examples/complete/'
provider: 'azurerm'
enable_plan: true
show_plan: false
secrets:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
GITHUB: ${{ secrets.GITHUB }}
Expand All @@ -113,6 +115,7 @@ jobs:
working_directory: './examples/complete/'
provider: 'aws'
enable_plan: true
show_plan: false
aws_region: 'us-east-1'
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down Expand Up @@ -173,6 +176,7 @@ jobs:
| `terraform_version` | No | Latest | Specific Terraform version to use |
| `enable_version_check` | No | `false` | Enable min/max version compatibility testing |
| `enable_plan` | No | `false` | Enable terraform plan step |
| `show_plan` | No | `true` | Only shows terraform plan summary |
| `role_duration_seconds` | No | `3600` | AWS role duration in seconds (900-43200) |
| `project_id` | No | - | GCP project ID |
| `token_format` | No | `access_token` | GCP token format (`access_token` or `id_token`) |
Expand Down
Loading