Serverless Architecture

This website and domain name are for sale.

Tips, Tricks, And Gotchas of Amazon API Gateway

  • Mapping templates, accessible in the Request Integration and Response Integration screens, may be used to transform request or response data, including adding request metadata from Amazon to request data from the user. One particularly compelling use case is selecting different config parameters based on the value of the stage parameter.
  • Be aware that input mapping templates match on content type and thus depend on a properly-set Content-Type request header. Also be aware that mapping templates can turn nulls into blank strings depending on how they’re put together, so make sure your request handling code is prepared for that.
  • Cross-origin resource sharing can be enabled if you’d like to use your API from the browser without setting up a custom domain for it. It involves creating an OPTIONS endpoint alongside your POST endpoint, and installing some access control headers.
  • Request and response models allow the validation of input and output against JSON Schemas. This provides the opportunity for rudimentary input checking outside the Lambda, for example.
  • API Gateway methods can be connected to not only a specific lambda, but a specific version of a Lambda. This is a convenient way to pin an API Gateway stage to a precise version of a Lambda, for instance ensuring that the prod stage always points to the same code, regardless of further changes to the Lambda. To use a specific version of a Lambda, paste that version’s ARN into the API Gateway Create Method screen and deploy or redeploy the stages which should use it.
  • The JAWS Framework provides a convenient way to structure and maintain serverless APIs written with Lambda and API Gateway. It’s still a young project but it’s gaining momentum quickly, and the improved source code management and scriptability make it an increasingly good choice for managing your serverless API. And for Python, check out the emerging PAWS Framework, heavily inspired by JAWS.


Leave a Reply

Serverless Architecture © 2020 Frontier Theme