AWS SAM – невозможно создать стек со шлюзом API, используя переменную этапа для вызванной лямбда-версии.

Хорошо, предыдущий вопрос об использовании разных лямбда-версий на разных этапах здесь: AWS — лямбда-версии для разных этапов шлюза?

Теперь я пытаюсь собрать все это вместе с помощью AWS SAM cli, но все равно получаю ошибку:

шаблон.yaml

Соответствующие части моего шаблона

      
Resources:
  AppApi:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: HelloWorldApiGateway

  HelloWorldResource:
    Type: AWS::ApiGateway::Resource
    Properties:
      RestApiId: !Ref AppApi
      ParentId: !GetAtt AppApi.RootResourceId
      PathPart: hello-world

  ResourceMethodGet:
    Type: AWS::ApiGateway::Method
    Properties:
      AuthorizationType: NONE
      RestApiId: !Ref AppApi
      ResourceId: !Ref HelloWorldResource
      HttpMethod: GET
      Integration:
        Type: AWS
        IntegrationHttpMethod: GET
        Uri: !Join
          - ""
          - - "arn:aws:apigateway:"
            - ${AWS::Region}
            - "lambda:path/2015-03-31/functions/"
            - !GetAtt HelloWorldFunction.Arn
            - ":${lambda_alias}"
            - "/invocations"

  ProductionStage:
    Type: AWS::ApiGateway::Stage
    Properties:
      RestApiId: !Ref AppApi
      StageName: production
      DeploymentId: !Ref ProductionDeployment
      Variables:
        function_alias: production

  StagingStage:
    Type: AWS::ApiGateway::Stage
    Properties:
      RestApiId: !Ref AppApi
      StageName: staging
      DeploymentId: !Ref StagingDeployment
      Variables:
        function_alias: staging

  ProductionDeployment:
    Type: AWS::ApiGateway::Deployment
    Properties:
      RestApiId: !Ref AppApi

  StagingDeployment:
    Type: AWS::ApiGateway::Deployment
    Properties:
      RestApiId: !Ref AppApi

  HelloWorldFunction:
    Type: AWS::Serverless::Function
    # ...

  FunctionStagingAlias:
    Type: AWS::Lambda::Alias
    Properties:
      FunctionName: !Ref HelloWorldFunction
      Name: "staging"
      FunctionVersion: $LATEST

  FunctionProductionAlias:
    Type: AWS::Lambda::Alias
    Properties:
      FunctionName: !Ref HelloWorldFunction
      Name: "production"
      FunctionVersion: 2 # Just an example

Ошибка

sam build && sam sync --stack-name hello-world-app

      CloudFormation events from stack operations (refresh every 0.5 seconds)
---------------------------------------------------------------------------------------------------------------------------------------------
ResourceStatus                      ResourceType                        LogicalResourceId                   ResourceStatusReason              
---------------------------------------------------------------------------------------------------------------------------------------------

... non-error events ...

UPDATE_IN_PROGRESS                  AWS::ApiGateway::Method             ResourceMethodGet                   -                                 
UPDATE_FAILED                       AWS::ApiGateway::Method             ResourceMethodGet                   AWS ARN for integration must      
                                                                                                            contain path or action (Service:  
                                                                                                            AmazonApiGateway; Status Code:    
                                                                                                            400; Error Code:                  
                                                                                                            BadRequestException; Request ID:  
                                                                                                            7ea71b09-062b-41d3-89e1-e567c0cd3 
                                                                                                            85e; Proxy: null)                 
UPDATE_ROLLBACK_IN_PROGRESS         AWS::CloudFormation::Stack          hello-world-app                     The following resource(s) failed  
                                                                                                            to update: [ResourceMethodGet].  

... rollback ...

0 ответов