This project is a simple way to create, lint, and deploy a basic Kubernetes cluster using CloudFormation. However, the CloudFormation template included in the project can be replaced by any CloudFormation template and it would work.
CloudFormation templates usually throw all sorts of errors that might not be caught by traditional linters. Sometimes the errors are not caught until much later on after a lot of resources have already been deployed, which could lead to a lot of problems. This particular linter checks that the resources being deployed are deployed in the right order, checks the syntax, and ensures that no errors occur during deployment.
The following files are included in this project:
amazon-eks-controlplane-template.yaml
: This is the CloudFormation EKS Cluster Template. Ideally, this program works with any type of CloudFormation template..pre-commit-config.yaml
: This file is used for running unit tests on the template before uploading the stack to AWS or including it in our CI/CD pipeline.requirements.txt
: This can be installed before running the file, but ideally, you only need Python 3.9 installed on the device that this program is run on.
To run the tests, you must ensure that Python 3.9 is installed. Follow these steps:
- Ensure you replace the
amazon-eks-controlpane-template.yaml
with the CloudFormation file you want to lint. - Replace the file name in
.pre-commit-config.yaml
with the CloudFormation file name to be linted. cd
to the project folder on your terminal.- Run
pre-commit run --all-files
. - All the tests should run and show the green "passed".
The tests being run on the templates are:
- Trim Trailing white space
- End for file space
- CFN-Lint
- CFN-Nag
To further extend this project, cloud radar can be used to perform Python unit tests that will simulate the launching of the resources and verify that they are accurately launched.