AWS Lambda is a leader in the serverless computing service industry, allowing you the convenience of running your code without the need for provisioning or managing servers.
If you need to regularly scale your product without focusing on the backend, AWS Lambda is probably one of your go-to products. It charges you only for the compute time you actually use and is able to process a few requests per day to thousands per second.
Basically, it takes over administration issues, can be run from almost any type of application or backend service, and only charges you when your code is running. Check out this short guide if you’d like to understand more about AWS Lambda. You can also watch this official AWS technical introduction on YouTube.
Lambda has been around for some time now, climbing in popularity. However, AWS just recently announced a couple of new AWS Lambda features to help broaden the number of users who choose this as their development platform.
These two features are environment variables and an updated Serverless Application Model. They also recently improved the ability to build serverless applications in AWS Mobile Hub and are adding an X-Ray function to assist in debugging.
First things first: It’s great to note that this added feature is included free of charge if you use the default service key provided by Lambda. AWS clarifies on its blog that the typical per-request KMS charges do apply if you use your own key.
The newly added ability to give environment variables to specific functions in Lambda is an important one. Of course, when developers are building code, they attempt to give the code the ability to be used in more than one environment.
To do this well, it must be able to accept configuration values at runtime. Otherwise, it can’t be easily adapted. This is because these configuration values are usually specific to the environment where the code is hosted. “For example,” explains Jeff Barr on AWS’s blog, “many projects have distinct configurations for their development, test, and production environment.”
Finally, it is now possible to associate environment variables with Lambda functions, providing users with the ability to update and revise configuration changes or apply API keys without the need to hard code them each time.
With this, you’re also able to be more efficient with your serverless application than before because there is no need to redeploy code to effect configuration changes. Having encrypted key/value paired with their AWS Key Management Service (KMS), you’re able to decrypt each as needed.
KMS is a feature of AWS that allows you to create and control encryption keys more simply to protect your data. It also utilizes Hardware Security Modules (HSMs) for keys security. This feature is integrated throughout many AWS services, as well as AWS CloudTrail, to help keep your data protected.
In AWS Lambda, you can create new versions of a Lambda function while setting the environment variables for them. Values are only able to be modified in the latest version of the function. Additionally, there is a strict 4KB size limit, but no per-function limit on how many environment variables are possible.
Serverless Application Model
This feature was created to make AWS Lambda apps easier to create, manage, and integrate. The new model of AWS SAM gives users the option of describing components of Lambda functions, Amazon API Gateway resources, and Amazon DynamoDB tables in a much more simplified way.
Amazon API Gateway is a service that assists developers in creating, publishing, maintaining, monitoring, and securing APIs with no minimum fees or startup costs. Amazon DynamoDB, on the other hand, is a NoSQL database service. Both of these services are able to be used at any scale.
It’s now possible on AWS Lambda to invoke a simplified syntax, natively supported by AWS CloudFormation, to build serverless applications with these different resources that are typically used together.
Barr writes that “Each function declaration specifies a handler, a runtime, and a URI to a ZIP file that contains the code for the function.” APIs are able to be implicitly declared through defining events, although you are also able to declare them explicitly with a Swagger file.
While you have a full range of options for declaring DynamoDB tables, it’s also possible now to declare them with a simplified syntax. For that, you’ll only need to give a “table name, a primary key (name and type), and the provisioned throughput.”
Essentially, AWS SAM is a manifest file for an application built on AWS Lambda that gives a description of how each section fits with the AWS architecture.
Serverless Application in AWS Mobile Hub
AWS Mobile Hub recently released a new Cloud Logic feature that assists mobile app developers in implementing a pattern “to create and test mobile cloud APIs backed by business logic functions you develop” and to “share your business logic across your iOS and Android apps.”
With this new feature, users are able to have more control and access to the cloud APIs in API Gateway to make it “easy to limit access to app users who have authenticated with any of the user sign-in options in Mobile Hub.” The new sign-in options also now include SAML-based app sign-in and fully managed email- and password-based app sign-in.
Mobile Hub, then, can now be used to help create functions with API Gateway endpoints used in mobile apps. This way, developers are able to start from the app side rather than from the server side, improving workflow and infrastructure.
AWS also gives information on how to build a “secure mobile back end in just a few minutes using a serverless stack.”
Another newly announced feature is AWS X-Ray, although this one is in preview right now. This function assists developers in analyzing and debugging their code in distributed apps.
With X-Ray, you are given an “end-to-end view of requests as they travel through your application” and the ability to trace calls and timing from AWS Lambda functions to other services.
When it is released for AWS Lambda, it will be able to analyze applications that are in production, as well as those in development. This useful function helps users “identify and troubleshoot the root cause of performance issues and errors.”