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
GitHubOwnerfield. - Create a New personal access token with
repoandadmin:repo_hookscopes, and enter the token in theGitHubTokenfield. - Enter the name of an existing S3 bucket for storing pipeline artifacts in the
ArtifactBucketfield. (Create a bucket first if necessary.)
- Verify the newly-created stack and pipeline.
- Check the CloudFormation Console to ensure your stack reaches the
CREATE_COMPLETEstate successfully. - Check the CodePipeline Console to ensure the pipeline's
SourceandDeploystages both completed successfully.
- Check the CloudFormation Console to ensure your stack reaches the
- Update the parent CloudFormation stack:
- Modify
cfn-template.ymlin the Git repository, and commit/push the change. - For example, try renaming the
Dummyresource todummy2.
- Modify
- Update the child CloudFormation stack:
- Modify
nested.ymlin the Git repository, and commit/push the change. - For example, try renaming the
Dummyresource 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_COMPLETEstate successfully. c. Verify the created/updated resources in theResourcestab 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"