将数据从一个AWS账户中的S3存储桶复制到另一个AWS账户中的S3存储桶

时间:2019-02-04 14:10:06

标签: amazon-web-services amazon-s3

我正在尝试将S3存储桶对象从一个AWS复制到另一个AWS账户。我遵循了此链接here,该链接可用于一个帐户A,但当我将其与另一个帐户B一起使用时却出现访问被拒绝的错误。这可能是什么原因?它是否与某些防火墙或安全性问题相关,甚至源帐户B存储桶也已公开。 这是应用于源存储区B的策略

{

  "Version": "2012-10-17",

  "Statement": [

    {

      "Sid": "DelegateS3Access",

      "Effect": "Allow",

      "Principal": {

        "AWS": "arn:aws:iam::12345678910:user/abc"

      },

      "Action": [

        "s3:ListBucket",

        "s3:GetObject"

      ],

      "Resource": [

        "arn:aws:s3:::sourceBucketB/*",

        "arn:aws:s3:::sourceBucketB"

      ]

    }

  ]

}

这是应用于目标帐户的政策

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::sourcebucket",
                "arn:aws:s3:::sourcebucket/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:PutObject",
                "s3:PutObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::destinationbucket",
                "arn:aws:s3:::destinationbucket/*"
            ]
        }
    ] }

[这是来自帐户B的存储桶的配置] enter image description here [1 \

我正在使用以下命令从存储区B复制到目标帐户(使用目标帐户配置文件)

aws s3 sync s3:// sourceBucket s3:// destinationBucket

这是错误

  

严重错误:调用时发生错误(AccessDenied)   ListObjectsV2操作:访问被拒绝

2 个答案:

答案 0 :(得分:0)

This documentation包含您需要的确切策略和必要步骤。

根据该文档,该策略应如下所示:

C.WriteLine("Hello, world!");

答案 1 :(得分:-1)

简单方法(全部授予):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "s3:*",
      "Effect": "Allow",
      "Resource": "*",
      "Principal": "*"
    }
  ]
}

这似乎也不必要,并且可能会使事情复杂化(在您的第二条政策中):

{
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::sourcebucket",
                "arn:aws:s3:::sourcebucket/*"
            ]
        },