CLOVER🍀

That was when it all began.

AWS SAMのテンプレートになにがあるか確認する

これは、なにをしたくて書いたもの?

AWS SAMを使う時に、テンプレートになにがあったのか確認することがあるのですが、そもそもリポジトリーがどこでcurlなどで見る時に
どうしたらいいかをいつも過去エントリーから探していたのでメモしておくことにしました。

AWS SAMのテンプレートリポジトリー

こちらです。

GitHub - aws/aws-sam-cli-app-templates

各言語、パターンごとのテンプレートはリポジトリーの中身を見るしかありませんが、外観はこちらを見てもよいでしょう。

https://github.com/aws/aws-sam-cli-app-templates/blob/master/manifest-v2.json

たとえばPython 3.12向け。

https://github.com/aws/aws-sam-cli-app-templates/tree/master/python3.12

Amazon EventBridgeを使ったテンプレート。

https://github.com/aws/aws-sam-cli-app-templates/tree/master/python3.12/event-bridge

curlで見てみる

manifest-v2.jsoncurlで見てみます。

現時点での、言語とランタイムの組み合わせの一覧。

$ curl -s https://raw.githubusercontent.com/aws/aws-sam-cli-app-templates/master/manifest-v2.json | jq 'keys'
[
  "amazon/dotnet6-base",
  "amazon/dotnet8-base",
  "amazon/go-provided.al2-base",
  "amazon/go-provided.al2023-base",
  "amazon/java11-base",
  "amazon/java17-base",
  "amazon/java21-base",
  "amazon/java8.al2-base",
  "amazon/nodejs16.x-base",
  "amazon/nodejs18.x-base",
  "amazon/nodejs20.x-base",
  "amazon/nodejs22.x-base",
  "amazon/python3.10-base",
  "amazon/python3.11-base",
  "amazon/python3.12-base",
  "amazon/python3.13-base",
  "amazon/python3.8-base",
  "amazon/python3.9-base",
  "amazon/ruby3.2-base",
  "amazon/ruby3.3-base",
  "dotnet6",
  "dotnet8",
  "go (provided.al2)",
  "go (provided.al2023)",
  "graalvm.java11 (provided.al2)",
  "graalvm.java17 (provided.al2)",
  "java11",
  "java17",
  "java21",
  "java8.al2",
  "nodejs16.x",
  "nodejs18.x",
  "nodejs20.x",
  "nodejs22.x",
  "python3.10",
  "python3.11",
  "python3.12",
  "python3.13",
  "python3.8",
  "python3.9",
  "ruby3.2",
  "ruby3.3",
  "rust (provided.al2)",
  "rust (provided.al2023)"
]

特定の言語内のテンプレート一覧。

