LoginSignup
1
1

AWS SAMの基本的な使い方

Posted at

AWS SAMの基本的な使い方

AWSのServerless Application Model(SAM)は、サーバーレスアプリケーションの開発とデプロイを簡単にするフレームワークです。
この記事では、SAMを使用してサーバーレスアプリケーションを開発、テスト、デプロイする基本的なコマンドを紹介します。

はじめに

AWS SAMは、AWSのサービスを利用してサーバーレスアプリケーションを構築するためのツールです。
SAMを使用することで、Lambda関数、API Gateway、DynamoDBなどのAWSリソースを簡単に定義し、デプロイできます。

アプリケーションの開発

アプリケーション初期化

$ sam init

アプリケーション構築

$ sam build

アプリケーションをデプロイ

$ sam deploy --guided

アプリケーション実行

$ sam list endpoints --output json

Lambda関数とやり取りする

$ sam remote invoke HelloWorldFunction --stack-name sam-app

アプリケーションを変更して AWS クラウド に同期する

$ sam sync --watch

アプリケーションをローカルでテストする

$ sam local invoke
$ sam local start-api
$ curl http://127.0.0.1:3000/hello

AWS クラウドからアプリケーションを削除する

$ sam delete

SAM template

SAMには多くのスタートアップテンプレートがあり、それぞれのニーズに合わせて選ぶことができます。
例えば、「Hello World Example」や「Data processing」、「Lambda EFS example」などがあります。

Choose an AWS Quick Start application template
	1 - Hello World Example
	2 - Data processing
	3 - Hello World Example with Powertools for AWS Lambda
	4 - Multi-step workflow
	5 - Scheduled task
	6 - Standalone function
	7 - Serverless API
	8 - Infrastructure event management
	9 - Lambda Response Streaming
	10 - Serverless Connector Hello World Example
	11 - Multi-step workflow with Connectors
	12 - Full Stack
	13 - Lambda EFS example
	14 - DynamoDB Example
	15 - Machine Learning

まとめ

AWS SAMは、サーバーレスアプリケーションの開発を容易にする強力なツールです。
この記事で紹介した基本的なコマンドを使って、AWS上でサーバーレスアプリケーションを構築、テスト、デプロイすることができます。

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1