首页 > 解决方案 > CloudFormation 部署 ApiGateway 方法从 rootresource 继承 AWS_IAM

问题描述

我一直在使用 ApiGateway、Lambda 等资源构建更大的 CloudFormation 堆栈。

对于最新的 ApiGateway,我将 AWS::ApiGateway::Methods 直接放在 / (rootresourceid) 上,当从 CloudFormation 部署时,AWS::ApiGateway::Stage 上的授权者将变为 AWS_IAM,尽管我设置了自定义在方法上授权并使用 DependsOn 让资源等待。

   Post:
    DependsOn:
      - AuthorizerApi
    Type: AWS::ApiGateway::Method
    Properties:
      AuthorizationType: CUSTOM
      AuthorizerId: !Ref AuthorizerApi
      RestApiId: !Ref Api
      ResourceId: !GetAtt Api.RootResourceId
      HttpMethod: POST
      Integration:
        Type: AWS_PROXY
        IntegrationHttpMethod: POST
        Uri: !Join ['', ["arn:aws:apigateway:", !Ref "AWS::Region", ":lambda:path/2015-03-31/functions/", !GetAtt PostLambda.Outputs.FunctionGetAtt, ":${stageVariables.environment}/invocations"]]
      MethodResponses:
      - ResponseModels:
          application/json: Empty
        StatusCode: 200

有趣的是,这不是rootresource下资源的问题,所以看起来是继承问题。

其他任何经历过这种情况的人,如果要求不是根目录下的路径,解决方案是什么?

标签: amazon-cloudformationaws-api-gateway

解决方案


推荐阅读