Skip to content

Commit fc891d8

Browse files
committed
Merge remote-tracking branch 'origin/main' into dev_container_build
2 parents 7a7a5bd + 4a6d03a commit fc891d8

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

.github/workflows/quality-checks.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ jobs:
288288
declare -a rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar")
289289
for ruleset in "${rulesets[@]}"
290290
do
291-
echo "Checking all templates in cloudformation folder with ruleest $ruleset"
291+
echo "Checking all templates in cloudformation folder with ruleset $ruleset"
292292
293293
~/.guard/bin/cfn-guard validate \
294294
--data cloudformation \
@@ -305,7 +305,7 @@ jobs:
305305
declare -a rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar")
306306
for ruleset in "${rulesets[@]}"
307307
do
308-
echo "Checking all templates in cdk.out folder with ruleest $ruleset"
308+
echo "Checking all templates in cdk.out folder with ruleset $ruleset"
309309
310310
~/.guard/bin/cfn-guard validate \
311311
--data cdk.out \
@@ -314,6 +314,42 @@ jobs:
314314
> "cfn_guard_output/cdk.out_$ruleset.txt"
315315
done
316316
317+
- name: Download terraform plans
318+
uses: actions/download-artifact@v5
319+
with:
320+
pattern: '*_terraform_plan'
321+
path: terraform_plans/
322+
merge-multiple: true
323+
324+
- name: Check terraform plans exist
325+
id: check_terraform_plans
326+
run: |
327+
if [ ! -d terraform_plans ]; then
328+
echo "Terraform plans not present."
329+
echo "terraform_plans_exist=false" >> "$GITHUB_OUTPUT"
330+
else
331+
echo "Terraform plans present:"
332+
ls -l terraform_plans/
333+
echo "terraform_plans_exist=true" >> "$GITHUB_OUTPUT"
334+
fi
335+
336+
- name: Run cfn-guard script for terraform plans
337+
if: steps.check_terraform_plans.outputs.terraform_plans_exist == 'true'
338+
run: |
339+
#!/usr/bin/env bash
340+
341+
declare -a rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pillar")
342+
for ruleset in "${rulesets[@]}"
343+
do
344+
echo "Checking terraform plans with ruleset $ruleset"
345+
346+
~/.guard/bin/cfn-guard validate \
347+
--data terraform_plans \
348+
--rules "/tmp/ruleset/output/$ruleset.guard" \
349+
--show-summary fail \
350+
> "cfn_guard_output/terraform_plans_$ruleset.txt"
351+
done
352+
317353
- name: Show cfn-guard output
318354
if: failure()
319355
run: find cfn_guard_output -type f -print0 | xargs -0 cat

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ The main quality checks workflow runs comprehensive checks for EPS repositories.
1717
- **Run Linting** Runs `make lint`.
1818
- **Run actionlint** Runs actionlint using [actionlint](https://github.com/raven-actions/actionlint)
1919
- **Run shellcheck**: Runs shellcheck using [action-shellcheck](https://github.com/ludeeus/action-shellcheck)
20-
- **Run cfn-lint** Runs [cfn-lint](https://github.com/aws-cloudformation/cfn-lint) against files in cloudformation and SAMtemplates folders
20+
- **Validate CloudFormation Templates** (*Conditional*): If CloudFormation, AWS SAM templates or CDK are present, runs `cfn-lint` (SAM and cloudformation only) and `cfn-guard` to validate templates against AWS best practices and security rules.
21+
- **Validate Terraform Plans** Terraform plans can also be scanned by `cfn-guard` by uploading plans as artefacts in the calling workflow. All Terraform plans must end _terraform_plan and be in json format.
2122
- **Run Unit Tests** Runs `make test`.
2223
- **CDK Synth** (*Conditional*): Runs `make cdk-synth` if packages/cdk folder exists
2324
- **Run cloudformation-guard** (*Conditional*): Runs [cfn-guard](https://github.com/aws-cloudformation/cloudformation-guard) if CloudFormation, AWS SAM templates or CDK are present

0 commit comments

Comments
 (0)