简体   繁体   English

使用批处理作业时“调用 ListObjectsV2 操作时发生错误 (AccessDenied):访问被拒绝”

[英]"An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied" when using batch jobs

  • I have a compute environment with 'ecsInstanceRole'.我有一个带有“ecsInstanceRole”的计算环境。 It contains the policies 'AmazonS3FullAccess' and 'AmazonEC2ContainerServiceforEC2Role'它包含策略“AmazonS3FullAccess”和“AmazonEC2ContainerServiceforEC2Role”
  • Since I am using the AmazonS3FullAccess policy, I assume the batch job has permission to list, copy, put etc. -The image I am using is a custom docker image that has a startup script which uses "aws s3 ls <S3_bucket_URL>"由于我使用的是 AmazonS3FullAccess 策略,因此我假设批处理作业有权列出、复制、放置等。-我使用的图像是自定义 docker 图像,它有一个使用“aws s3 ls <S3_bucket_URL>”的启动脚本
  • When I start this image on an EC2 instance, it runs fine and lists the contents of the bucket当我在 EC2 实例上启动此映像时,它运行良好并列出了存储桶的内容
  • when I do the same as a batch job, I get the access denied error seen above.当我执行与批处理作业相同的操作时,出现上面看到的访问被拒绝错误。

I dont understand how this is happening.我不明白这是怎么回事。

Things I have tried so far:到目前为止我尝试过的事情:

  • having the bucket policy as将存储桶策略设置为

. .

{
    "Version": "2012-10-17",
    "Id": "Policy1546414123454",
    "Statement": [
        {
            "Sid": "Stmt1546414471931",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::<Account Id>:root"
            },
            "Action": [
                "s3:ListBucket",
                "s3:ListBucketVersions"
            ],
            "Resource": [
                "arn:aws:s3:::"bucketname",
                "arn:aws:s3:::bucketname/*"
            ]
        }
    ]
}
  • Granted public access to the bucket授予对存储桶的公共访问权限

Quoting the reply from @JohnRotenstein because I cannot mark it as an answer.引用@JohnRotenstein 的回复,因为我无法将其标记为答案。

"If you are using IAM Roles, there is no need for a Bucket Policy. (Also, there is a small typo in that policy, before bucketname but I presume that was due to a Copy & Paste error.) It would appear that a role has not been assigned to your ECS task: IAM Roles for Tasks - Amazon Elastic Container Service " “如果您使用的是 IAM 角色,则不需要存储桶策略。(此外,该策略中有一个小错字,在存储桶名称之前,但我认为这是由于复制和粘贴错误造成的。)看起来角色尚未分配给您的 ECS 任务:任务的IAM 角色 - Amazon Elastic Container Service

Solution : I had toattach an S3 access policy to my current Job Role.解决方案:我必须将 S3 访问策略附加到我当前的工作角色。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS S3 Boto3 Python - 调用 DeleteObject 操作时发生错误 (AccessDenied):拒绝访问 - AWS S3 Boto3 Python - An error occurred (AccessDenied) when calling the DeleteObject operation: Access Denied 调用 PutObject 操作时发生错误 (AccessDenied):Access Denied 但在我的系统上有效 - An error occurred (AccessDenied) when calling the PutObject operation: Access Denied but works on my system 当 MLFlow 尝试访问存储在 S3 上的人工制品时,获取“(InvalidToken)调用 ListObjectsV2 操作时” - Getting "(InvalidToken) when calling the ListObjectsV2 operation" when MLFlow is trying to access the artefacts stored on S3 S3 存储桶的 ListObjectsV2 操作的访问被拒绝 - AccessDenied for ListObjectsV2 operation for S3 bucket ValueError:存储桶不存在,或禁止访问 '调用 CreateMultipartUpload 时发生错误(AccessDenied) - ValueError: the bucket does not exist, or is forbidden for access 'An error occurred (AccessDenied) when calling the CreateMultipartUpload 调用 DescribeTaskDefinition 操作时发生错误(ClientException) - An error occurred (ClientException) when calling the DescribeTaskDefinition operation 调用 DescribeLaunchTemplates 操作时发生错误(UnauthorizedOperation)? - An error occurred (UnauthorizedOperation) when calling the DescribeLaunchTemplates operation? 调用 PutSubscriptionFilter 操作时发生错误(InvalidParameterException) - An error occurred (InvalidParameterException) when calling the PutSubscriptionFilter operation 调用 GenerateServiceLastAccessedDetails 时拒绝访问 - AccessDenied when calling the GenerateServiceLastAccessedDetails 使用 django-storages 和 boto3 在 Django 中调用 CreateMultipartUpload 操作时出现 AccessDenied - AccessDenied when calling the CreateMultipartUpload operation in Django using django-storages and boto3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM