gpt4 book ai didi

amazon-web-services - AWS S3 Cloudformation 更新堆栈失败

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

我有一个 S3 的 cloudformation 模板,我正在尝试创建它一次,然后更新它。但是当我尝试更新它时,它失败并显示错误消息 <bucket_name> already exists in stack <arn:id> .

    "S3Bucket": {
"Type": "AWS::S3::Bucket",
"DeletionPolicy": "Retain",
"Properties": {
"AccessControl": "BucketOwnerFullControl",
"BucketName": {
"Fn::Join": [
"-",
[
{
"Fn::GetAtt": [
"VPCInfo",
"VPCname"
]
},
{
"Ref": "BucketName"
}
]
]
},
"LoggingConfiguration": {
"DestinationBucketName": {
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"VPCInfo",
"VPCname"
]
},
"-s3logs"
]
]
},
"LogFilePrefix": {
"Fn::Join": [
"-",
[
{
"Fn::GetAtt": [
"VPCInfo",
"VPCname"
]
},
{
"Ref": "AWS::StackName"
}
]
]
}
},
"VersioningConfiguration": {
"Status": "Enabled"
}
}
}

第二次尝试更新 BucketName & TopicName作为参数传递

    "S3Bucket": {
"Type": "AWS::S3::Bucket",
"DeletionPolicy": "Retain",
"Properties": {
"AccessControl": "BucketOwnerFullControl",
"BucketName": {
"Fn::Join": [
"-",
[
{
"Fn::GetAtt": [
"VPCInfo",
"VPCname"
]
},
{
"Ref": "BucketName"
}
]
]
},
"LoggingConfiguration": {
"DestinationBucketName": {
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"VPCInfo",
"VPCname"
]
},
"-s3logs"
]
]
},
"LogFilePrefix": {
"Fn::Join": [
"-",
[
{
"Fn::GetAtt": [
"VPCInfo",
"VPCname"
]
},
{
"Ref": "AWS::StackName"
}
]
]
}
},
"NotificationConfiguration": {
"TopicConfigurations": [
{
"Topic": {
"Fn::Join": [
"",
[
"arn:aws:sns:",
{
"Ref": "AWS::Region"
},
":",
{
"Ref": "AWS::AccountId"
},
":function:",
{
"Ref": "TopicName"
}
]
]
},
"Event": "s3:ObjectCreated:*",
"Filter": {
"S3Key": {
"Rules": [
{
"Name": "suffix",
"Value": {
"Ref": "FileSuffix"
}
}
]
}
}
},
{
"Topic": {
"Fn::Join": [
"",
[
"arn:aws:sns:",
{
"Ref": "AWS::Region"
},
":",
{
"Ref": "AWS::AccountId"
},
":function:",
{
"Ref": "TopicName"
}
]
]
},
"Event": "s3:ObjectRemoved:*",
"Filter": {
"S3Key": {
"Rules": [
{
"Name": "suffix",
"Value": {
"Ref": "FileSuffix"
}
}
]
}
}
}
]
},
"VersioningConfiguration": {
"Status": "Enabled"
}
}
}

更新 S3 堆栈的正确方法是什么?我尝试执行两次的原因是由于此 -> https://aws.amazon.com/premiumsupport/knowledge-center/unable-validate-destination-s3/

最佳答案

我相信您正在删除 CFT 并重新创建它。您的问题是 "DeletionPolicy": "Retain" 即使您删除了 CFT,它也会保留 S3 存储桶。如果您更新现有的,应该没问题。

如果删除 CFT,只需手动删除存储桶或将 "DeletionPolicy": "Retain" 更改为 "DeletionPolicy": "Delete"

关于amazon-web-services - AWS S3 Cloudformation 更新堆栈失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50183417/

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