Skip to content
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

Can implicit API-Gateway definition from Lambda function definition have custom authorizer? #141

Closed
syang opened this issue May 25, 2017 · 3 comments

Comments

@syang
Copy link

syang commented May 25, 2017

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 #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
@kskory
Copy link

kskory commented May 30, 2017

@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.

@sanathkr
Copy link
Contributor

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

@sanathkr
Copy link
Contributor

Its happening #248!

aahung pushed a commit to aahung/serverless-application-model that referenced this issue Sep 8, 2022
* SAM T Serverless Connector Implementation

* Formatting Codes

* Adding Type Hints

* Fix failed unit tests

* Python 3.7 doesn't support TypedDict, revert partial changes

Addressing Feedback

Add more test to profile replace

* Move tests to unit test translator

* Use Managed Policy for Connectors

* Update Profiles.json

* Address Feedback and Modify Tests

* Rename some function and classes to better reflect the functionality

* Rename profile replace with better variables

* Handle hardcoded Role Arns

* Remove duplicate unit tests

Co-authored-by: Gavin Zhang <yuanhaoz@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants