title: Terraform Module dependency not working ( version 0.12)
body: <p>i am trying to pass one output value from one terraform module to another terraform module, but facing below issue</p>
  <p>my use case is this, in first module i am creating one IAM role and in the second module i need to use above created IAM role (also, in second module if role is not getting created in first module it will create role itself in second module, please consider it as requirement)</p>
  <pre><code>module &quot;createiamrole&quot;{
    source = &quot;./modules/createiamrole&quot;
  }
  
  
  // this module creates new role, if role is not supplied from above module (default value of iam_role is &quot;&quot; set in variables.tf).
  module &quot;checkiamrole&quot;{
    source = &quot;./modules/checkiamrole&quot;
    iam_role_depends_on = module.createiamrole.iam_role_name
    iam_role    = &quot;${module.createiamrole.iam_role_name}&quot;
  }
  
  </code></pre>
  <p>outputs.tf for stroing iam_role_name from first module</p>
  <pre><code>output &quot;iam_role_name&quot; {
    description = &quot;name for IAM role&quot;
    value       = aws_iam_role.createiamrole[0].name
  }
  </code></pre>
  <p>resource code of module checkiamrole for which i am getting error</p>
  <pre><code>resource &quot;aws_iam_role&quot; &quot;newrole&quot; {
    count              = var.iam_role == &quot;&quot; ? 1 : 0
    name               = &quot;my-new-iamrole&quot;
    assume_role_policy = data.aws_iam_policy_document.iampolicy[0].json
  
    tags = var.tags
  
    depends_on = [var.iam_role_depends_on]
  }
  </code></pre>
  <p>Error
  Invalid count argument</p>
  <p>count              = var.iam_role == &quot;&quot; ? 1 : 0</p>
  <p>The &quot;count&quot; value depends on resource attributes that cannot be determined
  until apply, so Terraform cannot predict how many instances will be created.
  To work around this, use the -target argument to first apply only the
  resources that the count depends on.</p>
  <p>My Query is how to implement module dependency as well how to pass one output value from dependent module to required module</p>