【问题标题】:Template error: instance of Fn::GetAtt references undefined resource模板错误:Fn::GetAtt 的实例引用了未定义的资源
【发布时间】:2017-06-10 20:52:27
【问题描述】:

我有这个 cloudformation 模板:

"InstanceProfileProd": {
  "Type" : "AWS::IAM::InstanceProfile",
  "Properties": {
    "Path": "/",
    "Roles" : [ { "Ref" : "InstanceRole"} ]
  }
},

"CompLayer": {
  "Type": "AWS::OpsWorks::Layer",
  "DependsOn" : "OpsWorksServiceRole",
  "Properties": {
    "AutoAssignElasticIps" : false,
    "AutoAssignPublicIps" : true,
    "CustomJson" : {
      },
      "awscli" : {
        "profils" : {
          "default" : {
            "role_arn": { "Fn::GetAtt": [ "InstanceProfileProd","Arn" ] }
          }
        }
      },
    },
    "CustomSecurityGroupIds" : { "Ref" : "SecurityGroupIds" },
    "EnableAutoHealing" : true,
    "InstallUpdatesOnBoot": false,
    "LifecycleEventConfiguration": {
      "ShutdownEventConfiguration": {
        "DelayUntilElbConnectionsDrained": false,
        "ExecutionTimeout": 120 }
      },
      "Name": "Layer",
      "Shortname" : "layer1",
      "StackId": { "Ref": "CompStack" },
  }
},

当我验证模板时出现此错误:

An error occurred (ValidationError) when calling the ValidateTemplate operation: Template error: instance of Fn::GetAtt references undefined resource InstanceProfileProd

资源都被正确定义和写得很好;我不明白为什么我会收到这个错误。 我的 opsworks 堆栈的所有层都引用了实例配置文件。

【问题讨论】:

  • 除了 JSON 语法错误之外,如果您的问题仍然存在,请发布一个完整的堆栈模板来重现该问题,而不仅仅是较大模板的一小部分。引用FAQ,“问题可能不在您怀疑的部分,而是完全在另一部分。”

标签: json amazon-cloudformation aws-opsworks


【解决方案1】:

您的 JSON 格式不正确。

  • CustomJSON 下面的行有一个额外的右括号,应该删除:

    },
    
  • profils 中有一个错字,这似乎不是故意的(尽管可能与当前错误无关)。

【讨论】:

    猜你喜欢
    • 2021-10-25
    • 1970-01-01
    • 1970-01-01
    • 2021-11-21
    • 2020-08-30
    • 2021-11-12
    • 1970-01-01
    • 2021-08-07
    • 2019-04-26
    相关资源
    最近更新 更多