Gateway API with SAM updated incorrectly

We use Cloud Formation to define a group of lambda functions:

AWSTemplateFormatVersion: '2010-09-09'
Transform:
- 'AWS::Serverless-2016-10-31'

Resources:
  MyLambda:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: com.handler::MyLambda
      Runtime: java8
      CodeUri: .
      Description: Some desc
      MemorySize: 512
      Timeout: 15
      Role: !Ref LambdaRole
      FunctionName: MyLambda
      Events:
        MyLambdaEvt:
          Type: Api
          Properties:
            RestApiId: !Ref MyApiDef
            Path: /lambda/my
            Method: get

  MyApiDef:
    Type: AWS::Serverless::Api
    Properties:
      DefinitionUri: s3://a-bucket/api-gateway.yml
      StageName: prod

Outputs:
  ApiUrl:
    Description: URL of your API endpoint
    Value: !Join
      - ''
      - - https://
        - !Ref MyApiDef
        - '.execute-api.'
        - !Ref 'AWS::Region'
        - '.amazonaws.com/prod'

CodePipeline creates a set of changes and executes it.

Thus, all Lambda functions are correctly updated, but the endpoint of the API gateway is not updated correctly, and we need to manually import and deploy YML to s3://a-bucket/api-gateway.yml.

+4
source share
2 answers

Why the API is not updated (educated guess)

, CloudFormation . , ( MyApiDef) , - .yaml S3, CloudFormation , .

API CF, S3, CF () API .

S3, , , .

CloudFormation, - API. :

  • MyApiDef . (MyApiDefv2 MyApiDefv3 ..)
  • DefinitionUri . ( S3).

, S3 , .

, , CloudFormation, . , Variables .

0

Source: https://habr.com/ru/post/1691052/


All Articles