Make your Life Easier by Running AWS CDK in a Docker Container

Cross post from Medium Tags: CDK, 3 Musketeers, AWS This is an example of AWS CDK in a docker container following the 3 Musketeers pattern. GitHub Repo: https://github.com/chrishart0/aws-cdk-typescript-3-musketeers What Is This 3 Musketeers Thing Anyway and Why Would I Want to Do Such a Thing as to Containerize the AWS CDK? Links: 3 Musketeers for an epic Developer Experience What is 3 Musketeers? What is AWS CDK There are a host of benefits to the 3 Musketeers pattern, which mostly center around Developer Experience....

February 22, 2022 · 3 min · chart

CloudFront 494 Error - Quick Fix

My team ran into a 494 error earlier this week coming out of CloudFront. The first few files requested from CloudFront would be successful, then we would hit the 494 error and most requests after that, but not all, would fail. The first place we looked was CloudFront logs, but these 494 requests weren’t getting logged at all. After some troubleshooting we narrowed the issue down to header size. Solution for CloudFront 494 Error Some functionality was added which increased the size of one of the headers....

February 5, 2021 · 1 min · chart

AWS CDK: Avoiding CDK stack dependency errors on updates

Have you encountered an error such as the one below? Export my-stack-1:ExportsOutputRefMyResource6724B74E921810D3 cannot be deleted as it is in use by my-stack-2 This is because: A resource created by my-stack-1.py has created an export my-stack-2.py is using this export in one of it’s resources You are attempting to change or remove the resource in my-stack-1.py, altering the export How can this error be worked around? One method would be to tear down my-stack-2, update my-stack-1, then re-deploy my-stack-2....

February 1, 2021 · 1 min · chart

AWS CDK: Place a Lambda function in specific subnets

I struggled for a while today to figure out how to place a lambda function inside of a given SubnetType of a VPC generated in the same CDK stack. To specify subnets for a lambda function it needs a SubnetSelection object passed in. I expected to find a method of ec2.VPC() which would give me an output with the type SubnetSelection but this doesn’t exist. After some reading of other people’s posts online I found an example which showed what I needed to do:...

January 27, 2021 · 1 min · chart

AWS CDK: Python Tips, Tricks, and Examples

Examples Official CDK Python Examples: https://github.com/aws-samples/aws-cdk-examples/tree/master/python Unofficial CDK best practices: https://github.com/kevinslin/open-cdk Basics Read the docs! Run the following command to open the CDK docs in your browser: cdk docs Set the deployment region In the app.py in the root of your CDK construct: add env={‘region’: ‘us-east-2’} to your ConstructStack(…). At time of writing this is on line 9 by default. It should look something like this: app = core.App() MyConstructStack(app, "my-construct", env={'region': 'us-east-2'}) Install new packages When working with a new services you may need to install them with a command similar to the one below:...

January 11, 2021 · 2 min · chart

Learning the AWS CDK

CloudFormation written in Python? Yes! After using the CDK for a bit, I believe it will be replacing CloudFormation for most AWS IaC in the coming years. The CDK is a layer of abstraction built on top of CloudFormation(CF). It allows you to write a condensed, but more powerful form of CF in one of several programming languages(JavaScript, TypeScript, Python, Java, and C#). You utilize AWS Constructs to more concisely deploy infra....

January 11, 2021 · 1 min · chart