(module name): short issue description
See original GitHub issueAccording to this https://github.com/aws/aws-cdk/issues/10348#issuecomment-692685610 we can import existing bucket if the bucket is created in the same cdk app.
const sourcebucket = s3.Bucket.fromBucketAttributes(this, 'SourceBucket', {
bucketArn : 'arn:aws:s3:::test-bucket'
}
);
const cfnBucket = sourcebucket.node.defaultChild as s3.CfnBucket;
cfnBucket.replicationConfiguration
is still giving me Cannot set property ‘replicationConfiguration’ of undefined error.
This test-bucket
is being created in the same cdk app.
Use Case:
I have 2 stack. One i am using to create bucket and another is to add replication configuration.
Please let me know if there is another way to do this.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
(module name): (short issue description) #20201 - GitHub
Describe the bug. Lang: python. Attempting to remove bootstrapped version rules etc from final synthesized yaml templates by customizing the ...
Read more >Module Release, Project "short name" "messes up ... - Drupal
This is by design to disambiguate modules and other components that share a name across projects. Since https://www.drupal.org/project/dff was ...
Read more >Module:Settlement short description - Wikipedia
This Lua module is used on approximately 689,000 pages, or roughly 1% of all pages. ... Used in Template:Infobox settlement to generate short...
Read more >What is a module in software, hardware and programming?
In programming, a module is a section of code that is added in as a whole or is designed for easy reusability. What...
Read more >Java SE 9 - JPMS module naming - Stephen Colebourne's blog
Modules are a group of packages. As such, the module name must be related to the package names. Module names are strongly recommended...
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
Thanks for the reply @jumic, saved me some time here. This is a great solution to the question asked!
@krishansubudhi imported buckets will work the same way regardless if the bucket was originally created in the same CDK app or not. That is; they will return an IBucket which as jumic explained, doesn’t contain a CfnBucket.
The comment you linked was saying that:
Is there a reason you want to set replication configuration in the second stack instead of the stack where you initially create the bucket? Creating two stacks to do this is unnecessary so unless you have a reason to do this in two separate stacks I’d advise against it 😄
s3.Bucket.fromBucketAttributes
doesn’t create a new S3 bucket. It only imports an existing bucket. Hence it doesn’t contain a CfnBucket (which would create a new bucket).However, you could pass the bucket object from the first to the second stack. In this case, you could split the definition of the S3 bucket and the replication configuration into to CDK stacks in a CDK app.
Example of both stacks:
In the app, pass the buckets to the second stack:
Note:
replicationConfiguration
in a second stack.cdk.out
. In the CloudFormation templates that are generated by CDK, the bucket and the replicationConfiguration will be moved to the first stack. This is correct because all properties have to be merged into a single CloudFormation resource (AWS::S3::Bucket
).