模板错误:Fn :: GetAtt的实例引用了未定义的资源

时间:2017-01-25 15:37:13

标签: json amazon-cloudformation aws-opsworks

我有这个云形态模板:

"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堆栈的所有层中引用。

1 个答案:

答案 0 :(得分:1)

您的JSON格式不正确。

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

    },
    
  • profils中有一个拼写似乎并非故意(虽然可能与当前错误无关)。