amazon-web-services - AWS S3 Cloudormation 更新堆栈失败
问题描述
我有一个用于 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"
推荐阅读
- azure - Microsoft graph 获取通话数据不起作用
- javascript - 在角度应用程序中以树结构显示数据
- excel - 循环浏览工作表以查看工作表名称是否已被占用 - 循环中的 Len/Left 函数
- android - 如何将不同 api id 的数据显示到不同的回收视图项?
- angularjs - 使用 angularjs 在 Select2 中设置选定值
- ionic-framework - 在 Play 商店中找不到 Ionic DevApp
- node.js - 通过 node.js 对 Google API 的几次调用后,事件列表返回空数组
- sql - 实体框架:在不读取所有数据的情况下检查值是否为空?
- google-cloud-platform - GCP - 无法通过 SSH 连接到新的 GPU 深度学习 VM 实例
- git - Git 命令在 vagrant 机器中没有 sudo 就无法工作