Skip to content

Commit c7ccb08

Browse files
[NDR-71] Enhance Terraform Plan output logging by redirecting stderr to capture errors in plan and show commands
1 parent ef47871 commit c7ccb08

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

.github/workflows/terraform-dev-to-main-ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ jobs:
7070
- name: Terraform Plan
7171
id: plan
7272
run: |
73-
terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf.plan
74-
terraform show -no-color tf.plan > tfplan.txt
73+
terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf.plan > plan_output.txt 2>&1
74+
terraform show -no-color tf.plan > tfplan.txt > 2>&1
7575
7676
# Mask sensitive URLs in the Terraform Plan output
7777
grep -Eo 'https://[a-zA-Z0-9.-]+\.execute-api\.[a-zA-Z0-9.-]+\.amazonaws\.com/[a-zA-Z0-9/._-]*' tfplan.txt | while read -r api_url; do
@@ -101,6 +101,9 @@ jobs:
101101
# Mask Terraform variables
102102
echo "::add-mask::${{ vars.TF_VARS_FILE }}"
103103
104+
# Output the sanitized plan to logs
105+
cat plan_output.txt
106+
104107
echo "summary=$(grep -E 'Plan: [0-9]+ to add, [0-9]+ to change, [0-9]+ to destroy\.|No changes\. Your infrastructure matches the configuration\.' tfplan.txt | sed 's/.*No changes\. Your infrastructure matches the configuration/Plan: no changes/g' | sed 's/.*Plan: //g' | sed 's/\..*//g')" >> $GITHUB_OUTPUT
105108
working-directory: ./infrastructure
106109
shell: bash

0 commit comments

Comments
 (0)