简体   繁体   English

无法使用 SSE 在 S3 存储桶上设置跨区域复制

[英]Unable to set Cross Region Replication on S3 bucket with SSE

I am not able to setup Cross Region Replication when the objects are server side encrypted.当对象是服务器端加密时,我无法设置跨区域复制。 I am using awscli to set it up.我正在使用 awscli 进行设置。 This is what I have done.这就是我所做的。

Cross region replication role IAM policy looks like this:跨区域复制角色 IAM 策略如下所示:

{


   "Version":"2012-10-17",
   "Statement":[
      {
         "Effect":"Allow",
         "Action":[
            "s3:GetReplicationConfiguration",
            "s3:ListBucket"
         ],
         "Resource":[
            "arn:aws:s3:::source-bucket"
         ]
      },
      {
         "Effect":"Allow",
         "Action":[

            "s3:GetObjectVersion",
            "s3:GetObjectVersionAcl",
            "s3:GetObjectVersionTagging"

         ],
         "Resource":[
            "arn:aws:s3:::source-bucket/*"
         ]
      },
      {
         "Effect":"Allow",
         "Action":[
            "s3:ReplicateObject",
            "s3:ReplicateDelete",
            "s3:ReplicateTags"
         ],
         "Resource":"arn:aws:s3:::destination-bucket/*"
      }
   ]
}

This is how my replication configuration file looks like:这是我的复制配置文件的样子:

{
    "Role": "arn:aws:iam::1234567890:role/replication-role",
    "Rules": [
        {
            "ID": "abcd",
            "Prefix": "",
            "Status": "Enabled",
            "SourceSelectionCriteria": {
                "SseKmsEncryptedObjects": {
                    "Status": "Enabled"
                }
            },
            "Destination": {
                "Bucket": "arn:aws:s3:::destinationbucket",
                "EncryptionConfiguration": {
                    "ReplicaKmsKeyID": "arn:aws:kms:us-west-2:1234567890:key/849b779d-bdc3-4190-b285-6006657a578c"
                }
            }
        }
    ]
}

This is how my cli command looks like:这是我的 cli 命令的样子:

aws s3api put-bucket-replication --bucket "sourcebucket" --replication-configuration  file://./replicationconfigfile.json

When I go to S3 bucket after running the cli command, I can see the replication rule being created with KMS-Encrypted Object as replicate but when i click on edit to see the details, it does not have any KMS keys selected.当我在运行 cli 命令后转到 S3 存储桶时,我可以看到使用KMS-Encrypted Object作为replicate创建的复制规则,但是当我单击edit查看详细信息时,它没有选择任何 KMS 密钥。

------Update------- ------更新-------

if i delete the rule created by cli and set it up using console, it selects all the kms keys in the wizard.如果我删除由 cli 创建的规则并使用控制台设置它,它会选择向导中的所有 kms 键。 So the question is why is it not selecting kms keys in source region when I am using cli?所以问题是为什么我在使用 cli 时不选择源区域中的 kms 键? what am I missing here?我在这里错过了什么?

KMS list field that is showed in the wizard is missing in the CLI, I have the same issue because I am using KMS to encrypt my origin and my destination bucket and I can't select the key to decrypt the objects in my origin bucket as I am using Terraform to created the replication rule. CLI 中缺少向导中显示的 KMS 列表字段,我遇到了同样的问题,因为我使用 KMS 来加密我的源和目标存储桶,但我无法选择密钥来解密我的源存储桶中的对象作为我正在使用 Terraform 创建复制规则。

As you can see here the only parameter that exists is "Replication criteria" and the value just can be true or false , the list field "Choose one or more keys for decrypting source objects" does not exist in the AWS CLI.正如您在此处看到的,唯一存在的参数是“复制条件” ,其值可以是truefalse ,AWS CLI 中不存在列表字段“选择一个或多个用于解密源对象的密钥”

I already sent this issue to them.我已经把这个问题发给他们了。

What did I do?我做了什么? I replaced my generated KMS key managed by me to use the key managed by AWS, I just enabled server-side encryption and I choose the AES256 encryption type in both bucket, origin and destination and it works fine to me.我将生成的由我管理的 KMS 密钥替换为使用由 AWS 管理的密钥,我刚刚启用了服务器端加密,并在存储桶、源和目标中选择了 AES256 加密类型,它对我来说很好用。

Just in case anyone else runs into this issue, I had a long conversation with AWS support where they confirmed that there is no way to set the key for decrypting source objects programmatically (or in CloudFormation).以防万一其他人遇到此问题,我与 AWS 支持进行了长时间的对话,他们确认无法以编程方式(或在 CloudFormation 中)设置用于解密源对象的密钥。 In my case, I had to set up the configuration with the SDK and then manually set the decryption key in the console.就我而言,我必须使用 SDK 设置配置,然后在控制台中手动设置解密密钥。 Fairly annoying that they haven't fixed this as of 7/8/2020.相当烦人的是,他们在 2020 年 7 月 8 日还没有解决这个问题。

Looking around at a Terraform thread where they discuss this same issue, I believe they get around this by setting the IAM policy for CRR directly, but I'm unsure of exactly how you do that.环顾他们讨论同一问题的 Terraform 线程,我相信他们通过直接为 CRR 设置 IAM 策略来解决这个问题,但我不确定您是如何做到这一点的。 https://github.com/terraform-providers/terraform-provider-aws/issues/6046#issuecomment-427960842 https://github.com/terraform-providers/terraform-provider-aws/issues/6046#issuecomment-427960842

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

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