Skip to content

Inconsistent behavior in ServerlessApp cloudformation deployment #708

@vasylk

Description

@vasylk

Hello,

we have been experiencing unexpected? behavior affecting API Gateway when deploying the serverless app.

Along with SAM resources the cloudformation template contains API Gateway proxy integration with S3 (see simplified Cloudformation sippet for reference).
The stack is deployed via CodePipeline + integration with CloudFormation

AWS::Region = eu-central-1

The unexpected behavior is:

  1. After some random deployment execution (happened already a few times) the API Gateway resources related to ApiGateway/S3 Integration (not SAM) get removed from API Gateway (S3FileImportRootResource, S3FileImportSubResource, S3FileImport) even though they do exist in CloudFormation stack and not affected by stack update.

The same happens with BinaryMediaTypes property of AWS::Serverless::Api

It gets restored when we manually comment out these resources in CloudFormation template and run two deployments in a row - without these resources in the template and with them. I assume it is not expected behavior.

  1. The changes in the resource S3FileImport (Integration section) do not get automatically deployed in API Gateway Stage specified in WebApi.StageName
    We have to manually run Deploy API action in API Gateway to get these changes available.

Regards
Vasyl

Template Snippet:

 AWSTemplateFormatVersion: "2010-09-09"
 Transform: 'AWS::Serverless-2016-10-31'
 .....
  ApiGwS3ProxyRole:
    Type: "AWS::IAM::Role"
    ....
  S3FileImportRootResource:
    Type: AWS::ApiGateway::Resource
    ....
  S3FileImportSubResource:
    Type: AWS::ApiGateway::Resource
    ....
  S3ReportFileImport:
    Type: AWS::ApiGateway::Method
    Properties:
      RestApiId: !Ref WebApi
      ResourceId: !Ref S3FileImportSubResource
      HttpMethod: POST
      Integration:
        Type: AWS
        IntegrationResponses:
  WebApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: api
      BinaryMediaTypes:
          - application~1octet-stream

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions