sam init

Let’s use the CLI to create our new serverless application.

What we will be creating is an API Gateway and a Lambda function that will return a response.

Architecture

  1. Type sam init.
  2. Type 1 for 1 - AWS Quick Start Templates.
  3. Type 1 for 1 - Zip (artifact is a zip uploaded to S3).
  4. Type 1 for 1 - nodejs14.x.
  5. Type api for Project name. It will now download the Quick Start templates from GitHub.
  6. Type 1 for 1 - Hello World Example.

Let’s look at the directory structure on the left hand side file navigation pane.

  • api/ (root folder for the project)
    • events/ (folder to store events that can trigger the app)
    • hello-world/ *(stores the lambda function)
      • tests/ (folder to store the tests)
      • app.js (file that handler function)
    • template.yaml (SAM template file)

SAM Folder