serverless-application-model
serverless-application-model copied to clipboard
"Auth" property do not work with "AWS::Include" DefinitionBody
Description:
We need to use some cloudformation functions in our swagger. So the "AWS::Include" transform is used in the DefnitionBody. I tried to move the authorizer declaration out of the swagger using the new "Auth" property. But I received an error of "Unable to add Auth configuration because 'DefinitionBody' does not contain a valid Swagger". Also, I notice the authorizer caching TTL is not an attribute in the "Auth" property?
** Template snippet:**
Type: AWS::Serverless::Api
Properties:
StageName: !Ref "Environment"
EndpointConfiguration: REGIONAL
Auth:
Authorizers:
RequestAuth:
FunctionPayloadType: REQUEST
FunctionArn: !FindInMap [EnvironmentDependentParams, !Ref "Environment", "AuthorizerArn"]
FunctionInvokeRole: !FindInMap [EnvironmentDependentParams, !Ref "Environment", "AuthorizerCredentials"]
Identity:
Headers:
- Authorization
Context:
- httpMethod
- path
ReauthorizeEvery: 0 # OPTIONAL; Service Default: 300
DefinitionBody:
'Fn::Transform':
Name: 'AWS::Include'
Parameters:
Location: s3://accolade-api-swaggers-test-577121982548/users.yml
This is a limitation in SAM's authorizer support. It only works with inline swagger definitions and AWS::Include is not supported. SAM's authorizer support needs access to the swagger definition, because it modifies it to add auth information. However, since the SAM transform is executed before the AWS::Include transform is executed, it cannot access the swagger document to modify it.
Can this be re-opened so it can be added to the documentation? @jlhood (Specifically, https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api-auth-object)
I just wasted a couple hours which would have been saved if it were there 😄 no dig, just so others don't hit the same thing 👍
@abbottdev Sure, reopening. Would you be willing to contribute the PR to update the docs? You can follow this guide to get setup or even make the change directly via the GitHub UI since it's just a documentation change.
Closing in favor of https://github.com/aws/serverless-application-model/issues/2533.