Created
May 20, 2022 01:43
-
-
Save AntoniusGolly/4a4dee4a3aadd36eb3f5efe8c54a2242 to your computer and use it in GitHub Desktop.
Handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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