support for stage variables in lambda and https integration
See original GitHub issue❓ General Issue
How to pass a stage variable to lambda function field in API Gateway?
I have an API Gateway that triggers a lambda function specified by a stage variable stageVariables.lbfunc
.
How can I create this API Gateway with AWS CDK?
It looks like that I should create a special handler
for LambdaRestApi.
But I can’t find any example code for doing this.
The following is my current code. I wish that LambdaIntegration
’s handler can be determined by a stage variable.
# dev_lambda_function should be replaced by something else
dev_lambda_function = lambda_.Function(self, "MyServiceHandler",
runtime=lambda_.Runtime.PYTHON_3_7,
code=lambda_.Code.asset("resources"),
handler="lambda_function.lambda_handler",
description="My dev lambda function"
)
stage_options = apigateway.StageOptions(stage_name="dev",
description="dev environment",
variables=dict(lbfunc="my-func-dev")
)
# What should I pass to the handler variable so that LambdaRestApi triggers the lambda function specified by the stage variable "stageVariables.lbfunc"?
api = apigateway.LambdaRestApi(self, "my-api",
rest_api_name="My Service",
description="My Service API Gateway",
handler=dev_lambda_function,
deploy_options=stage_options)
Environment
- CDK CLI Version: 1.22.0 (build 309ac1b)
- Module Version:
- OS: OSX Mojave
- Language: Python
Other information
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Setting up stage variables for a REST API deployment
Stage variables are name-value pairs that you can define as configuration attributes associated with a deployment stage of a REST API.
Read more >HTTP API Integration with lamda function and stage variable ...
I have an HTTP API with two stages dev and prod. Each stage has a stage variable 'environment', for the dev stage the...
Read more >Stage variable with lambda - Amazon API Gateway p18
So, at a high level, how we can use the stage variables. --- Support my work: --- Patreon: https ://www.patreon.com/srcecde PayPal: ...
Read more >Stage variables - Amazon HTTP API tutorial p16 - YouTube
AWS ECS Tutorial | Deploy a New Application from Scratch | KodeKloud · Stage variable with lambda version & alias - Amazon API...
Read more >Working with stages for HTTP APIs - Amazon API Gateway
To use a stage variable for a Lambda function, the function must be in the same account as the API. Stage variables don't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any update on this issue? We are currently blocked with this and would like to know if there are any alternative approach?
Agree with rampatina - the inability to pass stage variables negates the ability to utilize API-GW stages as they were designed/intended to be used, forcing sub-optimal design of multiple GWs; one per stage.