LambdaTokenAuthorizer
Configure a Lambda Authorizer to control access to your API with a Lambda function.
For more information and examples, see Control API access with your AWS SAM template.
Syntax
To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.
YAML
DisableFunctionDefaultPermissions:BooleanFunctionArn:StringFunctionInvokeRole:StringFunctionPayloadType:StringIdentity:LambdaTokenAuthorizationIdentity
Properties
-
Specify
trueto prevent AWS SAM from automatically creating anAWS::Lambda::Permissionsresource to provision permissions between yourAWS::Serverless::Apiresource and authorizer Lambda function.Default value:
falseType: Boolean
Required: No
CloudFormation compatibility: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.
-
Specify the function ARN of the Lambda function which provides authorization for the API.
Note
AWS SAM will automatically create an
AWS::Lambda::Permissionsresource whenFunctionArnis specified forAWS::Serverless::Api. TheAWS::Lambda::Permissionsresource provisions permissions between your API and authorizer Lambda function.Type: String
Required: Yes
CloudFormation compatibility: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.
-
Adds authorizer credentials to the OpenApi definition of the Lambda authorizer.
Type: String
Required: No
CloudFormation compatibility: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.
-
This property can be used to define the type of Lambda Authorizer for an Api.
Valid values:
TOKENorREQUESTType: String
Required: No
Default:
TOKENCloudFormation compatibility: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.
-
This property can be used to specify an
IdentitySourcein an incoming request for an authorizer. This property is only required if theFunctionPayloadTypeproperty is set toREQUEST.Type: LambdaTokenAuthorizationIdentity
Required: Conditional
CloudFormation compatibility: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.
Examples
LambdaTokenAuth
YAML
Authorizers: MyLambdaTokenAuth: FunctionArn: Fn::GetAtt: - MyAuthFunction - Arn Identity: Header: MyCustomAuthHeader # OPTIONAL; Default: 'Authorization' ValidationExpression: mycustomauthexpression # OPTIONAL ReauthorizeEvery: 20 # OPTIONAL; Service Default: 300
BasicLambdaTokenAuth
YAML
Authorizers: MyLambdaTokenAuth: FunctionArn: Fn::GetAtt: - MyAuthFunction - Arn