CloudFormation template to create CI/CD Pipeline used to continuously develop CloudFormation templates.
This template creates the following:
-
CodeCommit Respository
-
CodePipeline with the following:
- CodeCommit Repo as the source stage
- CloudFormation as the deploy stage
-
S3 bucket for CodePipeline artifacts
-
Custom Resource that does the following:
-
During stack creation:
-
Performs an initial commit to this repo with the following files:
-
template.yml
: CloudFormation template file -
input-params.json
: File that holds the input parameter values to be passed to CloudFormation during create-stack and update-stack operations
-
-
-
During stack deletion:
- removes all objects from the S3 bucket so that it can successfully be deleted by the CloudFormation stack
-
aws cloudformation create-stack --stack-name CloudFormation-Template-Development-CI-CD-Pipeline --template-body file://CloudFormation-Template-Development-CI-CD-Pipeline.yml --capabilities CAPABILITY_NAMED_IAM
Having a CI/CD Pipeline for CloudFormation template creation is extremely useful. You can begin building your template in the template.yml
file in the git repo, and as each resource is added (or a small group of resources) you can do the following:
-
validate the template with the following command:
aws cloudformation validate-template --template-body file://template.yml
-
commit changes to the local git repo, and then push the changes to the remote repo with
git push
Once the CodeCommit repo has a new commit, the Pipeline is triggered and will perform an update-stack operation on the CloudFormation stack for this template.
This way you can continually add to the template and know that the resources that you have created are able to successfully launch without issues.