Getting started with Lambda - AWS Lambda

Getting started with Lambda

To get started with Lambda, use the Lambda console to create a function. In a few minutes, you can create a function, invoke it, and then view logs and metrics.


If you do not have an AWS account, complete the following steps to create one.

To sign up for an AWS account
  1. Open

  2. Follow the online instructions.

    Part of the sign-up procedure involves receiving a phone call and entering a verification code on the phone keypad.

    When you sign up for an AWS account, an AWS account root user is created. The root user has access to all AWS services and resources in the account. As a security best practice, assign administrative access to an administrative user, and use only the root user to perform tasks that require root user access.

AWS sends you a confirmation email after the sign-up process is complete. At any time, you can view your current account activity and manage your account by going to and choosing My Account.

After you sign up for an AWS account, create an administrative user so that you don't use the root user for everyday tasks.

Secure your AWS account root user
  1. Sign in to the AWS Management Console as the account owner by choosing Root user and entering your AWS account email address. On the next page, enter your password.

    For help signing in by using root user, see Signing in as the root user in the AWS Sign-In User Guide.

  2. Turn on multi-factor authentication (MFA) for your root user.

    For instructions, see Enable a virtual MFA device for your AWS account root user (console) in the IAM User Guide.

Create an administrative user
  • For your daily administrative tasks, grant administrative access to an administrative user in AWS IAM Identity Center (successor to AWS Single Sign-On).

    For instructions, see Getting started in the AWS IAM Identity Center (successor to AWS Single Sign-On) User Guide.

Sign in as the administrative user
  • To sign in with your IAM Identity Center user, use the sign-in URL that was sent to your email address when you created the IAM Identity Center user.

    For help signing in using an IAM Identity Center user, see Signing in to the AWS access portal in the AWS Sign-In User Guide.

Create a Lambda function with the console

In this getting started exercise, create a Lambda function using a blueprint. A blueprint provides sample code to do some minimal processing. Most blueprints process events from specific event sources, such as Amazon Simple Storage Service (Amazon S3), Amazon DynamoDB, or a custom application.

To create a Lambda function with the console
  1. Open the Functions page of the Lambda console.

  2. Choose Create function.

  3. Select Use a blueprint.

  4. In the Filter blueprints box, search hello-world-python and select the hello-world-python blueprint.

  5. Choose Configure.

  6. Under Basic information, do the following:

    1. Enter a Function name.

    2. For Execution role, choose Create a new role with basic Lambda permissions. Lambda creates an execution role that grants the function permission to upload logs to Amazon CloudWatch. The Lambda function assumes the execution role when you invoke your function, and uses the execution role to create credentials for the AWS SDK and to read data from event sources.

Invoke the function

To invoke the function from the console, create a test event.

  1. Choose the Test tab.

  2. For Test event action, choose Create new event.

  3. For Event name, enter a name for the test event.

  4. For Event sharing settings, choose Private.

  5. For Template, leave the default hello-world option.

  6. In the Event JSON, replace value1 with hello, world! Don't change key1 or the event structure. Example:

    { "key1": "hello, world!", "key2": "value2", "key3": "value3" }
  7. Choose Save, and then choose Test. Lambda invokes the function on your behalf. The function handler receives and then processes the sample event.

  8. Review the Execution result. Under Details, you should see the value that you entered in step 6: "hello, world!". The execution result also includes the following information:

    • The Summary section shows the key information from the REPORT line in the invocation log.

    • The Log output section shows the complete invocation log. Lambda writes all invocation logs to Amazon CloudWatch.

  9. Choose Test to invoke the function a few more times and gather additional metrics that you can view in the next step.

  10. Choose the Monitor tab. This page shows graphs of the metrics that Lambda sends to CloudWatch.


    It mights take 5 to 10 minutes for logs to show up after a function invocation.

    For more information on these graphs, see Monitoring functions on the Lambda console.

Clean up

If you are done working with the example function, delete it. You can also delete the log group that stores the function's logs, and the execution role that the console created.

To delete a Lambda function
  1. Open the Functions page of the Lambda console.

  2. Choose a function.

  3. Choose Actions, Delete.

  4. In the Delete function dialog box, enter delete, and then choose Delete.

To delete the log group
  1. Open the Log groups page of the CloudWatch console.

  2. Select the function's log group (/aws/lambda/my-function).

  3. Choose Actions, Delete log group(s).

  4. In the Delete log group(s) dialog box, choose Delete.

To delete the execution role
  1. Open the Roles page of the AWS Identity and Access Management (IAM) console.

  2. Select the function's execution role (for example, my-function-role-31exxmpl).

  3. Choose Delete.

  4. In the Delete role dialog box, enter the role name and then choose Delete.

You can automate the creation and cleanup of functions, log groups, and roles with AWS CloudFormation and the AWS Command Line Interface (AWS CLI). For fully functional sample applications, see Lambda sample applications.

Additional resources

After creating your first Lambda function, try a tutorial:

To learn more about serverless application development with Lambda, see the following:

Accessing Lambda

You can create, invoke, and manage Lambda functions using any of the following interfaces:

  • AWS Management Console – Provides a web interface for you to access your functions. For more information, see Lambda console.

  • AWS Command Line Interface (AWS CLI) – Provides commands for a broad set of AWS services, including Lambda, and is supported on Windows, macOS, and Linux. For more information, see Using Lambda with the AWS CLI.

  • AWS SDKs – Provide language-specific APIs and manage many of the connection details, such as signature calculation, request retry handling, and error handling. For more information, see AWS SDKs.

  • AWS CloudFormation – Enables you to create templates that define your Lambda applications. For more information, see AWS Lambda applications. AWS CloudFormation also supports the AWS Cloud Development Kit (AWS CDK).

  • AWS Serverless Application Model (AWS SAM) – Provides templates and a CLI to configure and manage AWS serverless applications. For more information, see Getting started with AWS SAM.

Authoring and deploying functions

The following table lists the languages that Lambda supports and the tools and options that you can use with them. The available tools and options depend on:

  • The language that you use to write your Lambda function code.

  • The libraries that you use in your code. The Lambda runtimes provide some of the libraries, and you must upload any additional libraries that you use.

Language Tools and options for authoring code






  • Lambda console

  • Your own authoring environment


  • Your own authoring environment


You deploy your function code to Lambda using a deployment package. Lambda supports two types of deployment packages: