aws-cdk: (s3): bucket already exists
I’m using aws-cdk-go https://github.com/aws/aws-cdk-go to deploy a stack with some functionalities. As far as I create a bucket resource using NewBucket call from github.com/aws/aws-cdk-go/awscdk/awss3 package I get an error that says the bucket already exists. I mean, I think this should check if it exists and omit creating again.
0/101 |7:54:10 AM | CREATE_FAILED | AWS::S3::Bucket | cdk-wiserentr-stack-dev-user-docs (cdkwiserentrstackdevuserdocsC2F72F08) cdk-wiserentr-stack-dev-user-docs already exists
new Bucket (/tmp/jsii-kernel-aeePMk/node_modules/monocdk/lib/aws-s3/lib/bucket.js:589:26)
\_ /tmp/jsii-runtime.481357249/lib/program.js:8367:58
\_ Kernel._wrapSandboxCode (/tmp/jsii-runtime.481357249/lib/program.js:8795:24)
\_ Kernel._create (/tmp/jsii-runtime.481357249/lib/program.js:8367:34)
\_ Kernel.create (/tmp/jsii-runtime.481357249/lib/program.js:8108:29)
\_ KernelHost.processRequest (/tmp/jsii-runtime.481357249/lib/program.js:9692:36)
\_ KernelHost.run (/tmp/jsii-runtime.481357249/lib/program.js:9655:22)
\_ Immediate._onImmediate (/tmp/jsii-runtime.481357249/lib/program.js:9656:46)
\_ processImmediate (internal/timers.js:464:21)
Reproduction Steps
What did you expect to happen?
What actually happened?
Environment
- CDK CLI Version : github.com/aws/aws-cdk-go/awscdk v1.124.0-devpreview
- Framework Version:
- Node.js Version: v16.9.1
- OS : Linux 5.14.2-1-MANJARO
- Language (Version): go version go1.16.7 linux/amd64
Other
This is 🐛 Bug Report
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (7 by maintainers)
@urko-b I’ll sum up everything I’ve said so far.
Important things to know:
BucketNameprop.BucketNameprop. According to AWS documentation:What should you do?
OPTION 1 According to CDK documentation, delete your stack and then redeploy your stack. If you don’t make any additional changes after you redeploy which cause resource replacement, you won’t run into this issue anymore.
OPTION 2 According to CloudFormation documentation, specify a new physical name. If you don’t make any additional changes after you redeploy which cause resource replacement, you won’t run into this issue anymore.
OPTION 3 According to CDK best practices, do not specify the
BucketNameprop. You can make changes which cause resource replacement after this and you won’t run into this issue anymore.I’ve thoroughly explained what’s happening at this point, so I’m going to close the issue. Please ping me if you’ve fully understood everything I’ve said and you’re still running into issues. Thanks! 😄
Hi @peterwoodworth But I mean. Why with event-bus creation is not happening the same? I think the NewBucket method should check if the bucket already exists and then do not create it. Otherwise S3 bucket creation using the cdk-stack code is not reusable. I only can run once the NewBucket creation… Is not friendly for developers.