gpt4 book ai didi

json - CFT 模板错误:Fn::If 中未解决条件依赖性 UseDBSnapshot

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

尝试为 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。

如果您需要更多详细信息,请告诉我。

最佳答案

如果您要从快照恢复数据库,则无法提供 MasterUsernameMasterUserPassword。这些值将是 inherited来自快照,因此您必须将它们设为可选

If you specify the SourceDBInstanceIdentifier or DBSnapshotIdentifier property, don't specify this property. The value is inherited from the source DB instance or snapshot.

关于json - CFT 模板错误:Fn::If 中未解决条件依赖性 UseDBSnapshot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68237770/

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