Skip to content

Commit 7fb951c

Browse files
[NDR-71] Update GitHub Actions workflow for Terraform to enhance security and streamline processes
1 parent f35ca6f commit 7fb951c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,23 @@ jobs:
7373
terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf.plan
7474
terraform show -no-color tf.plan > tfplan.txt
7575
76-
# Mask AWS account IDs (12-digit numbers)
77-
echo "$PLAN_FULL" | grep -oE '[0-9]{12}' | while read -r account_id; do
78-
echo "::add-mask::$account_id"
76+
# Mask sensitive URLs in the Terraform Plan output
77+
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
78+
if [ -n "$api_url" ]; then
79+
echo "::add-mask::$api_url"
80+
fi
7981
done
8082
8183
# Mask Lambda invocation URLs
82-
echo "$PLAN_FULL" | grep -oE 'https://[a-zA-Z0-9.-]+\.lambda\.amazonaws\.com/[a-zA-Z0-9/._-]+' | while read -r lambda_url; do
84+
grep -Eo 'https://[a-zA-Z0-9.-]+\.lambda\.amazonaws\.com/[a-zA-Z0-9/._-]+' tfplan.txt | while read -r lambda_url; do
8385
if [ -n "$lambda_url" ]; then
8486
echo "::add-mask::$lambda_url"
8587
fi
86-
done || echo "No Lambda URLs found to mask."
88+
done
8789
88-
# Mask API Gateway URLs (e.g., execute-api)
89-
echo "$PLAN_FULL" | grep -oE 'https://[a-zA-Z0-9.-]+\.execute-api\.[a-zA-Z0-9.-]+\.amazonaws\.com/[a-zA-Z0-9/._-]*' | while read -r api_url; do
90-
if [ -n "$api_url" ]; then
91-
echo "::add-mask::$api_url"
92-
fi
90+
# Mask AWS account IDs (12-digit numbers)
91+
grep -Eo '[0-9]{12}' tfplan.txt | while read -r account_id; do
92+
echo "::add-mask::$account_id"
9393
done
9494
9595
# Mask GitHub secrets

0 commit comments

Comments
 (0)