Loading...
Loading...
Common AWS CDK patterns and constructs for building cloud infrastructure with TypeScript, Python, or Java. Use when designing reusable CDK stacks and L3 constructs.
npx skill4agent add sickn33/antigravity-awesome-skills cdk-patternsRemovalPolicyTagsimport { Construct } from "constructs";
import * as apigateway from "aws-cdk-lib/aws-apigateway";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
export class ServerlessApiPattern extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
const table = new dynamodb.Table(this, "Table", {
partitionKey: { name: "pk", type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
removalPolicy: cdk.RemovalPolicy.RETAIN,
});
const handler = new lambda.Function(this, "Handler", {
runtime: lambda.Runtime.NODEJS_20_X,
handler: "index.handler",
code: lambda.Code.fromAsset("lambda"),
environment: { TABLE_NAME: table.tableName },
tracing: lambda.Tracing.ACTIVE,
});
table.grantReadWriteData(handler);
new apigateway.LambdaRestApi(this, "Api", { handler });
}
}cdk.Tags.of(this).add()cdk diffCfn*cdk.Aws.ACCOUNT_ID