Setting up an AWS Lambda
This page gives the basic steps for setting up a lambda in AWS. For
additional information, and for actually completing the unicorn lab, see
this page.
The steps:
- Go to the Lambda site from your console; click on the orange Create function button.
- Enter the function name and select Java 21 for the runtime.
- Open the arrow “Change default execution role”, select “use an existing role”, and set it to LabRole.
- Click the orange Create Function button.
- Upload the jar file into the code source box.
- Click Edit in the Runtime settings box and set the Handler to the handleRequest path. This will be something like “com.xyz.handler_class::handlerMethod”.
- Click on the Configuration tab and select Concurrency and recursion detection.
- Click Edit in the Concurrency box, select Reserve concurrency, and set the limit to 2.
- Click the orange Save button.
If relevant, create an API Gateway:
- Visit the API Gateway from the console AND click on the orange Create API button.
- Click Build in the HTTP API box.
- Name the API and click Add integration.
- Select Lambda, chose the Lambda function by entering bits of its name and then selecting the right one.
- Ensure Version is 2.0, click Next.
- In the Configure Routes box, set the resource path to the appropriate name and click Next.
- Keep the Stage name “$default” and click Next followed by Create.
If you have an API gateway, you can test by doing the following:
- Return to the home page for your lambda.
- Click on the Configuration tab, then click on Triggers.
- Copy the API endpoint to PostMan.
- Set Body to raw, enter the JSON values, and click Send.