Learn how easily you can harness serverless technology by building your first AWS Lambda function with this simple tutorial.
On the Progress Corticon team, we love serverless technologies. This blog is the start of a series on Serverless in general as well as on application design with Corticon rules and decision services in Serverless environments.
To kick things off, we will start with AWS Lambda functions. Let’s see how easy it is to create your first function.
If you don't have an account on AWS, you can get free access simply by creating one here. You will get 1 million Lambda function calls a month for free (See aws.amazon.com/free for details).
First, login to AWS console at this URL: https://aws.amazon.com/console/. Click on Lambda under Compute or simply search Lambda in the services search field.
Now click the button labeled "Create function." You will get to the screen below where you enter a function name (firstFunction) and select Node JS 12. Then click Create at the bottom right of the screen.
You will get to the following screen:
Scroll down to the source code and replace “Hello from Lambda” with “Hello from my first function.”
Click Save at to top right and then click Test. You will get to a screen to create a test event to be passed to your function. At this stage we are not using anything from the event so just enter an event name and click Create.
Now you will be back to the editor screen, click Test again. That will run your function with the test event you just created. You will see a successful execution and its result will be displayed in a new tab called “Execution Result,” under the source code.
You will see the result of the execution as well as the unique request ID and the log.
Now let's see how we pass data to the function:
Change the code as highlighted below and rerun the test:
Now you know how to pass data in and get results out.
Congratulations, you have run your first Lambda function at no cost in your free tier account. If you were to run this in a paid account it would cost $0.0000002083 (As of March 2020). To put this number in perspective: If you were to invoke that function a million times it would cost you 21 cents!!! And even better, you didn't have to set up any machines or instances. The function will auto-scale on demand automatically and, as importantly, when there is no traffic (no invocation) it won't cost you anything (this is often called pay-as-use or pay-as-go).
These are extremely important properties of serverless environments and some of the reasons why people choose them over more traditional technologies.
In the next blog we will see how we can achieve the same with Microsoft Azure platform. Stay tuned.
Subscribe to get all the news, info and tutorials you need to build better business apps and sites
You have the right to request deletion of your Personal Information at any time.
You can also ask us not to pass your Personal Information to third parties here: Do Not Sell My Info
Copyright © 2020 Progress Software Corporation and/or its subsidiaries or affiliates.All Rights Reserved.
Progress, Telerik, Ipswitch, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.