SAM v1.19.0 Release: HTTP APIs (Beta)
SAM V1.19.0 Release: Introducing HTTP APIs
HTTP APIs enable you to create RESTful APIs with lower latency and lower cost than REST APIs. In SAM, we aim to make creating and configuring these APIs easier and safer by providing the ability to construct an authenticated API backed by Lambda functions. We did this by creating a new resource type, AWS::Serverless::HttpApi
, and a new Function event type to go with it, HttpApi
.
To learn more about the differences and benefits of using a HTTP API, see the Amazon API Gateway documentation.
We followed the same pattern that we had for our current AWS::Serverless::Api
resource, with a few notable changes.
New Simple API
We are making it even easier to configure a Lambda-backed API. We are introducing a new simple case, where one Lambda function can map to all endpoints of an API and is simple and easy to use. This is done via several improvements:
Always Deploy API
There is now an option to automatically deploy any changes made to an API. SAM will no longer have to try to hash any changes to the API in an effort to deploy for any change; it should instead always work.
Default Stage
There is a new $default
stage that is used if no StageName
is given. This stage maps to the base of the API url.
Default Path
There is a new $default
path option that SAM uses if no Method
and Path
are given in an HttpApi
event. All unmapped paths and methods will be routed to this endpoint.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS SAM template with a simple API definition backed by a single Lambda function.
Resources:
ApiFunction:
Type: AWS::Serverless::Function
Properties:
Events:
ApiEvent: # uses new default path
Type: HttpApi
Handler: index.handler
CodeUri: ./src
Runtime: python3.7
Authorization
AWS::Serverless::HttpApi
at launch only supports JWT authorizers, and these can be added and used in much the same way that authorizers work on the AWS::Serverless::Api
resource.
For more information about authorization on AWS::Serverless::HttpApi
resources, see the SAM Documentation.
OpenApi Merging
SAM will now attempt to merge Lambda integrations with existing OpenApi documents. This allows advanced users to bring a pre-existing OpenApi document with all paths and methods specified and let SAM add the API Gateway integrations for Serverless functions via HttpApi
events on these functions. If the template author defines their own OpenApi, SAM requires the openapi
version to be set and at least an empty paths
dictionary to be created.