Help us understand the problem. What is going on with this article?

#AWS Lambda の実行ロールを作成する ( SQSの実行権限を与える例 )

実行ロールとは

AWS Lambda 「が」AWSの他のサービス「を」使うときの許可、ポリシーみたいだ。

https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/lambda-intro-execution-role.html

image

ロールの作成

エンティティとして「AWSサービス」を、サービスとして「Lambda」を選んで次のステップに進む。

https://console.aws.amazon.com/iam/home?#/roles$new?step=type

image

今回必要な権限

SQSとの連携をしたいので、次の3項目を許可したい。

sqs:ReceiveMessage
sqs:DeleteMessage
sqs:GetQueueAttributes

https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/with-sqs.html

ポリシーのフィルタを使って、SQSというキーワードで検索する

image

ポリシーの中身を見る

(操作しづらい、なにこれ…!)

image

AWSLambdaSQSQueueExecutionRole 項目を開いて JSON 表示を選ぶと、必要な Action が入っていそうなことがわかる。

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "sqs:ReceiveMessage",
                "sqs:DeleteMessage",
                "sqs:GetQueueAttributes",
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "*"
        }
    ]
}

ポリシーを選んで次のステップに進む

タグの選択は飛ばす

てきとうな名前をつけてロールを作成する

image

作成完了

image

Lamdaの設定

これでlambda関数の「実行ロール」から、新しいロールが選べるようになった。

image

これで動くかな?

よし、試そう。

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/2496

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away