With the Serverless Framework v1.41.0 release, we’re adding AWS X-Ray Tracing support for API Gateway, which complements the AWS tracing story and makes it possible to trace incoming events from API Gateway all the way through your Lambda functions. Our new version also adds support for multiple API Gateway usage plan and key definitions as well as lots of enhancements for local function invocations via Docker. In addition to that, we also addressed a couple of bug fixes and enhancements. 1 bug fix and 7 enhancements were merged and are now available in our v1.41.0 release.
X-Ray support for AWS API Gateway
AWS API Gateway is one of the central services used in many serverless applications. Interactions with an API Gateway-driven serverless backend start with an event which is triggered via an HTTP request and then re-routed to the corresponding AWS Lambda function.
It would be great to monitor and trace requests through the service-stack to better understand how requests are processed and where they spend most of their lifetime.
In one of our previous Serverless Framework releases we introduced AWS X-Ray Tracing for AWS Lambda. With this post, we now complete the picture by adding AWS X-Ray Tracing support for API Gateway.
Enabling tracing for API Gateway is as easy as enabling the corresponding config on the
provider: tracing: apiGateway: true
X-Ray tracing works best when it’s used across multiple AWS services. If you’re using X-Ray Tracing for API Gateway you might want to enable it for your Lambda functions as well:
provider: tracing: apiGateway: true lambda: true
This way you can get more insights into your API Gateway → Lambda setup when using the X-Ray Tracing Service Map
IMPORTANT: Due to CloudFormation limitations it's not possible to enable AWS X-Ray Tracing on existing deployments which don’t use tracing right now.
Please remove the old API Gateway and re-deploy it with tracing enabled if you want to use AWS X-Ray Tracing for API Gateway.
Support for multiple usage plans
Sometimes it’s useful to limit access to your API Gateway when exposing it to the public. In previous versions of the Serverless Framework this could be easily done via API Keys and usage plans:
provider: name: aws apiKeys: - keyOne - keyTwo usagePlan: quota: limit: 5000 offset: 2 period: MONTH throttle: burstLimit: 200 rateLimit: 100
The initial implementation which supported one usage plan and multiple API Keys was usually enough for simple API Gateway setups.
However in production setups one usually needs more flexibility. It’s very common to have different types of usage plans for different user types, such as “free” plan users and “paid” plan users.
The Serverless Framework v1.41.0 adds support for multiple usage plans. Multiple API Keys can be assigned to each usage plan:
provider: name: aws apiKeys: - free: - freeKeyOne - freeKeyTwo - paid: - paidKeyOne - paidKeyTwo usagePlan: - free: quota: limit: 5000 offset: 2 period: MONTH throttle: burstLimit: 200 rateLimit: 100 - paid: quota: limit: 50000 offset: 1 period: MONTH throttle: burstLimit: 2000 rateLimit: 1000
Docker Invoke Local improvements
Serverless Framework recently added support for local function invocation via Docker, meaning that every AWS Lambda runtime can now be invoked locally in a Docker container.
Serverless Framework v1.41.0 adds support for: function environment variables; access to function dependencies; lambda layer download caching; and Docker argument passing.
- #5964 Add error message when provider does not exist +15/-0 Xenonym
- #5973 The code for removing comments is easy to read +0/-2 xichengliudui
- #5977 #5947: Ensure invoke local docker runs lambda with the dependencies +32/-22 endeepak
- #5997 Add additional Capability when Transform is detected +54/-0 pofallon
- #6010 Allow specifying a retention policy for lambda layers +63/-1 dschep
- #6011 Updating Node.js runtime version +1/-1 ffxsam
- #6013 Make it easier on the eyes of serverless newcomers +3/-3 guerrerocarlos
- #6018 Update quick-start.md +1/-1 allanchua101
- #6023 Update newsletter + enterprise link in readme +1/-1 pdaryani
- #5692 Add AWS x-ray support for API Gateway +368/-2 softprops
- #5954 #4750 Java invoke local support for handlers that implement RequestStreamHandler +138/-7 XaeroDegreaz
- #5970 Add support for multiple usage plans +875/-173 pmuens
- #5971 Added rust template for Cloudflare WASM +151/-0 jspies
- #5994 #5993: Ability to pass args for docker run command during invoke local docker +56/-4 endeepak
As always, we appreciate each and every one of you that use and contribute to the Framework and Serverless ecosystem!