updated Macie solution for Control Tower optional (#175) #157
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cfn-nag - CloudFormation Scan | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Ruby 2.6 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '2.6' | |
- name: Install cfn-nag | |
run: gem install cfn-nag | |
- name: Scan files in all templates folders | |
run: | | |
export deployment_dir=`pwd` | |
echo "$deployment_dir" | |
for i in $(find . -type f | grep -E '.template$|.yaml$|.yml$|.json$' | sed 's/^.\///') ; do | |
echo $i | |
if [[ "$i" == *"templates"* ]]; then | |
cfn_nag_scan --input-path "$deployment_dir/$i" | |
if [ $? -ne 0 ]; then | |
echo "cfn-nag failed validation - $i" | |
exit 1 | |
fi | |
fi | |
done |