通过假定角色的AWS S3 CLI存储桶访问

时间:2019-06-06 18:33:54

标签: amazon-s3 aws-cli

我想将我不拥有的外部帐户中的S3存储桶中的某些数据批量复制到我的帐户中的存储桶中。

外部帐户的所有者通过我担任的角色授予了我访问权限。我可以列出外部存储桶内容,并通过AWS CLI将内容复制到云桌面的本地磁盘。

将数据直接从外部帐户移动到我使用源配置文件的AWS帐户失败。我试图在我的帐户中设置一个存储桶策略和一个角色来信任外部角色,到目前为止还算不上运气。

我的.aws / config:

[profile extern-role]
source_profile = my-account-profile
role_arn = arn:aws:iam::112233445566:role/ExternalAccountRole

我帐户中的桶政策:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::112233445566:role/ExternalAccountRole"
            },
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::my-test-bucket/*",
                "arn:aws:s3:::my-test-bucket"
            ]
        }
    ]
}

工作正常:

aws s3 ls --profile extern-role s3://extern-account-bucket/

工作正常:

aws s3 ls --profile my-account-profile s3://my-account-bucket/

失败:

aws s3 ls --profile extern-role s3://my-account-bucket/

An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied

(为简便起见,使用此处的AWS s3 ls示例,但是从extern-account-bucket到云桌面的cp成功,从extern-account-bucket到my-account-bucket的cp失败)

任何建议将不胜感激!

0 个答案:

没有答案