【发布时间】:2022-03-23 12:52:41
【问题描述】:
我有一个 AWS Batch Job,它是一个作为容器运行的 .NET CORE 应用程序,它从 SFTP 服务器下载一个 CSV 文件,解析它并将数据插入 AWS RDS。
当 CSV 损坏时,作业失败并且应该发送 SNS 通知,但我在 CloudWatch 日志中看到以下错误。
"Message": "User: arn:aws:sts::654001826221:assumed-role/fileimportworker-batch/5f77c736e4e64c2d82df278800ec4f25 is not authorized to perform: SNS:Publish on resource: arn:aws:sns:eu-west-1:accountIdHere:Test-SNS-Batch",
附加到批处理作业角色的我的 IAM 角色具有 SNS:允许发布、允许 S3,还提供对 Secret Manager 中 2 个密钥的读取访问权限。 S3 和 SecretManager 访问工作,该任务能够从 SFTP 下载文件并将其放到 S3 中,还可以从 Secret Manager 读取 RDS 密码。
【问题讨论】:
-
我尝试使用 AWS CLI 创建一个简单的 Docker 容器,我在我的机器上使用
docker run --env AWS_ACCESS_KEY_ID=id_here --env AWS_SECRET_ACCESS_KEY=secret_here --env REGION=eu-west-1 --env TOPIC_ARN=arn:aws:sns:eu-west-1:account_id_here:Test-SNS-Batch aws_cli运行它,我得到消息 ID 并将消息传递到我的收件箱。 -
当我使用所需的环境变量创建新的批处理作业定义并提交作业时,我得到
An error occurred (AuthorizationError) when calling the Publish operation: User: arn:aws:iam::account_id_here:user/docker_test is not authorized to perform: SNS:Publish on resource: arn:aws:sns:eu-west-1:account_id_here:Test-SNS-Batch。
标签: amazon-web-services amazon-iam amazon-sns aws-batch