简体   繁体   中英

How to add non authenticated routes in AWS SAM template

So this is my SAM template:

webApi:
    Type: AWS::Serverless::Api
    Properties:
      Auth:
        DefaultAuthorizer: CognitoAuthorizer
        Authorizers:
          CognitoAuthorizer:
            UserPoolArn: !GetAtt myUserPool.Arn
        AddDefaultAuthorizerToCorsPreflight: false
      Cors:
        AllowMethods: "'*'"
        AllowHeaders: "'*'"
        AllowOrigin: "'*'"
      StageName: !Ref Environment
      DefinitionBody:
        swagger: "2.0"
        info:
          title:
            Ref: AWS::StackName
        paths:
        /path/one:
            post:
              responses: {}
              x-amazon-apigateway-integration:
                uri: myFunction.Arn
                httpMethod: "POST"
                type: "aws_proxy"
          /path/two:
            post:
              responses: {}
              x-amazon-apigateway-integration:
                uri: myFunction.Arn
                httpMethod: "POST"
                type: "aws_proxy"

How can I make the path/two an non authenticated route? I tried to google but there was nothing.

If possible I don't want to create another API Gateway. I would like to do it within the same resource.

In AWS SAM template, to disable security for specific endpoints in the DefinitionBody , what worked for me is the following:

 swagger: "2.0"
        info:
          title:
            Ref: AWS::StackName
        paths:
          /path/one:
            post:
              security:
                - NONE: []

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM