小编use*_*652的帖子

如何为Api方法启用ApiKeyRequired?

我想使用API​​网关的标准API密钥功能.如果我使用标准的cloudformation,可以通过将方法的属性ApiKeyRequired设置为true来实现.我怎样才能用SAM做到这一点?

我尝试使用swagger,但似乎不起作用:

    swagger: "2.0"
    info:
      title: !Ref AWS::StackName

    paths:
      "/machines/{resourceid}":
        get:
          parameters: 
            - name: resourceid 
              in: path 
              type: string 
              required: true 
          x-amazon-apigateway-integration:
            httpMethod: POST
            type: aws_proxy
            uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyLambda.Arn}/invocations
            responses: {}
          security:
            - authorizer: []

    securityDefinitions:
      authorizer:
        type: apiKey
        name: Authorization
        in: header
Run Code Online (Sandbox Code Playgroud)

有什么建议?

aws-api-gateway aws-sam-cli serverless

5
推荐指数
1
解决办法
1213
查看次数

标签 统计

aws-api-gateway ×1

aws-sam-cli ×1

serverless ×1