Skip to content

Commit

Permalink
Update pre-commit (#236)
Browse files Browse the repository at this point in the history
Add cfn-lint config file;
Add tag to architecting templates
  • Loading branch information
rezabekf authored Aug 15, 2023
1 parent 07b895a commit f98f3dd
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 19 deletions.
10 changes: 10 additions & 0 deletions .cfnlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
templates:
- ./code/solutions/**/*.template
- ./code/solutions/**/*.yaml

ignore_templates:
- ./code/solutions/policy-as-code-with-guard/example_bucket_tests.yaml

ignore_checks:
# Supress "This code may only work with `package` cli command as the property <xyz> is a string".
- W3002
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ jobs:

# Run Tests
- name: CloudFormation lint test
run: cfn-lint code/solutions/**/*.yaml --ignore-templates code/solutions/policy-as-code-with-guard/example_bucket_tests.yaml
run: cfn-lint
- name: CloudFormation nag test
run: cfn_nag_scan --input-path code/solutions --ignore-fatal
23 changes: 12 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,44 @@ repos:

# CloudFormation
- repo: https://github.com/aws-cloudformation/cfn-python-lint
rev: v0.74.1
rev: v0.79.7
hooks:
- id: cfn-python-lint
name: AWS CloudFormation Linter
files: solutions/.*\.(yaml)$
files: solutions/.*\.(yaml|template)$
args:
- --ignore-templates=code/solutions/policy-as-code-with-guard/example_bucket_tests.yaml

- repo: https://github.com/aws-cloudformation/rain
rev: v1.2.0
rev: v1.4.4
hooks:
- id: cfn-format
files: solutions/.*\.(yaml)$
files: solutions/.*\.(yaml|template)$
exclude: code/solutions/policy-as-code-with-guard/example_bucket_tests.yaml

# Python
- repo: https://github.com/pycqa/pylint
rev: v2.16.4
rev: v3.0.0a6
hooks:
- id: pylint
args:
- --errors-only
- --disable=E0401

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
args: ["--profile", "black"]

# Shell check
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.2
rev: v0.9.0.5
hooks:
- id: shellcheck
files: solutions/.*\.(sh)$
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test: $(VENV_NAME)
$(VENV_NAME)/bin/pre-commit run --all-files

lint: $(VENV_NAME)
$(VENV_NAME)/bin/cfn-lint code/solutions/**/*.yaml --ignore-templates code/solutions/policy-as-code-with-guard/example_bucket_tests.yaml
$(VENV_NAME)/bin/cfn-lint

nag:
cfn_nag_scan --input-path code/solutions --ignore-fatal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: Sample template describing an example application deployment. (uksb-1q9p31idr)
Description: Sample template describing an example application deployment. (uksb-1q9p31idr) (tag:architecting-templates).

Parameters:
AppNameTagValue:
Expand Down
2 changes: 1 addition & 1 deletion code/workspace/architecting-templates/application.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: Sample template describing an example application deployment. (uksb-1q9p31idr)
Description: Sample template describing an example application deployment. (uksb-1q9p31idr) (tag:architecting-templates).

Parameters:
AppNameTagValue:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: Sample template describing an AWS::EC2::VPC resource, with two public subnets and 2 private subnets, route tables, and routes to the Internet. (uksb-1q9p31idr)
Description: Sample template describing an AWS::EC2::VPC resource, with two public subnets and 2 private subnets, route tables, and routes to the Internet. (uksb-1q9p31idr) (tag:architecting-templates).

Parameters:
AppNameTagValue:
Expand Down
2 changes: 1 addition & 1 deletion code/workspace/architecting-templates/cloud9.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: Sample template describing an AWS Cloud9 environment. (uksb-1q9p31idr)
Description: Sample template describing an AWS Cloud9 environment. (uksb-1q9p31idr) (tag:architecting-templates).

Parameters:
AppNameTagValue:
Expand Down
2 changes: 1 addition & 1 deletion code/workspace/architecting-templates/hosted-zone.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: Sample template describing an Amazon Route 53 hosted zone. (uksb-1q9p31idr)
Description: Sample template describing an Amazon Route 53 hosted zone. (uksb-1q9p31idr) (tag:architecting-templates).

Parameters:
AppNameTagValue:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: Sample template describing security group resources for an example application. (uksb-1q9p31idr)
Description: Sample template describing security group resources for an example application. (uksb-1q9p31idr) (tag:architecting-templates).

Parameters:
AppNameTagValue:
Expand Down

0 comments on commit f98f3dd

Please sign in to comment.