我正在尝试使用 swagger 扩展将 swagger 与 api 网关和 lambda 集成。 Swagger 文件上传到 S3 存储桶中,我使用 Body 进行转换并包含如下
在 AWS::ApiGateway::RestApi 属性中使用 BodyS3Location 返回错误“无法解析 API 定义,因为上面提到的同一集成的集成格式错误”Swagger file with AWS Extensions stored in S3 Bucket for API Creation with Cloudformation 。
并修改 AWS::ApiGateway::RestApi 属性的模板如下
body :
Fn::变换:
名称:AWS::包括
参数:
地点:
Fn::Sub: "s3://${BucketName}/apiSwaggerSpec.yaml"
对于上面的堆栈,我拥有 cloudformation 操作的所有权限
下面的代码我添加为 swagger 扩展。
x-amazon-apigateway-auth:
类型:“aws_iam”
x-amazon-apigateway-集成:
类型:“aws_proxy”
http方法:“POST”
passthroughBehavior:“when_no_match”
网址:
Fn::Sub: "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:${accountId}:function:testLambdaFunction/调用”
证书:
Fn::Sub: "arn:aws:iam::${accountId}:role/${myRole}"
回应:
默认:
状态代码:200
我收到权限被拒绝错误,消息如下 myrole 无权对资源执行 cloudformation:CreateChangeSet:arn:aws:cloudformation:us-east-1:aws:transform/include
我是否需要为转换/包含添加特殊权限。 aws 文档说它不需要特殊权限?
最佳答案
我遇到了同样的问题,这个问题是我在搜索时能找到的唯一有意义的结果。尽管 AWS 声称与此相反,但似乎确实需要一项许可,但错误消息提示的许可似乎是唯一的许可;之后,包含转换似乎可以工作。这是我添加的整个政策:
PolicyDocument:
Version: "2012-10-17"
Statement:
- # The AWS::Include transform requires this weird permission.
Sid: UseInclude
Effect: "Allow"
Action: "cloudformation:CreateChangeSet"
Resource: !Sub "arn:aws:cloudformation:${AWS::Region}:aws:transform/Include"
关于amazon-web-services - 资源 arn :aws:cloudformation:us-east-1:aws:transform 的权限问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53993584/