Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Lambda Aliases To Be Used With Constructs #208

Open
2 tasks
miles-po opened this issue Jun 3, 2021 · 3 comments
Open
2 tasks

Allow Lambda Aliases To Be Used With Constructs #208

miles-po opened this issue Jun 3, 2021 · 3 comments
Assignees
Labels
feature-request A feature should be added or improved needs-triage The issue or PR still needs to be triaged

Comments

@miles-po
Copy link

miles-po commented Jun 3, 2021

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

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@miles-po miles-po added feature-request A feature should be added or improved needs-triage The issue or PR still needs to be triaged labels Jun 3, 2021
@biffgaut
Copy link
Contributor

biffgaut commented Jun 4, 2021

Thanks - that's an interesting idea. We'll take a look.

@biffgaut biffgaut self-assigned this Jun 7, 2021
@gvnavin
Copy link

gvnavin commented Mar 28, 2023

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.

@gvnavin
Copy link

gvnavin commented Mar 29, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved needs-triage The issue or PR still needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants