Forrest logo
back to the sam tool

sam:tldr:221c4

sam: Initialize a serverless application.
$ sam init
try on your machine

The command "sam init" is used in the AWS Serverless Application Model (SAM) to initialize a new serverless application. SAM is an open-source framework provided by AWS to simplify the development, testing, and deployment of serverless applications using AWS services such as AWS Lambda, API Gateway, etc.

When the "sam init" command is executed, it prompts the user to input various options to set up the application:

  1. Choose a runtime: This option allows you to select the programming language or runtime for your serverless application. SAM supports several languages like Node.js, Python, Java, .NET, etc.

  2. Generate a new project or start from an existing one: Here, you can either create a new serverless application or start with an existing application template. Choosing an existing template provides a scaffolded starting point with pre-configured code, folders, and resources.

  3. Application template: If you choose an existing project, this option lets you select the template to use. SAM provides a range of templates for common use cases, including Hello World, API Gateway with Lambda, Step Functions, etc.

  4. Application name: Specify a name for your application. This becomes the name of the project folder.

  5. AWS Quick Start Templates: Decide whether to use AWS Quick Start Templates, which are example applications provided by AWS with best practices and recommended architectures.

After gathering these inputs, the "sam init" command generates the necessary files and folders to set up the serverless application based on the selected options. It creates the project structure, template file (yaml or json) describing the AWS resources, and initial code files based on the chosen runtime and template.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the sam tool