Hello World
You can use the AWM SAM CLI to create, build, and deploy a simple Hello World application.
Create a new application
Create a new application in a new directory.
sam init
The SAM CLI command above will prompt you with the following options:
Which template source would you like to use?
1 - AWS Quick Start Templates
2 - Custom Template Location
Choose 1 and press Enter.
Choose an AWS Quick Start application template
1 - Hello World Example
2 - Multi-step workflow
3 - Serverless API
4 - Scheduled task
5 - Standalone function
6 - Data processing
7 - Infrastructure event management
8 - Serverless Connector Hello World Example
9 - Multi-step workflow with Connectors
10 - Lambda EFS example
11 - Machine Learning
Choose 1 and press Enter.
Use the most popular runtime and package type? (Python and zip) [y/N]: y
Would you like to enable X-Ray tracing on the function(s) in your application? [y/N]: N
Project name [sam-app]: hello-lambda
- Enter
y
to selectPython
andzip
as the most popular runtime and package type. - Enter
N
to disable X-Ray tracing. - Enter
hello-lambda
as the project name.
Build and test the application
Build the application.
cd hello-lambda
sam build
Deploy the application
Deploy the application.
sam deploy --guided
Test the application
Test the application using the invoke command.
sam local invoke HelloWorldFunction --event events/event.json