【发布时间】:2021-09-15 03:37:15
【问题描述】:
尝试为 RDS 创建一个可以处理这两种情况的 CFT 创建一个新的 RDS Aurora MySQL 集群并 使用现有数据库集群快照创建 RDS 集群
这是我尝试过的,
我提供了模板的以下条件部分
"UseDbSnapshot" : {
"Fn::Not" : [
{
"Fn::Equals":[
{"Ref": "DBSnapshotName"},
""
]
}
]
}
并在下面的资源部分中引用
"RDSCluster1": {
"Type": "AWS::RDS::DBCluster",
"Condition": "isResourceCreate",
"Properties": {
"Engine": "aurora",
"DBSubnetGroupName": {
"Ref": "DBSubnetGroup"
},
"DBClusterParameterGroupName": {
"Ref": "RDSDBClusterParameterGroup"
},
"DBSnapshotIdentifier" : {
"Fn::If" : [
"UseDBSnapshot",
{"Ref" : "DBSnapshotName"},
{"Ref" : "AWS::NoValue"}
]
},
"MasterUsername": {
"Ref": "DbUser"
},
"MasterUserPassword": {
"Ref": "MasterUserPassword"
},
"StorageEncrypted" : true,
"KmsKeyId" : {
"Ref": "KmsKeyId"
},
"VpcSecurityGroupIds": [
{
"Fn::GetAtt": [
"DBAccessSecurityGroup",
"GroupId"
]
}
],
"Port": "3306",
"BackupRetentionPeriod": "1"
},
"DeletionPolicy": "Snapshot"
}
条件“isResourceCreate”已满足,但出现错误
模板错误:Fn::If 中未解决的条件依赖 UseDBSnapshot
你能帮帮我吗?
已查到在线链接https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-sample-templates.html 并创建了这个 CFT。
如果您需要更多详细信息,请告诉我。
【问题讨论】:
-
能否提供完整的模板?您当前的甚至没有显示参数。
-
你有一个错字。 UseDbSnapshot != UseDBSnapshot
-
在这里更新了我的 CFT 堆栈代码
-
现在,纠正模板后出现以下错误即使我使用了
"Fn::If" : [ "UseDbSnapshot", {"Ref" : "DBSnapshotName"}, {"Ref" : "AWS::NoValue"} ]@OleksiiDonoha,也无法指定 SnapshotIdentifier 和 MasterUsername
标签: json amazon-web-services amazon-cloudformation amazon-rds