This is code sample that uses CDK to:
- Create a Pipeline Template to Deploy
- Create a Lambda that creates multiple pipelines using existing pipeline template for all the release branches
- triggerOnPush: true Controls automatically starting your exisiting pipeline when a new commit is made on the configured repository and branch.
- Ensure you've followed the guide to Getting Started to AWS CDK, and you have CDK installed, and the AWS SDK installed and credentials configured.
- Bootstrap your AWS environment
- The
cdk.json
file tells the CDK Toolkit how to execute your app. - For authentication we are using Isengardcli.
In short :
First, you will need to install the AWS CDK:
$ npm install -g aws-cdk
Install the required dependencies:
$ npm install
At this point you can build and then synthesize the CloudFormation template for this code.
$ npm run build
$ cdk synth
If you haven't already you'll need to deploy the CDK Bootstrap stack. This only needs to be ran once per account/region
$ cdk bootstrap
If everything looks good, go ahead and deploy!
$ cdk deploy
To see the CloudFormation template generated by the CDK, run cdk synth, then check the output file in the "cdk.out" directory.
- S3
- Cloudfront
- OriginAccessIdentity
- Cloudfront Function
- Codepipeline
- Lambda
- Eventbridge
- Codebuild
- IAM
- Source : Connect with GitHub, pull the code from latest/main branch
- Build : Build doc-site to docs folder
- PreDeploy Lambda : Empty S3 directory
- Deploy : Deploy to S3
- PostDeploy Lambda : Invalidate CloudFront cache
- Run periodically & create new pipeline from codePipeline-template above for each release branch.
The cdk.json
file in the root of this repository includes
instructions for the CDK toolkit on how to execute this program.
After building your TypeScript code, you will be able to run the CDK toolkits commands as usual:
$ cdk ls
<list all stacks in this program>
$ cdk synth
<generates and outputs cloudformation template>
$ cdk deploy
<deploys stack to your account>
$ cdk diff
<shows diff against deployed stack>
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template