I'm using the tool to spin up locally an API gateway and run my lambda functions. However, I don't know how to configure an authorizer in template.yml
In my template.yml file, I have the following configuration:
JwtAuthorizerFunction:
Type: AWS::Serverless::Function
Properties:
Environment:
Variables:
JWT_SECRET: '<<secret>>'
Handler: authorizers.jwt
Runtime: nodejs6.10
Role:
Fn::ImportValue:
!Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]
If I understand the authorizers documentation correctly, I should be able to add the following configurations in order to configure my authorizer
Authorizer:
Type: "AWS::ApiGateway::Authorizer"
Properties:
AuthorizerCredentials:
Fn::GetAtt:
- "LambdaInvocationRole"
- "Arn"
AuthorizerResultTtlInSeconds: "300"
AuthorizerUri: "arn:aws:lambda:us-east-1:<<myarn>>:function:<<lambda function arn>>"
Type: "TOKEN"
IdentitySource: "method.request.header.Authorization"
Name: "DefaultAuthorizer"
RestApiId:
Ref: "RestApi"
Everything up until that point works fine. If I run
sam validate the output is Valid!
sam local start-api executes without a problem.
However, I don't know how to configure the custom authorizer in my lambda functions. I've read the AWS::Serverless::Function documentation but I couldn't find anything relevant to my issue. Furthermore, there are two issues about adding support for AuthorizationType to the API but it's unclear whether this support will ever be added, or if it has been added already.
Any help pointing in the right direction is greatly appreciated!
I'm using the tool to spin up locally an API gateway and run my lambda functions. However, I don't know how to configure an authorizer in
template.ymlIn my
template.ymlfile, I have the following configuration:If I understand the authorizers documentation correctly, I should be able to add the following configurations in order to configure my authorizer
Everything up until that point works fine. If I run
sam validatethe output isValid!sam local start-apiexecutes without a problem.However, I don't know how to configure the custom authorizer in my lambda functions. I've read the AWS::Serverless::Function documentation but I couldn't find anything relevant to my issue. Furthermore, there are two issues about adding support for AuthorizationType to the API but it's unclear whether this support will ever be added, or if it has been added already.
Any help pointing in the right direction is greatly appreciated!