在 cloudformation 中,AWS::ApiGateway::Method
具有布尔属性ApiKeyRequired
。我怎样才能在 SAM 中达到同样的效果?
我知道我们可以使用显式招摇配置启用。就像这样
{
"swagger": "2.0",
"info": {
"version": "1.0",
"title": {
"Ref": "AWS::StackName"
}
},
"x-amazon-apigateway-api-key-source": "HEADER",
"paths": {
"/": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": {
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHelloWorld.Arn}/invocations"
}
},
"responses": {},
"security": [
{
"api_key": []
}
]
}
}
},
"securityDefinitions": {
"api_key": {
"type": "apiKey",
"name": "x-api-key",
"in": "header"
}
}
}
不能在 SAM 中使用隐式 API 调用而不是显式传递AWS::Serverless::Api
?因为 swagger 代码对于较少的端点是可以的,并且一旦端点增加就会变得复杂。有没有APIkeyRequired
像我们这样的旗帜Cloudformation
?
感谢任何帮助谢谢