Skip to content

Instantly share code, notes, and snippets.

@AntoniusGolly
Created May 20, 2022 01:43
Show Gist options
  • Save AntoniusGolly/4a4dee4a3aadd36eb3f5efe8c54a2242 to your computer and use it in GitHub Desktop.
Save AntoniusGolly/4a4dee4a3aadd36eb3f5efe8c54a2242 to your computer and use it in GitHub Desktop.
Handler
import { Stack, StackProps} from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as lambda from 'aws-cdk-lib/aws-lambda-nodejs'
import * as apigateway from 'aws-cdk-lib/aws-apigateway'
import { LambdaIntegration } from './LambdaIntegration'
export class LegacyWrapperStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const handler = new lambda.NodejsFunction(this, "RoutesHandler", {
entry: './src/handler.ts',
handler: "handler"
});
const apiResourcePolicy = new iam.PolicyDocument({
statements: [
new iam.PolicyStatement({
actions: ['execute-api:Invoke'],
principals: [new AnyPrincipal()],
resources: ['execute-api:/*/*/*'],
})
]
})
const api = new apigateway.RestApi(this, "legacy-wrapper-api", {
restApiName: "My Api",
policy: apiResourcePolicy
});
const lambdaIntegration = new LambdaIntegration(handler, {
restApi: api,
requestTemplates: {"application/json": '{ "statusCode": "200" }'}
});
// add routes to API Gateway
// many, many routes ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment