REST API
Add an API Gateway REST API
POST /dear-santa { gift: "lego" | "surprise", legoSKU?: "40499", from: "emmet" }Update CDK stack
import { Construct, Stack, StackProps } from "aws-cdk-lib";
import { RestApi } from "aws-cdk-lib/aws-apigateway";
export class EDAWorkshopStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const api = new RestApi(this, "EDAWorkshopAPI-YOUR_USER_NAME");
const dearSanta = api.root.addResource("dear-santa");
dearSanta.addMethod("POST");
}
}Run a build
Synthesise the CloudFormation template
Deploy CDK app
Test API endpoint
Last updated