json - CFT 模板错误:Fn::If 中未解决的条件依赖 UseDBSnapshot
问题描述
尝试为 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。
如果您需要更多详细信息,请告诉我。
解决方案
如果要从快照恢复数据库,则不能提供 MasterUsername
和MasterUserPassword
. 这些值将从快照继承,因此您必须将它们设为可选。
如果您指定 SourceDBInstanceIdentifier 或 DBSnapshotIdentifier 属性,请不要指定此属性。该值继承自源数据库实例或快照。
推荐阅读
- javascript - 为什么我收到“错误 25:预期:;” 在这个函数定义中?
- python - Tensorflow 已安装但无法在 Windows 10 中运行
- python - 将 numpy 数组中的每一列滚动 x 步的最有效方法
- spacemacs - 如何禁用 Spacemacs 的彩虹分隔符?
- javascript - 如何在 wavesurfer.js 中播放一个区域?
- php - 警告:mysqli_query() 需要至少 2 个参数,1 [...]
- javascript - Javascript数组到laravel控制器
- mysql - 更新触发
- wifi - Flutter:使用“flutter run”时更改互联网连接
- java - java opencv GLIBC_2.14 未找到