Skip to content

towardsthecloud/aws-cdk-examples

Repository files navigation

AWS CDK Examples Banner

AWS CDK Examples

A collection of AWS CDK code samples crafted in TypeScript, featured on my blog at https://towardsthecloud.com/blog

Tip

Stop AWS bill surprises from happening.

Most infrastructure changes look harmless until you see next month's AWS bill. CloudBurn prevents this by analyzing the cost impact of your AWS CDK changes directly in GitHub pull requests, catching expensive mistakes during code review when fixes are quick, not weeks later when they're costly and risky.

Install CloudBurn from GitHub Marketplace

💰 Set it up once, then never be surprised by AWS costs again
  1. First install the free CDK Diff PR Commenter GitHub Action in your repository where you build your AWS CDK infrastructure
  2. Then install the CloudBurn GitHub App on the same repository

What happens now:

Whenever you open a PR with infrastructure changes, the GitHub Action comments with your CDK diff analysis. CloudBurn reads that diff and automatically adds a separate comment with a detailed cost report showing:

  • Monthly cost impact – Will this change increase or decrease your AWS bill? By how much?
  • Per-resource breakdown – See exactly which resources are driving costs (old vs. new monthly costs)
  • Region-aware pricing – We pick the right AWS pricing based on the region where your infrastructure is deployed

Your team can now validate cost impact alongside infrastructure changes during code review. Essentially, this shifts FinOps left where you optimize costs as you code, not weeks later when context is lost and production adjustments require more time and carry added risk.

CloudBurn will be free during beta. After launch, a free Community plan (1 repository with unlimited users) will always be available.

How to run the code from the examples

To run a Typescript example, execute the following:

$ npm install -g aws-cdk
$ cd EXAMPLE_DIRECTORY
$ npm install
$ cdk synth
$ cdk deploy

Then, to dispose of the stack/s afterwards

$ cdk destroy

Table of Contents

AWS CDK Example Description Blogpost link
application-load-balanced-fargate-service Create an Application Load Balanced Fargate Service in AWS CDK Click here
cloudfront-s3-origin Create a CloudFront distribution with an S3 bucket as origin .
custom-role-lambda-function Create a custom IAM role for an AWS Lambda function Click here
aws-cdk-dependson-relation Create a DependsOn relation between resources in AWS CDK Click here
openid-connect-bitbucket Create a Bitbucket OpenID Connect (OIDC) provider in AWS CDK Click here
openid-connect-github Create a GitHub OpenID Connect (OIDC) provider in AWS CDK Click here
rds-with-cloudwatch-alarms Create an Amazon RDS instance with custom CloudWatch alarms .
scheduled-fargate-task Create a Scheduled Fargate Task example in AWS CDK Click here
scheduled-rds-stop-and-start Create a Scheduled stop and start function for an Amazon RDS Instance Click here
share-resources-across-stacks Create a stack where you share resources to another stack Click here

Author

Danny Steenman

Sponsor this project