AWS CDK Infrastructure Code
Cloud Development Kit
Infrastructure as Code using familiar languages (TypeScript/Python).
CDK Constructs
TypeScript Example:
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as apigw from "aws-cdk-lib/aws-apigateway";
new lambda.Function(this, "MyFunction", {
runtime: lambda.Runtime.NODEJS_18_X,
handler: "index.handler",
code: lambda.Code.fromAsset("lambda")
});
new apigw.LambdaRestApi(this, "Endpoint", {
handler: myFunction
});
Commands:
cdk synth (CloudFormation)
cdk deploy (provision)
cdk diff (drift detection)L1/L2/L3 Constructs
- L1: CloudFormation parity
- L2: Opinionated patterns
- L3: Application constructs (patterns)