ReplicationTime cannot be used for this version of the replication configuration schema

Viewed 338

I am trying to get S3 Replication working via AWS CDK. I am using https://github.com/rogerchi/cdk-s3-bucketreplication/blob/main/src/index.ts as a starting point and it does create a replication rule. However there are some issues when trying to make it specific the case i want to setup.

When adding RTC (Replication Time Control)

sourceBucket.replicationConfiguration = {
      role: replicationRole.roleArn,
      rules: [
        {
          destination: {
            storageClass: ReplicationDestinationStorageClass.STANDARD_IA,
            bucket: destinationBucket.bucketArn,
            metrics: {
              status: "Enabled",
              eventThreshold: {
                minutes: 15,
              },
            },
            replicationTime: {
              status: "Enabled",
              time: {
                minutes: 15,
              },
            },
          },
          status: ReplicationRuleStatus.ENABLED,
        },
      ],
    };

I get the following error....

ReplicationTime cannot be used for this version of the replication configuration schema.

Also, i do not wish to use a prefix but want the rule scope to be "This rule applies to all objects in the bucket". As per the console setting below. The above approach appears to create a configuration that 'should' have a prefix. i.e. Looking at the created rule it appears to have "Limit the scope of this rule using one or more filters" selected by default.

enter image description here

Any advice would be appreciated.

1 Answers

I ran into the same problem with Terraform and had to add this:

        filter {
          tags = {}
        }

I got the hint from here: Is there a way to enable ReplicationConfiguration for AWS S3 Replication management using s3.putbucketreplication API? which points to https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication-add-config.html#replication-config-optional-filter which (not very clearly) indicates that you need to use the API V2 for replication to work:

Replication configuration XML V2 includes the Filter element for rules.

As you want all objects (as did I) there is also:

If you specify a rule with an empty filter tag your rule will apply to all objects in your bucket.
Related