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

Jav*_*een 5 json aws-cloudformation aws-opsworks

我有这个 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" },
  }
},
Run Code Online (Sandbox Code Playgroud)

当我验证模板时,我收到此错误:

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

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

wjo*_*dan 2

您的 JSON 格式不正确。

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

    },
    
    Run Code Online (Sandbox Code Playgroud)
  • 有一个拼写错误profils似乎不是故意的(尽管可能与当前错误无关)。