无法从基于 Docker 的 Lambda 创建 SQS 队列

0

【以下的问题经过翻译处理】 大家好,

我正在使用Python编写lambda函数,通过EventBridge触发特定事件时创建SQS队列。然后将函数打包为Docker镜像。当我尝试使用create_queue客户端方法创建队列时,

import boto3

sqs = boto3.client("sqs")

// sqs = boto3.client("sqs", endpoint_url="https://sqs.us-east-1.amazonaws.com")

sqs.create_queue(QueueName="my-test-queue")

我会收到以下任一错误:

An error occurred (AccessDenied) when calling the CreateQueue operation: Access to the resource https://sqs.us-east-1.amazonaws.com/ is denied.

或者

An error occurred (AccessDenied) when calling the CreateQueue operation: Access to the resource https://sqs.amazonaws.com/ is denied.

即使Lambda函数已经附加了正确的sqs:CreateQueue策略。

{
    "Statement": [
        {
            "Action": [
                "sqs:CreateQueue"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow"
        }
    ]
}

该Lambda函数未附加到任何VPC

我尝试使用基于ZIP和控制台创建的函数,但不会出现错误。

有谁有任何想法,为什么我在将函数打包为Docker镜像时会收到该错误?

非常感谢!

profile picture
EXPERTE
gefragt vor 5 Monaten18 Aufrufe
1 Antwort
0

【以下的回答经过翻译处理】 您的Lambda函数上的IAM策略权限可能不正确。有几个尝试方法:

  1. 临时授予sqs:*权限而不仅仅是CreateQueue,然后测试一下是否有效?
  2. 您可以查看CloudTrail以查看哪些API调用被拒绝了。
profile picture
EXPERTE
beantwortet vor 5 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen