简体   繁体   English

CREATE_FAILED | AWS::S3::Bucket,隐形桶存在吗?

[英]CREATE_FAILED | AWS::S3::Bucket, the invisible bucket is exist?

I am using aws-cdk and $cdk deploy to deploy some stacks.我正在使用 aws-cdk 和$cdk deploy来部署一些堆栈。

However, there comes error like this但是,会出现这样的错误

21:12:30 | CREATE_FAILED        | AWS::S3::Bucket                             | S3BucketStaticResourceB341FA19
si2-s3-sbu-mytest-xxx-static-resource-5133297d-91 already exists

Normally this kind of error, I can find the item exists in AWS console.通常这种错误,我可以在 AWS 控制台中找到该项目。

However in this case, $aws s3 ls doesn't show the bucket named this.但是在这种情况下, $aws s3 ls不会显示名为 this 的存储桶。

Why does this occur or where should I fix??为什么会发生这种情况或我应该在哪里解决?

Generally, it is a good idea to avoid explicitly providing physical names for resources you create with CDK.通常,最好避免为使用 CDK 创建的资源显式提供物理名称。

The documentation explains the reasoning: 文档解释了原因:

Assigning physical names to resources has some disadvantages in AWS CloudFormation.在 AWS CloudFormation 中为资源分配物理名称有一些缺点。 Most importantly, any changes to deployed resources that require a resource replacement, such as changes to a resource's properties that are immutable after creation, will fail if a resource has a physical name assigned.最重要的是,如果为资源分配了物理名称,则对需要替换资源的已部署资源的任何更改(例如对创建后不可变的资源属性的更改)都将失败。 If you end up in that state, the only solution is to delete the AWS CloudFormation stack, then deploy the AWS CDK app again.如果您最终进入该 state,唯一的解决方案是删除 AWS CloudFormation 堆栈,然后再次部署 AWS CDK 应用程序。 See the AWS CloudFormation documentation for details.有关详细信息,请参阅 AWS CloudFormation 文档。

So if you introduce a change that requires your bucket to be replaced, you'll see the aforementioned error.因此,如果您引入需要更换存储桶的更改,您将看到上述错误。

In your specific case, it is probably an S3-specific issue that bucket names are globally unique - across all accounts and regions, as stated by @Omar Rosadio in the comments.在您的特定情况下,如@Omar Rosadio 在评论中所述,存储桶名称在所有账户和区域中是全局唯一的,这可能是 S3 特定的问题。 This makes naming your buckets yourself an especially bad idea.这使得自己命名您的存储桶成为一个特别糟糕的主意。

If you don't pass the bucketName property when creating the bucket, CDK will generate a unique name for you, so you don't have to worry about this, and I suggest doing so.如果你在创建bucket的时候没有传递bucketName属性,CDK会为你生成一个唯一的名字,所以你不用担心这个,我建议这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM