0% found this document useful (0 votes)
9 views

AWS Program 4

This document outlines the steps to create and execute a Lambda function on AWS. It includes instructions for signing in to the AWS Management Console, creating a function, writing code, testing it locally and after deployment, and optional clean-up. The example function greets a user based on the input name provided in a test event.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

AWS Program 4

This document outlines the steps to create and execute a Lambda function on AWS. It includes instructions for signing in to the AWS Management Console, creating a function, writing code, testing it locally and after deployment, and optional clean-up. The example function greets a user based on the input name provided in a test event.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Program 4: Writing and Executing Lambda Function.

Step 1: Sign in to the AWS Management Console


➢ Go to AWS Management Console.
➢ Sign in with your AWS account or create a new account.
Step 2: Navigate to AWS Lambda
➢ In the AWS Management Console, navigate to the "Services" dropdown and select
"Lambda" under "Compute."
Step 3: Create a Lambda Function
➢ Click on the "Create function" button.
➢ Choose "Author from scratch."
➢ Enter a name for the function (e.g., "GreetUserLambda").
➢ Choose "Python" as the runtime.
➢ Choose an existing role or create a new one with basic Lambda execution
permissions.
➢ Click on "Create function."
Step 4: Write Lambda Function Code
➢ Scroll down to the "Function code" section.
➢ Replace the default code with the following Python code:
def lambda_handler(event, context):
name = event['name'] if 'name' in event else 'Guest'
greeting = f'Hello, {name}!'
return {
'statusCode': 200,
'body': greeting
}
Step 5: Test the Lambda Function Locally
➢ Click on "Test" at the top of the Lambda console.
➢ Configure a new test event with JSON data:
{
"name": "John"
}
➢ Click on "Test" to execute the function with the test event.
➢ Verify that the output shows the expected greeting.
Step 6: Deploy the Lambda Function
➢ Click on "Deploy" to deploy the Lambda function.
Step 7: Test the Deployed Lambda Function
➢ On the Lambda function page, click on the "Test" button again.
➢ Use the same test event or create a new one.
➢ Click on "Test" to execute the function.
➢ Verify that the deployed function returns the expected greeting.
Step 8: Clean-Up (Optional)
➢ If you're done experimenting, click on "Delete function" to avoid incurring
additional charges.

You might also like