$ curl -s https://raw.githubusercontent.com/aws/aws-sam-cli-app-templates/master/manifest-v2.json | jq '."python3.12"'
[
  {
    "directory": "python3.12/hello",
    "displayName": "Hello World Example",
    "dependencyManager": "pip",
    "appTemplate": "hello-world",
    "packageType": "Zip",
    "useCaseName": "Hello World Example"
  },
  {
    "directory": "python3.12/hello-pt",
    "displayName": "Hello World Example with Powertools for AWS Lambda",
    "dependencyManager": "pip",
    "appTemplate": "hello-world-powertools-python",
    "packageType": "Zip",
    "useCaseName": "Hello World Example with Powertools for AWS Lambda"
  },
  {
    "directory": "python3.12/event-bridge",
    "displayName": "EventBridge Hello World",
    "dependencyManager": "pip",
    "appTemplate": "eventBridge-hello-world",
    "packageType": "Zip",
    "useCaseName": "Infrastructure event management"
  },
  {
    "directory": "python3.12/event-bridge-schema",
    "displayName": "EventBridge App from scratch (100+ Event Schemas)",
    "dependencyManager": "pip",
    "appTemplate": "eventBridge-schema-app",
    "isDynamicTemplate": "True",
    "packageType": "Zip",
    "useCaseName": "Infrastructure event management"
  },
  {
    "directory": "python3.12/step-func",
    "displayName": "Step Functions Sample App (Stock Trader)",
    "dependencyManager": "pip",
    "appTemplate": "step-functions-sample-app",
    "packageType": "Zip",
    "useCaseName": "Multi-step workflow"
  },
  {
    "directory": "python3.12/efs",
    "displayName": "Elastic File System Sample App",
    "dependencyManager": "pip",
    "appTemplate": "efs-sample-app",
    "packageType": "Zip",
    "useCaseName": "Lambda EFS example"
  },
  {
    "directory": "python3.12/web-conn",
    "displayName": "Quick Start: Web Backend With Connectors",
    "dependencyManager": "pip",
    "appTemplate": "hello-world-connector",
    "packageType": "Zip",
    "useCaseName": "Serverless Connector Hello World Example"
  },
  {
    "directory": "python3.12/step-func-conn",
    "displayName": "Step Functions Sample App (Stock Trader) With Connectors",
    "dependencyManager": "pip",
    "appTemplate": "step-functions-with-connectors",
    "packageType": "Zip",
    "useCaseName": "Multi-step workflow with Connectors"
  }
]

ちなみに、sam initで指定するテンプレートの名前はappTemplateのことです(オプションは--app-template)。

テンプレート内の特定のフィールドのみ抽出する。

$ curl -s https://raw.githubusercontent.com/aws/aws-sam-cli-app-templates/master/manifest-v2.json | jq '."python3.12"[] | {displayName, appTemplate, useCaseName}'
{
  "displayName": "Hello World Example",
  "appTemplate": "hello-world",
  "useCaseName": "Hello World Example"
}
{
  "displayName": "Hello World Example with Powertools for AWS Lambda",
  "appTemplate": "hello-world-powertools-python",
  "useCaseName": "Hello World Example with Powertools for AWS Lambda"
}
{
  "displayName": "EventBridge Hello World",
  "appTemplate": "eventBridge-hello-world",
  "useCaseName": "Infrastructure event management"
}
{
  "displayName": "EventBridge App from scratch (100+ Event Schemas)",
  "appTemplate": "eventBridge-schema-app",
  "useCaseName": "Infrastructure event management"
}
{
  "displayName": "Step Functions Sample App (Stock Trader)",
  "appTemplate": "step-functions-sample-app",
  "useCaseName": "Multi-step workflow"
}
{
  "displayName": "Elastic File System Sample App",
  "appTemplate": "efs-sample-app",
  "useCaseName": "Lambda EFS example"
}
{
  "displayName": "Quick Start: Web Backend With Connectors",
  "appTemplate": "hello-world-connector",
  "useCaseName": "Serverless Connector Hello World Example"
}
{
  "displayName": "Step Functions Sample App (Stock Trader) With Connectors",
  "appTemplate": "step-functions-with-connectors",
  "useCaseName": "Multi-step workflow with Connectors"
}

Node.js向けのテンプレートでTypeScriptのものを抽出する。

$ curl -s https://raw.githubusercontent.com/aws/aws-sam-cli-app-templates/master/manifest-v2.json | jq '."nodejs22.x"[] | select(.appTemplate | test("typescript"))'
{
  "directory": "nodejs22.x/hello-ts",
  "displayName": "Hello World Example TypeScript",
  "dependencyManager": "npm",
  "appTemplate": "hello-world-typescript",
  "packageType": "Zip",
  "useCaseName": "Hello World Example"
}
{
  "directory": "nodejs22.x/hello-ts-pt",
  "displayName": "Hello World Example TypeScript With Powertools for AWS Lambda",
  "dependencyManager": "npm",
  "appTemplate": "hello-world-powertools-typescript",
  "packageType": "Zip",
  "useCaseName": "Hello World Example with Powertools for AWS Lambda"
}

こんなところでしょうか。