简体   繁体   English

跨账户访问特定 AWS 账户中的 S3 存储桶的 IAM 角色策略

[英]IAM Role policy for cross account access to S3 bucket in a specific AWS account

Allow access from IAM Role in AccountA to given S3 buckets only if they are present in AWS AccountB (using Account Number).仅当 AWS AccountB中存在给定的 S3 存储桶时才允许从AccountA中的 IAM 角色访问(使用帐号)。

Here is my Role policy in AccountA which currently has following permission.这是我在AccountA中的角色策略,目前具有以下权限。 How can I update it to only access S3 bucket in AccountB .如何将其更新为仅访问AccountB中的 S3 存储桶。

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Action": [
                "s3:Get*",
                "s3:List*",
                "s3:Put*"
            ],
            "Resource": [
                "arn:aws:s3:::kul-my-bucket/my-dir/*"
            ]
        },
        {
            "Sid": "ListBucket",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::kul-my-bucket"
            ]
        }
    ]
}

Wondering if it is possible or should I try it differently?想知道是否有可能或者我应该尝试不同的方法吗?

Is anything similar to this possible for my case by providing the condition in the policy:通过在政策中提供条件,我的情况是否可能与此类似:

"Condition": {
                "StringLike": {
                    "aws:accountId": [
                        "111111111111"
                    ]
                }
            }

I need this because on the S3 bucket in AccountB it allows root access to AccountA .我需要这个,因为在AccountB的 S3 存储桶上,它允许root访问AccountA Hence I want to put restriction on Role policy in AccountA .因此,我想限制AccountA中的角色策略。

I do not think it is possible to grant/deny access to an Amazon S3 bucket based on an AWS Account number.我认为不可能根据 AWS 帐号授予/拒绝对 Amazon S3 存储桶的访问权限。 This is because Amazon S3 ARNs exclude the Account ID and instead use the unique bucket name.这是因为 Amazon S3 ARN 不包括账户 ID,而是使用唯一的存储桶名称。

You would need to grant Allow access specifically to each bucket by name.您需要按名称专门授予允许访问每个存储桶的权限。

I have seen this situation before where the requirement was to grant S3 permission to access buckets only in other accounts , but not the account owning the IAM User themselves.我之前见过这种情况,要求授予 S3 权限以仅访问其他账户中的存储桶,而不是拥有 IAM 用户自己的账户。 We could not determine a way to do this without also granting permission to access the "same account" S3 buckets.如果不授予访问“相同帐户”S3 存储桶的权限,我们无法确定执行此操作的方法。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM