[s3] Add replication configuration to existing S3 bucket
See original GitHub issue❓ General Issue
The Question
I’m trying to assign replication configuration to existing S3 bucket using the code:
const cfnBucket = bucket.node.defaultChild as s3.CfnBucket;
cfnBucket.replicationConfiguration = {
role: replicationRole.roleName,
rules:[
{
destination:{
bucket: bucket.bucketName
},
prefix: "target_prefix",
status: "Enabled",
filter: {
prefix: "source_prefix"
}
}
]
}
Getting error at cdk synth: Cannot set property ‘replicationConfiguration’ of undefined
If I create bucket from the CDK code - template synth is working fine.
Is there any workaround to do the trick?
Environment
- CDK CLI Version: 1.63.0 (build 7a68125)
- Module Version:
- Node.js Version: v14.8.0
- OS: OSX 10.14.6
- Language (Version): TypeScript
Other information
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Configuring replication for source and destination buckets ...
Set up replication in Amazon S3 where the source and destination buckets are owned by the same AWS account.
Read more >How to add a replication rule to an S3 bucket - HowtoForge
Replication can copy newly created or updated objects from the source S3 bucket to the destination S3 bucket. The objects which already exist...
Read more >How to easily replicate existing S3 objects using S3 batch ...
Click on the bucket that you just created and navigate to the management tab. For creating S3 batch replication, we first have to...
Read more >Replicating objects - Amazon Simple Storage Service
Replication enables automatic, asynchronous copying of objects across Amazon S3 buckets. Buckets that are configured for object replication can be owned by the ......
Read more >Is there a way to add s3 replication policy with existing bucket ...
I don't think you can. CDK code converts into CloudFormation. An AWS::S3::Bucket entity contains a ReplicationConfiguration .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@SZubarev You can set it up just like you did, but not on an imported bucket. That is, if you create your bucket inside the same cdk app:
Then you use the escape hatch just like you did.
If you need to setup replication configuration on an already existing bucket, you’d need to use the
AwsCustomResource
and invoke the appropriate API call using the AWS JavaScript SDK.A separate CFN template will also not help because you won’t be able to include an existing bucket into a CFN template (this is also why CDK doesn’t support it).
Closing this issue since it seems to be resolved. Feel free to reopen.