![made-with-TypeScript](https://img.shields.io/badge/made--with-TypeScript-brightgreen) ## About 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. ## ⚡️ Quick Start * Ensure you've followed the [guide to Getting Started to AWS CDK](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html), and you have CDK installed, and the AWS SDK installed and credentials configured. * [Bootstrap your AWS environment](https://docs.aws.amazon.com/cdk/latest/guide/serverless_example.html#serverless_example_deploy_and_test) * 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](https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html). _This only needs to be ran once per account/region_ ```sh $ cdk bootstrap ``` If everything looks good, go ahead and deploy! ```sh $ cdk deploy ``` ## Synthesize CloudFormation Template To see the CloudFormation template generated by the CDK, run cdk synth, then check the output file in the "cdk.out" directory. ## CDK Stack has following resources * S3 * Cloudfront * OriginAccessIdentity * Cloudfront Function * Codepipeline * Lambda * Eventbridge * Codebuild * IAM ## CodePipeline Template - 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 ## Cron Lambda - Run periodically & create new pipeline from codePipeline-template above for each release branch. ## CDK Toolkit The [`cdk.json`](./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 $ cdk synth $ cdk deploy $ cdk diff ## Useful commands * `npm run build` compile typescript to js * `npm run watch` watch for changes and compile * `npm run test` perform the jest unit tests * `cdk deploy` deploy this stack to your default AWS account/region * `cdk diff` compare deployed stack with current state * `cdk synth` emits the synthesized CloudFormation template