-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(apigateway): LambdaRestApi fails when a user defined Stage is attached #5838
Conversation
…ached LambdaRestApi, by default, sets up a proxy integration as part of its construction which in turn binds the specified lambda function handler to the proxy using the LambdaIntegration class. The LambdaIntegration class needs to set up the right IAM permissions so API Gateway is able to invoke the Lambda function. The policy for this permission requires the ARN of the 'ANY' Method that is set up by the Proxy. When the 'deploy' option is set, it indicates to the RestApi construct and its sub-constructs (of which LambdaRestApi is one) to create a default deployment and stage as part of its construction. The user can also unset the 'deploy' option and specify their own Stage by setting the 'deploymentStage' on the RestApi construct. However, when the 'deploy' option is unset, the LambdaIntegration class cannot compute the ARN for the 'ANY' Method since there's no Stage and Deployment created. This generates at synthesis, even though there may be a Stage that the user has configured against the RestApi later on. The fix here is straightforward. Computation of the Method ARN should occur at the time of synthesis rather than at the time of construction. fixes #5744
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request is now being automatically merged. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request is now being automatically merged. |
LambdaRestApi, by default, sets up a proxy integration as part of its
construction which in turn binds the specified lambda function handler
to the proxy using the LambdaIntegration class.
The LambdaIntegration class needs to set up the right IAM permissions
so API Gateway is able to invoke the Lambda function. The policy for
this permission requires the ARN of the 'ANY' Method that is set up by
the Proxy.
When the 'deploy' option is set, it indicates to the RestApi construct
and its sub-constructs (of which LambdaRestApi is one) to create a
default deployment and stage as part of its construction. The user can
also unset the 'deploy' option and specify their own Stage by setting
the 'deploymentStage' on the RestApi construct.
However, when the 'deploy' option is unset, the LambdaIntegration class
cannot compute the ARN for the 'ANY' Method since there's no Stage and
Deployment associated. This produces an error when LambdaRestApi is
constructed, even though the user may configure a Stage later on.
The fix here is straightforward. Computation of the Method ARN should
occur at the time of synthesis rather than at the time of construction.
fixes #5744
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license