-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Open
Labels
@aws-cdk/aws-apigatewayRelated to Amazon API GatewayRelated to Amazon API Gatewayeffort/mediumMedium work item – several days of effortMedium work item – several days of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p1
Description
❓ 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-apigatewayRelated to Amazon API GatewayRelated to Amazon API Gatewayeffort/mediumMedium work item – several days of effortMedium work item – several days of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p1
