SAM - Disable authorizer for one event

74 views Asked by At

I've created a authorizer "ExampleAuthoriser" which is applying to all endpoints within that API. Although I've created a public endpoint which currently needs 0 authentication as it's in testing and public access is needed.

I've google'd around and it's told me that isn't not possible to turn the authorizer off for one event, and advised me to define separate APIs which is not the result I'm looking for.

I want "ExamplePostApi" to have no authentication applied, or a empty Authorizers property.

AWS::Serverless::HttpApi

    ExampleApi:
        Type: AWS::Serverless::HttpApi
        Properties:
            FailOnWarnings: True
            Auth:
                Authorizers:
                    ExampleAuthoriser:
                        JwtConfiguration:
                            issuer: !FindInMap [AccountMap, !Ref "AWS::AccountId", IssuerUrl]
            CorsConfiguration:
                AllowOrigins:
                    - !FindInMap [AccountMap, !Ref "AWS::AccountId", CorsAllowOrigins]
                AllowHeaders:
                    - "*"
                AllowMethods:
                    - POST
                MaxAge: 0

AWS::Serverless::Function

  ExampleService:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: dotnt6
      Timeout: 30
      MemorySize: 1024
      Events:
        ExampleGetApi:
          Type: HttpApi
          Properties:
            ApiId: !Ref ExampleApi
            Path: /get
            Method: POST
        ExamplePostApi:
          Type: HttpApi
          Properties:
            ApiId: !Ref ExampleApi
            Path: /post
            Method: POST
            //NO AUTH ON THIS EVENT
0

There are 0 answers