Description:
BinaryMediaTypes is removed from APIGW settings when SAM template is updated and re-deployed
Steps to reproduce the issue:
Globals as follows:Globals:
Api:
BinaryMediaTypes:
- "*~1*"
Package and deploy. Observe Settings section of the new APIGW API. Binary Media Types will have */*
Make some changes to the SAM template. Re-package and re-deploy. Observe Settings section of the APIGW API. Binary Media Types config is empty/missing
Observed result:
Binary Media Types config is empty/missing after SAM template is updated and redeployed
Expected result:
Binary Media Types does not change after stack update.
Output of sam --version: SAM CLI, version 0.6.0
Optional Debug logs:
Add --debug flag to command you are running
Closing as this does not relate to this project. I responded on the issue that was made to AWS SAM CLI.
This needs to be reopened, it has not been fixed and it's part of the SAM templates
@mrjomp could you provide more details of what your error is and how you encountered it? Is it the exact same as the original post in this issue?
Ran into this issue today also. Exactly as described in original description by @abhilash1in.
I first set to '~1' in template.yaml. Then changed to 'image~1png' and packages/deployed. After that the BinaryMediaTypes have been removed. Changing them further does not have any effect.
Did further tests:
BinaryMediaTypes:
- image~1gif
- image~1png
Package/deploy got the expected result.
BinaryMediaTypes:
- image~1gif
- image~1png
- application~1vnd.openxmlformats-officedocument.spreadsheetml.sheet
Package/deploy resulted in only application/1vnd.openxmlformats-officedocument.spreadsheetml.sheet set in console.
BinaryMediaTypes:
- image~1gif
- image~1png
- application~1vnd.openxmlformats-officedocument.spreadsheetml.sheet
- image~1tiff
Package/deploy resulted in only image/tiff set in console
BinaryMediaTypes:
- image~1gif
- image~1png
- application~1vnd.openxmlformats-officedocument.spreadsheetml.sheet
- image~1tiff
- image~1jpeg
Package/deploy resulted in only image/jpeg set in console
Also encountering this error. We are currently working around it by manually updating in the console and deploying the api manually. Not ideal!
In our case we want BinaryMediaTypes: ['*/*'] but that fails. Changing the value to *~1* also does not persist.
Further clarification: creating a fresh stack will work with *~1* (but it appears updates it does not). I'll cobble a reduced case 馃敎 .
Is this resolve yet .. i am facing the same issue
I have created an example with steps to reliably reproduce the behavior. It looks like anything that results in updating the deployment of apigateway will remove the binary media types.
https://github.com/brianleroux/cloudformation-update-stack-removes-binary-media-types
This is an API Gateway/CloudFormation issue. I've contacted the teams internally.
SAM can resolve this by changing the way we set BinaryMediaTypes. Instead of setting it as a property of the CloudFormation Resource, we will need to set it via Swagger/OpenApi x-amazon-apigateway-binary-media-types
PR for fixing BinaryMediaTypes is in update #954
Released with v1.13.0
just ran into this, although I'm using strictly cloudformation templates with the sam transform. Should I not be seeing this problem? I made a change to BinaryMediaTypes and upon committing/updating my stack, and then inspecting cloudfront distro in the web console, the BinaryMediaTypes are empty
@burritoIand we encountered a problem where we were setting BinaryMediaTypes in the CloudFormation property, but should have been setting them in the Swagger/OpenApi document. This resulted in a behavior where on first deployment, the BinaryMediaTypes were present, but then would be removed when we updated the API.
If you are using Swagger/OpenApi, make sure to add the BinaryMediaTypes inside of your Swagger/OpenApi API definition.
Most helpful comment
I have created an example with steps to reliably reproduce the behavior. It looks like anything that results in updating the deployment of apigateway will remove the binary media types.
https://github.com/brianleroux/cloudformation-update-stack-removes-binary-media-types