Template error: instance of Fn::GetAtt references undefined resource

JavaQueen picture JavaQueen · Jan 25, 2017 · Viewed 14k times · Source

I have this cloudformation template :

"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" },
  }
},

When I validate the template I get this error :

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

The resources are all properly defined and well writen; I don't understand why I am getting this error. The instance profile is referenced in all the layers of my opsworks stack.

Answer

wjordan picture wjordan · Jan 25, 2017

Your JSON is not well-formed.

  • The line below CustomJSON has an extra closing bracket that should be removed:

    },
    
  • There is a typo in profils that doesn't seem intentional (though probably unrelated to the current error).