This project demonstrates how to set up an "infrastructure continuous delivery" architecture using GitHub, AWS CodePipeline and CloudFormation, with a project containing a nested stack.
- Fork this repo.
- Bootstrap the CloudFormation stack:
- Enter the forked repo's owner in the
GitHubOwner
field. - Create a New personal access token with
repo
andadmin:repo_hook
scopes, and enter the token in theGitHubToken
field. - Enter the name of an existing S3 bucket for storing pipeline artifacts in the
ArtifactBucket
field. (Create a bucket first if necessary.)
- Verify the newly-created stack and pipeline.
- Check the CloudFormation Console to ensure your stack reaches the
CREATE_COMPLETE
state successfully. - Check the CodePipeline Console to ensure the pipeline's
Source
andDeploy
stages both completed successfully.
- Check the CloudFormation Console to ensure your stack reaches the
- Update the parent CloudFormation stack:
- Modify
cfn-template.yml
in the Git repository, and commit/push the change. - For example, try renaming the
Dummy
resource todummy2
.
- Modify
- Update the child CloudFormation stack:
- Modify
nested.yml
in the Git repository, and commit/push the change. - For example, try renaming the
Dummy
resource toDummy2
.
- Modify
- Verify the stack update(s).
a. Check the CodePipeline Console to ensure the pipeline processes the new commit in both stages.
b. Check the CloudFormation Console to ensure your stack reaches the
UPDATE_COMPLETE
state successfully. c. Verify the created/updated resources in theResources
tab of the CloudFormation console match the values in the new template.
That's it!
Note: The CloudFormation Service Role (CFNRole
) grans full admin permissions ('*'
) to your AWS account.
For more restricted, fine-grained security, you should move the CFNRole
and PipelineRole
resources into a separate CloudFormation stack (or just create them manually), reference them using Fn::ImportValue
(or by a fixed-string name), and ensure that CFNRole
grants least privilege depending on the Resources in your stack.
Talk from re:Invent 2016, "Infrastructure Continuous Delivery Using AWS CloudFormation"