Last active
December 12, 2022 20:12
-
-
Save fl0wo/2a683e1949b2dc8ae5f7f94ff1383b44 to your computer and use it in GitHub Desktop.
AddPrivateEndpointsToRestApiGateway
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
export const addEndpointsToRestApiGateway = ( | |
stack: Construct, | |
api:RestApi, | |
apis: Array<ApiRestEndpoint>) => { | |
apis.forEach(rest => { | |
const route = api.root.addResource(rest.path); | |
route.addMethod( | |
rest.https_methods[0], | |
new LambdaIntegration(rest.fun), | |
); | |
}); | |
return api; | |
} |
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
export const addPrivateEndpointsToRestApiGateway = ( | |
scope: Construct, | |
api: RestApi, | |
authorizer: Authorizer, | |
authorizationType: AuthorizationType, | |
apis: Array<ApiRestEndpoint> | |
) => { | |
apis.forEach(rest => { | |
const route = api.root.addResource(rest.path); | |
route.addMethod( | |
rest.https_methods[0], | |
new LambdaIntegration(rest.fun), | |
{ | |
authorizer: authorizer, | |
authorizationType: authorizationType | |
} | |
); | |
}); | |
return api; | |
} |
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 {NodejsFunction} from "aws-cdk-lib/aws-lambda-nodejs"; | |
import {HttpMethod} from "aws-cdk-lib/aws-events"; | |
export interface ApiRestEndpoint { | |
description: string, | |
id: string, | |
fun: NodejsFunction, | |
https_methods: Array<HttpMethod>, | |
path: string | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment