Api Gateway Deployment not updated when AutoPublishAlias is changed

0

Hello, when I update my lambda and I have AutoPublishAlias activated. Api Gateway does not deploy to update the version of the target lambda. what am I doing wrong? my code: https://github.com/fjanuszewski/demo_aws_apigateway_lambda_dynamo

(i'm using swagger)

Globals:
  Function:
    Runtime: nodejs14.x
    AutoPublishAlias: live

Resources:
  CommonsLayer:
    Type: AWS::Serverless::LayerVersion
    Properties:
      LayerName:
        Fn::Sub: ${AWS::StackName}-CommonsLayer
      Description: "Commons Libs"
      ContentUri: ./layers/commons
      LicenseInfo: Available under the MIT-0 license.
      CompatibleRuntimes:
        - nodejs14.x
    Metadata:
      BuildMethod: nodejs14.x

  ServerlessRestApi:
    Type: AWS::Serverless::Api
    Properties:
      Name: 
        Fn::Sub: ${AWS::StackName}-ApiGateway
      StageName: 
        Ref: Environment
      Variables:
        Environment: 
          Ref: Environment
      DefinitionBody:
        Fn::Transform:
          Name: AWS::Include
          Parameters:
            Location: ./swagger.yaml
            
  GetItem:
    Type: AWS::Serverless::Function
    Properties:
      Handler: app.handler
      Timeout: 30
      MemorySize: 128
      CodeUri: ./functions/getItem
      FunctionName: 
        Fn::Sub: ${AWS::StackName}-GetItem      
      Layers:
        - Ref: CommonsLayer
      Environment:
        Variables:
          ENV: 
            Ref: Environment
          EXAMPLE_TABLE: 
            Ref: ExampleTable
      Policies:
        - AWSLambdaExecute
        - AWSXRayDaemonWriteAccess
        - Statement:
            - Effect: Allow
              Action:
                - "dynamodb:GetItem"
              Resource:
                Fn::GetAtt: ExampleTable.Arn
      Events:
        HttpEvent:
          Type: HttpApi 
          Properties:
            Path: /items/{idItem}
            Method: GET
            ApiId:
              Ref: ServerlessRestApi
asked 2 years ago429 views
1 Answer
0

What do you expect to happen? API Gateway should be pointing to the live alias. Every time you publish a new function version, the alias is moved to the new version so there is no need to change anything in API Gateway.

profile pictureAWS
EXPERT
Uri
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions