

To make API Gateway send binary files as a response to every request (without expecting Accept header), you need to specify at least one mime type as a wildcard */*. What now? There is a workaround for that.
#NPM INSTALL SERVERLESS SAVE DEV UPDATE#
Update your request with header ‘Accept’ and value ‘image/gif’. There is a one ‘small’ issue in AWS API Gateway. Still not working, an image is not visible, what is going on? No worries, let’s check it with some REST testing tool (ie Postman): Let’s add our image type: click on edit button, then on add binary media type in the input type image/gif and click save:Īfter this (and each other) change in API Gateway you need to redeploy it:

After login to console, choose ‘API Gateway’ from the “Services” menu under “Application Services”, and click on your API (make sure that you are in proper AWS region):įrom the left navigation pane choose Binary support:Īs you can see there is no type listed here. We can use the AWS console to solve the problem manually. See the serverless docs for more information LicenseĬopyright (c) 2018 Bastian Töpfer, contributors.Add support for binary files in API Gateway Since version 1.2.0 of this plugin you can use the following syntax to access the certificates Arn in other plugins $ Reference Certificate Arn via variableResolvers Please make sure to check out the complete sample project here. For some stages you may not want to use certificates (and custom domains associated with it). Region: eu-west-1 // optional - default is us-east-1 which is required for custom api gateway domains of Type Edge (default)Įnabled: true // optional - default is true. HostedZoneIds: 'XXXXXXXXX' //required if hostedZoneNames is not set HostedZoneNames: 'somedomain.io.' //required if hostedZoneIds is not set IdempotencyToken: 'abcsomedomainio' //optional Npm i serverless-domain-manager -save-devĬertificateName: '' //required Install the plugins: npm i serverless-certificate-creator -save-dev I found serverless-domain-manager very useful but i also wanted to be able to automatically create the certificate for the newly generated custom domain. If you combine this plugin with serverless-domain-manager you can automate the complete process of creating a custom domain with a certificate. To remove the certificate and delete the CNAME recordsets from route53, run: serverless remove-cert this is useful if you managed to delete your certificate but the dns validation records still exist if you want to give your certificate a name that is shown in the ACM Console you can add a Tag with the key "Name" optional - see SubjectAlternativeNames optional - default is us-east-1 which is required for custom api gateway domains of Type Edge (default) It sets the name of the file containing the cert info optional, only used when writeCertInfoToFile is set to true. if you set it to true you will get a new file (after executing serverless create-cert), that contains certificate info that you can use in your deploy pipeline, alternativly as an array required if hostedZoneIds is not set, alternativly as an array Open serverless.yml and add the following: plugins: Usage npm i serverless-certificate-creator -save-dev Make sure you have the following installed before starting:

# Or, update the serverless cli from a previous versionĬheck out their getting started guide for more information here. You can install it like this: # Install the serverless cli This package is made for the serverless framework. Use this in your CICD flow to automatically create a certificate, create the necessary route53 recordsets to validate the certificate with Dns-Validation and finally wait until the certificate has been validated. This serverless plugin creates certificates that you need for your custom domains in API Gateway.
