为什么EC2对S3的基于角色的访问被拒绝?

0

【以下的问题经过翻译处理】 我有一个EC2服务器“deploy”,其中包含一个“deploy-server-profile”,其中包含一个“deploy-server-role”。我的“deploy-server-role”有一个附加的管理策略“all-servers”,其中包含2个规则:

          - Effect: "Allow"
            Action:
              - "s3:GetObject"
            Resource:
              - "arn:aws:s3:::my-app-builds/infrastructure/master/cloud-init"
          - Effect: "Allow"
            Action:
              - "s3:ListBucket"
            Resource:
              - "arn:aws:s3:::my-app-builds"

在服务器上,我确保AWS CLI使用该角色运行:

ubuntu@ip-10-63-1-114:~$ aws sts get-caller-identity | jq .Arn
"arn:aws:sts::<my_aws_account>:assumed-role/deploy-server-role/<instance_id>"

并且我验证了我可以列出存储桶:

ubuntu@ip-10-63-1-114:~$ aws s3 ls s3://my-app-builds
                           PRE infrastructure/

但我无法下载“cloud-init”文件:

ubuntu@ip-10-63-1-114:~$ aws s3api get-object --bucket my-app-builds --key infrastructure/master/cloud-init /tmp/cloud-init.sh
An error occurred (AccessDenied) when calling the GetObject operation: Access Denied
1 回答
0

【以下的回答经过翻译处理】 我发现是因为这个对象是没有使用--acl bucket-owner-full-control的原因,因此我的帐户一开始就没有委派权限。

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则