【问题标题】:CFT Template error: unresolved condition dependency UseDBSnapshot in Fn::IfCFT 模板错误:Fn::If 中未解决的条件依赖 UseDBSnapshot
【发布时间】: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


【解决方案1】:

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

如果您指定 SourceDBInstanceIdentifier 或 DBSnapshotIdentifier 属性,请不要指定此属性。该值继承自源数据库实例或快照

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-14
    • 1970-01-01
    • 1970-01-01
    • 2020-10-22
    • 2012-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多