-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Inline swagger with x-amazon-apigateway-any-method doesn't work with "ANY" method API event #289
Comments
An additional complication - the workaround mentioned above only works locally. Deploying it, Cloud Formation creates permissions in the Lambda function policy which are specific to each HTTP verb, e.g.:
Since an
Currently, to ensure local and cloud can both work from a single template, I need to define a function API event per HTTP method and one for the ANY method, in other words:
This is pretty ugly. |
Hi, |
+1 ... also having this exact same issue on 0.2.11. |
I also got exactly the same problem. |
@StefanSmith This was corrected in the 0.3.0 release. Closing since this has been addressed. We even have integ tests for it: https://github.com/awslabs/aws-sam-cli/blob/develop/tests/integration/local/start_api/test_start_api.py#L180 :) |
This is now working for me as expected @jfuss. Thanks! |
thanks @StefanSmith for documenting this issue. Searched high and low for how to set up the I added the following to my SAM API resource
and added the following to my SAM Lambda Resource
|
I'm encountering an issue on SAM Local v0.2.6 that doesn't occur when deploying the SAM template to AWS.
Given the following template.yml:
The output from
sam local start-api
includes the following:The response code from
curl http://localhost:3000
is502 Bad Gateway
and the body is:I should add that the above works fine when deployed to a real Cloud Formation stack. It just behaves differently in SAM Local.
My current workaround to this issue is to add an API event to the function for each HTTP method, i.e.
Then the output of
sam local start-api
includes:I can then curl the API with no problems.
Having looked at the SAM Local code, I can see that when a Swagger definition is parsed, the
x-amazon-apigateway-any-method
operation results in separate HTTP methods (GET, POST, etc) being added to theNewServerlessRouter
. Conversely, when an API function event with anANY
method is parsed, only a singleANY
method is added toNewServerlessRouter
. The subsequent merge operation to consolidate mounts and handlers therefore fails to map the multiple Swagger methods to the single function method handler.Could this be fixed by changing the merge logic in
NewServerlessRouter
to be more intelligent about which mounts should be merged when an 'ANY' mount is encountered?The text was updated successfully, but these errors were encountered: