How to implement S3 replication for existing objects in CDK?

0
  1. I already can replicate existing objects from aws console by setting up a batch job.

  2. But how to do the same thing in CDK?

  3. Currently, in CDK, I can only implement live replication for a new created bucket, not for existing objects. Here is

// create a new bucket and add replication rule 
// How to do replication for an existed bucket? 
const source = new cdk.aws_s3.CfnBucket(this, "SourceBucketNew", {
      bucketName: `replication-source-bucket-${this.account}`,
      versioningConfiguration: {
        status: "Enabled",
      },
      replicationConfiguration: {
        role: role.roleArn,
        rules: [
          {
            destination: {
              bucket: dest.bucketArn,
            },
            status: "Enabled",
          },
        ],
      },
    });
hai
gefragt vor 2 Jahren319 Aufrufe
1 Antwort
0

If you did not create the bucket with the CDK app, it is not possible to change the replication without a direct API call outside of CloudFormation. You would need to make that change using an AWSCustomResource.

There is a bit more context as to why this is the case here: https://github.com/aws/aws-cdk/issues/10348#issuecomment-692672755

profile pictureAWS
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen