Allow Lambda Aliases To Be Used With Constructs
In a Re:Invent video about CDK Pipelines, they demoed using lambda aliases to perform canary and linear rollouts of lambdas to a stack. However it does not appear that any of the official CDK Constructs Solutions (let alone the community ones) allow for using a lambda alias as the existing lambda reference.
Use Case
Allow canary and linear rollout of lambda changes in conjunction with integration tests on deployment when using CDK Solutions Constructs with CDK Pipelines.
Proposed Solution
{
existingLambda: /* IFunction instead of Function */
}
Other
- [ ] :wave: I may be able to implement this feature request
- [ ] :warning: This feature might incur a breaking change
This is a :rocket: Feature Request
Thanks - that's an interesting idea. We'll take a look.
Any updates on this ?
Background: We are using CDK to create a infrastructure. We use rest api gateway and lambda and integrate them together. We use "software.amazon.awsconstructs.services.apigatewaylambda.ApiGatewayToLambda" construct for this integration. The sample code below.
apiGatewayToLambda = ApiGatewayToLambda.Builder
.create(this, stageId + names.componentName + "RestApi")
.existingLambdaObj(lambdaFunction)
.apiGatewayProps(
mapOf(
"proxy" to false,
"restApiName" to "${waveId}${stageId}${names.componentName}RestApi",
"deployOptions" to deployOptions
)
).build()
}
Problem: We want to provision the lambda since the we are getting "504 - gateway timeout" from API gateway. On investigation we found that the lambda is getting timeout due to cold start.
Blocker: The lambda provisioning can be done only to lambda alias. When we analyze the ApiGatewayToLambda , it does n't accept the lambda alias as input.
How do we go about it ? Are there any workaround ? Can some one from support help me with the path forward ? Some java cdk code samples will be helpful.
We can think of re-writing the integration using this article - https://bobbyhadz.com/blog/aws-cdk-api-gateway-example , but we are worried that it will make a modification to the stack and make impact to the existing resources and services.
Hence looking for a quick resolution on this.
We did something like the below. Credits goes to AWS support folks. Thanks to them.
val function = ((lambdaFunctionAlias as Alias).lambda as Function)
apiGatewayToLambda = ApiGatewayToLambda.Builder .create(this, stageId + componentName + "RestApi") .existingLambdaObj(function) .apiGatewayProps( mapOf( "proxy" to false, "restApiName" to "${waveId}${stageId}${names.componentName}RestApi", "deployOptions" to deployOptions