Skip to content

Commit

Permalink
fix test that fails but not in the way I wanted
Browse files Browse the repository at this point in the history
  • Loading branch information
RainofTerra committed Oct 20, 2023
1 parent 9dd0a22 commit 24487c1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/test-terraform-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@ jobs:

- name: Check if plan has changes
run: |
if [ $(terraform show -json tfplan | jq '.resource_changes | length') -ne 0 ]; then
echo "Terraform plan has detected changes after apply. This means the configuration is flapping."
PLAN_OUTPUT=$(terraform show -json tfplan || echo "{}")
# Output the JSON for debugging purposes
echo "=== TERRAFORM PLAN JSON OUTPUT ==="
echo "$PLAN_OUTPUT"
echo "=================================="
NUM_CHANGES=$(echo "$PLAN_OUTPUT" | jq '.resource_changes | length' || echo "0")
if [ -z "$NUM_CHANGES" ] || [ "$NUM_CHANGES" -ne 0 ]; then
echo "Terraform plan has detected changes after apply. This means the configuration isn't idempotent."
exit 1
fi
Expand Down

0 comments on commit 24487c1

Please sign in to comment.