An introduction to using AWS and AWS Lambda with the Serverless Framework.
The Serverless Framework helps you develop and deploy your AWS Lambda functions, along with the AWS infrastructure resources they require. It's a CLI that offers structure, automation and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of Functions and Events.
The Serverless Framework is different from other application frameworks because:
Here are the Framework's main concepts and how they pertain to AWS and Lambda...
A Function is an AWS Lambda function. It's an independent unit of deployment, like a microservice. It's merely code, deployed in the cloud, that is most often written to perform a single job such as:
You can perform multiple jobs in your code, but we don't recommend doing that without good reason. Separation of concerns is best and the Framework is designed to help you easily develop and deploy Functions, as well as manage lots of them.
Anything that triggers an AWS Lambda Function to execute is regarded by the Framework as an Event. Events are infrastructure events on AWS such as:
When you define an event for your AWS Lambda functions in the Serverless Framework, the Framework will automatically create any infrastructure necessary for that event (e.g., an API Gateway endpoint) and configure your AWS Lambda Functions to listen to it.
Resources are AWS infrastructure components which your Functions use such as:
The Serverless Framework not only deploys your Functions and the Events that trigger them, but it also deploys the AWS infrastructure components your Functions depend upon.
A Service is the Framework's unit of organization. You can think of it as a project file, though you can have multiple services for a single application. It's where you define your Functions, the Events that trigger them, and the Resources your Functions use, all in one file entitled
serverless.js). It looks like this:
# serverless.yml service: users functions: # Your "Functions" usersCreate: events: # The "Events" that trigger this function - http: post users/create usersDelete: events: - http: delete users/delete resources: # The "Resources" your "Functions" use. Raw AWS CloudFormation goes in here.
When you deploy with the Framework by running
serverless deploy, everything in
serverless.yml is deployed at once.
You can overwrite or extend the functionality of the Framework using Plugins. Every
serverless.yml can contain a
plugins: property, which features multiple plugins.
# serverless.yml plugins: - serverless-offline - serverless-secrets
Thanks for reading ❤
If you liked this post, share it with all of your programming buddies!
AWS KMS is a Key Management Service that let you create Cryptographic keys that you can use to encrypt and decrypt data and also other keys. You can read more about it here.
We explore Serverless with Java and Amazon Web Services (AWS). We'll create a simple serverless function using Amazon Web Services, Java, and Gradle. Learn how to simply integrate AWS deployment with a Gradle script. Learn how to use Okta to secure the serverless function with JSON Web Tokens, OAuth, and OpenID Connect.
Microservices vs Web Services, What is the difference between microservices and web services? Microservices vs. Web Services, Why Microservices? Why web services?
In this post, I’m going to show you how easy it is to build a basic Serverless Application using a few AWS Services (AWS Lambda)
Companies need to be thinking long-term before even starting a software development project. These needs are solved at the level of architecture: business owners want to assure agility, scalability, and performance.