Skip to content

Instantly share code, notes, and snippets.

@cal0610
Last active November 1, 2022 09:44
Show Gist options
  • Save cal0610/e60b8530eeb9caad1e7e649e2c974f81 to your computer and use it in GitHub Desktop.
Save cal0610/e60b8530eeb9caad1e7e649e2c974f81 to your computer and use it in GitHub Desktop.
add rest api
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
export class MyStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const api = new apigateway.RestApi(this, 'test-api', {
description: 'Test project',
deployOptions: {
stageName: 'dev',
},
defaultCorsPreflightOptions: {
allowOrigins: apigateway.Cors.ALL_ORIGINS, // replace with calling origin
allowMethods: apigateway.Cors.ALL_METHODS
},
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment