Почему CloudFormation API Gateway не может указать «REST API не содержит никаких методов» даже с DependsOn? - PullRequest
0 голосов
/ 25 февраля 2020

У меня есть шаблон CloudFormation, который я пытаюсь развернуть. Этот шаблон очень похож на другой шаблон, который у меня есть, но он работает без проблем, однако при развертывании этого шаблона он продолжает не указывать:

APIGatewayDeployment5332c373d4 CREATE_FAILED The REST API doesn't contain any methods (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 02c0352f-b23b-44d5-a0af-2f3f3ecd7273)

У меня ранее была эта проблема на другом шаблоне, и я добавил свойство DependsOn в развертывании, которое устранило проблему, однако даже с этим свойством этот шаблон не работает.

См. Урезанную версию моего шаблона ниже:

AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Globals:
  Function:
    Environment:
      Variables:
        FOO: bah
  Api:
    EndpointConfiguration: REGIONAL
Resources:
  APIGateway:
    Type: AWS::Serverless::Api
    Properties:
      Name: Some API
      StageName: !Sub ${EnvironmentTagName}
  ApiFooResource:
    Type: AWS::ApiGateway::Resource
    Properties:
      ParentId: !GetAtt APIGateway.RootResourceId
      PathPart: foo
      RestApiId: !Ref APIGateway
  ApiFooNotificationResource:
    Type: AWS::ApiGateway::Resource
    Properties:
      ParentId: !Ref ApiFooResource
      PathPart: notification
      RestApiId: !Ref APIGateway
  ApiFooNotificationMethod:
    Type: AWS::ApiGateway::Method
    Properties:
      HttpMethod: POST
      AuthorizationType: NONE
      ResourceId: !Ref ApiFooNotificationResource
      RestApiId: !Ref APIGateway
      MethodResponses:
        - StatusCode: '200'
      Integration:
        Credentials: !GetAtt SQSRole.Arn
        IntegrationHttpMethod: POST
        IntegrationResponses:
          - StatusCode: 200
        Type: AWS
        Uri: !Sub arn:aws:apigateway:${AWS::Region}:sqs:action/SendMessage
        RequestParameters:
          integration.request.querystring.QueueUrl: !Sub '''${FooNotificationQueue}'''
          integration.request.querystring.MessageBody: method.request.body
  ApiTestResource:
    Type: AWS::ApiGateway::Resource
    Properties:
      ParentId: !GetAtt APIGateway.RootResourceId
      PathPart: test
      RestApiId: !Ref APIGateway
  ApiTestMethod:
    Type: AWS::ApiGateway::Method
    Properties:
      HttpMethod: POST
      AuthorizationType: NONE
      ResourceId: !Ref ApiTestResource
      RestApiId: !Ref APIGateway
      MethodResponses:
        - StatusCode: '200'
      Integration:
        Credentials: !GetAtt SQSRole.Arn
        IntegrationHttpMethod: POST
        IntegrationResponses:
          - StatusCode: 200
        Type: AWS
        Uri: !Sub arn:aws:apigateway:${AWS::Region}:sqs:action/SendMessage
        RequestParameters:
          integration.request.querystring.QueueUrl: !Sub '''${TestQueue}'''
          integration.request.querystring.MessageBody: method.request.body
  ApiDeployment:
    Type: AWS::ApiGateway::Deployment
    DependsOn: ApiTestMethod
    Properties:
      RestApiId: !Ref APIGateway
      Description: !Sub Api Deployment for ${EnvironmentTagName}
      StageName: !Sub ${EnvironmentTagName}

...**Removed the rest for brevity**...

Parameters:
  StackTagName:
    Type: String
    Description: Stack Name (injected by Stackery at deployment time)
  EnvironmentTagName:
    Type: String
    Description: Environment Name (injected by Stackery at deployment time)
...