首页 > 解决方案 > 资源 arn:aws:cloudformation:us-east-1:aws:transform 的权限问题

问题描述

我正在尝试使用 swagger 扩展将 swagger 与 api 网关和 lambda 集成。Swagger 文件上传到 S3 存储桶中,我使用带有变换的 Body 并包括如下

在 AWS::ApiGateway::RestApi 属性中使用 BodyS3Loc​​ation 会返回错误 Unable to parse API definition because of a malformed integration for the same integration 我提到了 Swagger 文件,其中 AWS Extensions 存储在 S3 Bucket 中,用于使用 Cloudformation 创建 API

并为 AWS::ApiGateway::RestApi 属性修改了如下模板 Body: Fn::Transform: Name: AWS::Include Parameters: Location: Fn::Sub: "s3://${BucketName}/apiSwaggerSpec.yaml"

对于上面的堆栈,我拥有 cloudformation 操作的所有权限

下面的代码我已经添加为招摇扩展。 x-amazon-apigateway-auth: type: "aws_iam" x-amazon-apigateway-integration: type: "aws_proxy" httpMethod: "POST" passthroughBehavior: "when_no_match" uri: Fn::Sub: "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:${accountId}:function:testLambdaFunction/invocations" credentials: Fn::Sub: "arn:aws:iam::${accountId}:role/${myRole}" responses: default: statusCode: 200

由于 myrole 无权在资源上执行 cloudformation:CreateChangeSet:arn:aws:cloudformation:us-east-1:aws:transform/include,我收到了权限被拒绝错误消息

我是否需要为转换/包含添加特殊权限。aws 文档说它不需要特殊权限?

标签: amazon-web-servicesswaggeramazon-cloudformationaws-api-gatewayopenapi

解决方案


我遇到了同样的问题,这个问题是我在搜索时能找到的唯一有意义的结果。尽管 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"

推荐阅读