0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AmazonS3トリガーを使用してLambda 関数を呼び出す

Posted at

1. S3バケット作成

まずは、入れ物であるS3バケットを作成します
image.png
以前、ブロックパブリックアクセスを設定した際にS3にオブジェクトをアップできなかったので、いったんオフにする
image.png
S3作成完了

image.png

バケット作成とオブジェクトアップ

S3バケットが作成出来たので、オブジェクトをアップロードする
image.png

許可ポリシーの作成

image.png

  • Lambda が CloudWatch Logs にログを出力するための権限
  • 各アクションの役割:
    • PutLogEvents:ログを送信
    • CreateLogGroup:ロググループを作成(初回実行時など)
    • CreateLogStream:ログストリーム(時系列データの受け口)を作成
  • 全ての S3 バケットのオブジェクトに対して GetObject(読み取り)を許可

image.png

実行ロールの作成

image.png
実行ロールに対して先ほど作成した許可ポリシーを選択する
image.png
ロール名は任意のものを入力
image.png
image.png

Lambda作成

image.png
S3 にファイルがアップロードされたときに、そのファイルの Content-Type を取得して表示する AWS Lambda 関数

トリガーの追加

image.png

テスト

image.png

結果

image.png

ログの確認

新たにファイルをアップロードする
image.png
ログを確認
image.png
ロググループを確認
image.png

※参考
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/with-s3-example.html#with-s3-example-create-bucket

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?