gpt4 book ai didi

amazon-web-services - Cloudformation 脚本堆栈构建使用现有 s3 存储桶而不是创建新存储桶(错误 : s3-bucket-name already exists)

转载 作者:行者123 更新时间:2023-12-03 07:12:27 25 4
gpt4 key购买 nike

我正在创建一个 AWS cloudformation 脚本来创建 S3 存储桶和通知事件来触发 Lambda。作为其中的一部分,如果尚未创建 s3 存储桶,它将创建 s3 存储桶并且一切正常。

但是如果 S3 存储桶已经存在,则会出现错误。

错误:s3-bucket-name 已存在

"S3Bucket" : {
"Type" : "AWS::S3::Bucket",
"Properties" : {
"BucketName" : {
"Ref": "s3-bucket-name"
},
"NotificationConfiguration" : {
"LambdaConfigurations" : [ {
"Event" : "s3:ObjectCreated:*",
"Filter" : {
...
},
"Function" : {
"Fn::Sub": "<your-lambda-arn>"
}
}]
...
}

AWS cloudformation 堆栈应使用该存储桶(如果已存在)。如果不存在则创建。

我可能错过了一些东西。

最佳答案

如果您的模板尚未创建存储桶,AWS 将简单地假设您正在尝试创建与现有存储桶同名的第二个存储桶。当然你不能这样做,因为存储桶必须有唯一的名称。因此,您会收到s3-bucket-name已经存在错误。

要将在 CloudFormation 外部创建的现有存储桶置于 CloudFormation 的控制之下,您需要 import他们。

S3 存储桶为 one of the resources如果它们已经存在,则可以将其导入到 CloudFormation 中。

关于amazon-web-services - Cloudformation 脚本堆栈构建使用现有 s3 存储桶而不是创建新存储桶(错误 : s3-bucket-name already exists),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61152446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com