Skip to content

Commit

Permalink
Merge pull request #420 from ericzbeard/aws-linting
Browse files Browse the repository at this point in the history
Change scripts to run from any directory
  • Loading branch information
ericzbeard authored Apr 23, 2024
2 parents 5c745e1 + f432ed7 commit c45197a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 100 deletions.
5 changes: 0 additions & 5 deletions .cfnlintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
templates:
- aws/**/*.yaml
- aws/**/*.json
- community/**/*.yaml
- community/**/*.json
ignore_templates:
- aws/services/CloudFormation/MacrosExamples/**/*
- community/solutions/StaticWebSiteWithPipeline/examples/stackCreationPolicy.json
Expand Down
98 changes: 8 additions & 90 deletions aws/services/VPC/VPC_With_Managed_NAT_And_Private_Subnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,64 +21,6 @@ Mappings:
Private1:
CIDR: 10.0.3.0/24

AZRegions:
ap-northeast-1:
AZs:
- a
- b
ap-northeast-2:
AZs:
- a
- b
ap-south-1:
AZs:
- a
- b
ap-southeast-1:
AZs:
- a
- b
ap-southeast-2:
AZs:
- a
- b
ca-central-1:
AZs:
- a
- b
eu-central-1:
AZs:
- a
- b
eu-west-1:
AZs:
- a
- b
eu-west-2:
AZs:
- a
- b
sa-east-1:
AZs:
- a
- b
us-east-1:
AZs:
- a
- b
us-east-2:
AZs:
- a
- b
us-west-1:
AZs:
- a
- b
us-west-2:
AZs:
- a
- b

Resources:
VPC:
Type: AWS::EC2::VPC
Expand All @@ -105,10 +47,7 @@ Resources:
- ${AWS::Region}${AZ}
- AZ: !Select
- 0
- !FindInMap
- AZRegions
- !Ref AWS::Region
- AZs
- !GetAZs ""
CidrBlock: !FindInMap
- SubnetConfig
- Public0
Expand All @@ -126,10 +65,7 @@ Resources:
- -public-
- !Select
- 0
- !FindInMap
- AZRegions
- !Ref AWS::Region
- AZs
- !GetAZs ""

PublicSubnet1:
Type: AWS::EC2::Subnet
Expand All @@ -139,10 +75,7 @@ Resources:
- ${AWS::Region}${AZ}
- AZ: !Select
- 1
- !FindInMap
- AZRegions
- !Ref AWS::Region
- AZs
- !GetAZs ""
CidrBlock: !FindInMap
- SubnetConfig
- Public1
Expand All @@ -160,10 +93,7 @@ Resources:
- -public-
- !Select
- 1
- !FindInMap
- AZRegions
- !Ref AWS::Region
- AZs
- !GetAZs ""

PrivateSubnet0:
Type: AWS::EC2::Subnet
Expand All @@ -173,10 +103,7 @@ Resources:
- ${AWS::Region}${AZ}
- AZ: !Select
- 0
- !FindInMap
- AZRegions
- !Ref AWS::Region
- AZs
- !GetAZs ""
CidrBlock: !FindInMap
- SubnetConfig
- Private0
Expand All @@ -193,10 +120,7 @@ Resources:
- -private-
- !Select
- 0
- !FindInMap
- AZRegions
- !Ref AWS::Region
- AZs
- !GetAZs ""

PrivateSubnet1:
Type: AWS::EC2::Subnet
Expand All @@ -206,10 +130,7 @@ Resources:
- ${AWS::Region}${AZ}
- AZ: !Select
- 1
- !FindInMap
- AZRegions
- !Ref AWS::Region
- AZs
- !GetAZs ""
CidrBlock: !FindInMap
- SubnetConfig
- Private1
Expand All @@ -226,10 +147,7 @@ Resources:
- -private-
- !Select
- 1
- !FindInMap
- AZRegions
- !Ref AWS::Region
- AZs
- !GetAZs ""

InternetGateway:
Type: AWS::EC2::InternetGateway
Expand Down
9 changes: 6 additions & 3 deletions scripts/test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

set -eou pipefail

echo "Linting..."
cfn-lint
SCRIPT_DIR=$(dirname "$0")
CONFIG_FILE="${SCRIPT_DIR}/../.cfnlintrc"

echo "Linting with config file ${CONFIG_FILE}"
cfn-lint --config-file ${CONFIG_FILE} **/*.yaml

echo "Guard..."
cfn-guard validate --data . \
--rules scripts/rules.guard \
--rules ${SCRIPT_DIR}/rules.guard \
--show-summary fail

echo "Success"
7 changes: 5 additions & 2 deletions scripts/test-single.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

set -eou pipefail

SCRIPT_DIR=$(dirname "$0")
CONFIG_FILE="${SCRIPT_DIR}/../.cfnlintrc"

echo "Linting..."
cfn-lint -- $1
cfn-lint --config-file ${CONFIG_FILE} -- $1

echo "Guarding..."
cfn-guard validate --data $1 --rules scripts/rules.guard --show-summary fail
cfn-guard validate --data $1 --rules ${SCRIPT_DIR}/rules.guard --show-summary fail

echo "Success"

0 comments on commit c45197a

Please sign in to comment.