Initializing and Deploying an AWS SAM Application
Learn how to initialize an AWS SAM application with the SAM CLI and deploy it to AWS.
We'll cover the following...
Initializing a SAM application
With the SAM CLI installed, we can create a SAM application as follows:
sam init --name api-app
Here, we are invoking the SAM CLI with the command init
, which is used to
initialize a SAM application, and we are also using the --name
option to name the application "api-app"
. This will start the initialization routine, which will ask a number of questions on the command line as follows:
Which template source would you like to use?
1 - AWS Quick Start Templates
2 - Custom Template Location
Choice:
Here, we will choose the first option, which is to use “AWS Quick Start Templates”,
and respond by typing 1
.
The next question is, “Choose an AWS Quick Start application template.”
Choose an AWS Quick Start application template
1 - Hello World Example
2 - Data processing
3 - Hello World Example with Powertools for AWS Lambda
...
Here, we can again choose option one to use “Hello World Example” as our template.
The next question we are presented with is to choose the runtime and package type, as follows:
Use the most popular runtime and package type? (Python and zip) [Y/N]
Here, we will choose option N
, which is to This will actually show the other 21 different options available for the runtime, which were not shown here initially, meaning that the list of available languages with which to write AWS Lambdas is quite extensive.
Which runtime would you like to use?
1 - aot.dotnet7 (provided.al2)
2 - dotnet6
3 - go1.x
4 - go (provided.al2)
5 - graalvm.java11 (provided.al2)
6 - graalvm.java17 (provided.al2)
7 - java17
8 - java11
9 - java8.al2
10 - java8
11 - nodejs18.x
12 -
...