Serverless-application-model: Can implicit API-Gateway definition from Lambda function definition have custom authorizer?

Created on 25 May 2017  路  3Comments  路  Source: aws/serverless-application-model

If I'd like to define my API-Gateway through an 'implicit way', i.e., by defining the Lambda function and its associated Events-->ApiEventSource. See an example below.

Could I define the custom authorizer in this way? If so, how?

(Here is an example copied&pasted from https://github.com/awslabs/serverless-application-model/issues/104)

Resources:
  Create:
    Type: AWS::Serverless::Function
    Properties:
      Handler: meta/create.create
      CodeUri: app/
      Runtime: nodejs4.3
      Policies: AWSLambdaBasicExecutionRole
      Environment:
        Variables:
          DYNAMODB_TABLE_ENV: !Sub '${ServiceName}-${Stage}'
      Events:
        ApiEventSource:
          Type: Api
          Properties:
            Path: /
            Method: POST

  Delete:
    Type: AWS::Serverless::Function
    Properties:
      Handler: meta/delete.delete
      CodeUri: app/
      Runtime: nodejs4.3
      Policies: AWSLambdaBasicExecutionRole
      Environment:
        Variables:
          DYNAMODB_TABLE_ENV: !Sub '${ServiceName}-${Stage}'
      Events:
        ApiEventSource:
          Type: Api
          Properties:
            Path: /meta/{metaId}
            Method: DELETE
typfeature

Most helpful comment

I'll mark this as a feature request, because custom authorizers are a great thing to have in general. We'lll get this prioritiezed

All 3 comments

@syang "Implicit way" doesn't support that, you have to use AWS::Serverless::Api and define custom authorizers in swagger. Remember that for API event source in Lambda:

If an AWS::Serverless::Api resource is defined, the path and method values MUST correspond to an operation in the Swagger definition of the API.

I'll mark this as a feature request, because custom authorizers are a great thing to have in general. We'lll get this prioritiezed

Its happening #248!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PMudra picture PMudra  路  4Comments

feinstein picture feinstein  路  3Comments

angustohrallegrinski picture angustohrallegrinski  路  3Comments

voigt picture voigt  路  3Comments

polovi picture polovi  路  3Comments