LoginSignup
0
0

More than 5 years have passed since last update.

API GatewayのBinaryMediaTypesを指定するとCloudFormationのStackの更新に失敗する

Posted at

docomo Developer support@akatsukahaです

API GatewayのリソースをCloudFormationで作成後に,BinaryMediaTypesを追加して更新すると何故か失敗するのでその記録を残します.

Templateを作成

template_v1.yaml
AWSTemplateFormatVersion: '2010-09-09'

Resources:
  TestApi:
    Type: 'AWS::ApiGateway::RestApi'
    Properties:
      Description: 'Test API'
      Name: 'Test API'
      FailOnWarnings: true
      EndpointConfiguration:
        Types:
          - EDGE

  TestApiResource:
    Type: 'AWS::ApiGateway::Resource'
    Properties:
      RestApiId: !Ref TestApi
      ParentId: !GetAtt TestApi.RootResourceId
      PathPart: 'test'

Stackを作成する.
無事APIが作成されている.

スクリーンショット 2018-07-27 13.33.03.png

スクリーンショット 2018-07-27 13.57.45.png

続いて,BinaryMediaTypesをTemplateに追記してStackを更新してみる.

template_v2.yaml
AWSTemplateFormatVersion: '2010-09-09'

Resources:
  TestApi:
    Type: 'AWS::ApiGateway::RestApi'
    Properties:
      Description: 'Test API'
      Name: 'Test API'
      FailOnWarnings: true
      BinaryMediaTypes: 
        - image/jpeg
      EndpointConfiguration:
        Types:
          - EDGE

  TestApiResource:
    Type: 'AWS::ApiGateway::Resource'
    Properties:
      RestApiId: !Ref TestApi
      ParentId: !GetAtt TestApi.RootResourceId
      PathPart: 'test'

何故か失敗する.

スクリーンショット 2018-07-27 14.56.01.png

ログ見ると/binaryMediaTypes/image/jpegのパスのリソースを変更しようとしている?

Invalid patch path /binaryMediaTypes/image/jpeg (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 

もちろん反映されていない

スクリーンショット 2018-07-27 14.56.46.png

Stackを削除して,BinaryMediaTypesを追加した下記のTemplateを利用してStackをゼロから作成してみる.

AWSTemplateFormatVersion: '2010-09-09'

Resources:
  TestApi:
    Type: 'AWS::ApiGateway::RestApi'
    Properties:
      Description: 'Test API'
      Name: 'Test API'
      FailOnWarnings: true
      BinaryMediaTypes: 
        - image/jpeg
      EndpointConfiguration:
        Types:
          - EDGE

  TestApiResource:
    Type: 'AWS::ApiGateway::Resource'
    Properties:
      RestApiId: !Ref TestApi
      ParentId: !GetAtt TestApi.RootResourceId
      PathPart: 'test'

サクッと作れた.

スクリーンショット 2018-07-27 15.01.29.png

スクリーンショット 2018-07-27 15.01.46.png

なぜかBinaryMediaTypesを指定すると更新ができない模様

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0