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
demandé il y a 2 ans316 vues
1 réponse
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
répondu il y a 2 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions