-
Notifications
You must be signed in to change notification settings - Fork 2.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
Unable to set authorizer on AWS::Serverless::HttpApi on $default path #2481
Comments
Hey, I think you're encountering this issue because you're missing the |
(*I made an edit to make yaml formatted.) Assuming I understand correctly, what you are trying to do here is quite similar to one of our example "HttpApi with configuration settings" and you can find it here: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-httpapi.html, let me paste it at the end of this comment. Both are trying to "define a AWS::Serverless::HttpApi and use it in a function." You can try to replace ...
HttpApiEvent:
Type: HttpApi
Properties:
TimeoutInMillis: 20000
PayloadFormatVersion: '2.0'
Auth:
Authorizer: MyOauth2Authorizer
... with this ...
HttpApiEvent:
Type: HttpApi
Properties:
ApiId: !Ref Api
TimeoutInMillis: 20000
PayloadFormatVersion: '2.0' About
|
Hi @aahung , I found changing the template to the below structure worked. Is this the right way to construct it? https://gist.github.com/rockey5520/a654124bb6b891ce329470f1c0d63474 |
Your template creates two APIs, I don't think it is what you want. Would you mind trying to write your template based on the example I sent you? Like this:
|
Hi @aahung I tried with the structure given above. But I need to make a small change where my API Gateway needs to accept any HTTP methods and pass the request to lambda and replaced the above structure PATH to be as / and removed METHOD. By doing so I am getting error as CREATE_FAILED AWS::ApiGatewayV2::Api HttpApi Warnings found during import: Parse |
Can you post your updated template here? |
Sure @aahung , I am trying to get HttpAPI on gateway with $default route which can accept ANY HTTP method Template.yaml I tried using is : https://gist.github.com/rockey5520/8d9ae3828075149b40a31c6acad68476 |
Sorry for the delay @rockey5520. Support for I am marking this issue as a feature request and will update after discussing in team. Please let me know if you have any questions. Thanks |
Thank @c2tarun for answering. One question i have is, via SAM template is it possible to create a method OPTIONS to the httpapi gateway which does not need to integrate with lambda but it does need to exist for my case? Reason : I was able to overcome this situation by setting OPTIONS on httpapi via console but it would nice to have that in template. Hope my question makes sense or let me know I will try to rephrase. The same was accomplished via restapi following https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html but I am looking for the same in httpapi |
I have the same issue with Sam local and HttpApi auth... it works fine when deployed but the Auth is not used locally... Any ideas ? |
As for auth support in |
|
Hey @tbenhamou I can give you template structure that worked for me, if you like to adjust yours and see if it helps https://gist.github.com/rockey5520/82a32603ea096621be524f2816da98c2 Hope it works |
Hey @rockey5520 , Thanks for assisting me! Your template helped me for some other stuff but I found my issue just a few minutes ago!!! BTW, The field Thank you! |
This is a request on the SAM Spec not CLI. Moving to the correct repo (to make it easier to track) and updated the title to reflect the request. |
Just FYI for anyone getting here with Properties issuer and audience are case insensitive and can be used either lowercase as in OpenAPI or uppercase Issuer and Audience as in AWS::ApiGatewayV2::Authorizer. For my issue with Authorizer not showing up, I had to update SAM CLI as well as change Audience to a list as in...
|
Description:
Unable to set OAuth2 authorizer on API method [x-amazon-apigateway-any-method] for path [$default]
Steps to reproduce:
Below is template.Yaml file used and when run sam deploy gives errror as
Waiting for changeset to be created..
"Error: Failed to create changeset for the stack: finapi, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [XXX] is invalid. Event with id [HttpApiEvent] is invalid. Unable to set Authorizer [MyOauth2Authorizer] on API method [x-amazon-apigateway-any-method] for path [$default] because the related API does not define any Authorizers."
Observed result:
Waiting for changeset to be created..
Error: Failed to create changeset for the stack: finapi, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [FinApiFunction] is invalid. Event with id [HttpApiEvent] is invalid. Unable to set Authorizer [MyOauth2Authorizer] on API method [x-amazon-apigateway-any-method] for path [$default] because the related API does not define any Authorizers.
Expected result:
function with API method [x-amazon-apigateway-any-method] for path [$default] is created on API gateway with OAuth 2.0/JWT authorizer configured
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.15.0Add --debug flag to command you are running
The text was updated successfully, but these errors were encountered: