Amazon Web Services (AWS) - Initialize Serverless Application Model (SAM) app using the sam init command

by
Jeremy Canfield |
Updated: November 17 2023
| Amazon Web Services (AWS) articles
This assumes you have already installed the AWS Serverless Application Model (SAM) CLI. If not, check out my article Download and Install the AWS Serverless Application Model (SAM) CLI on Linux.
Let's create a directory.
mkdir /tmp/sam-hello-world
Move into the directory.
cd /tmp/sam-hello-world
Run the sam init command. In the prompt, let's make the following selections.
- Which template source would you like to use = 1 - AWS Quick Start Templates
- Choose an AWS Quick Start application template = 1 - Hello World Example
- 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
- Would you like to enable monitoring using CloudWatch Application Insights? [y/N] = N
- Project name [sam-app]: press enter to use sam-app
There should now be a directory named /tmp/sam-hello-wolrd/sam-app and inside the sam-app directory should be some Python files, YAML files and directories.
]$ ll sam-app/
total 20
drwxrwxr-x 2 ec2-user ec2-user 24 Nov 16 02:13 events
drwxrwxr-x 2 ec2-user ec2-user 63 Nov 16 02:13 hello_world
-rw-rw-r-- 1 ec2-user ec2-user 0 Nov 16 02:13 __init__.py
-rw-rw-r-- 1 ec2-user ec2-user 8329 Nov 16 02:13 README.md
-rw-rw-r-- 1 ec2-user ec2-user 679 Nov 16 02:13 samconfig.toml
-rw-rw-r-- 1 ec2-user ec2-user 1681 Nov 16 02:13 template.yaml
drwxrwxr-x 4 ec2-user ec2-user 80 Nov 16 02:13 tests
Did you find this article helpful?
If so, consider buying me a coffee over at