Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terraform Invalid depends_on reference

I am getting following error with Terraform after upgrading to 0.13

Error: Invalid depends_on reference on modules/iam/outputs.tf line 10, in output "config": 7: aws_iam_role_policy_attachment.eks_worker_node.policy_arn,

References in depends_on must be to a whole object (resource, etc), not to an attribute of an object. This error persist on all line from 7-11. Below is the output file from IAM module:

output "config" {
      value = {
        service_role = aws_iam_role.eks_service_role.name
        node_role    = aws_iam_role.eks_node.name
      }
      depends_on = [
        aws_iam_role_policy_attachment.eks_worker_node.policy_arn,
        aws_iam_role_policy_attachment.eks_cni.policy_arn,
        aws_iam_role_policy_attachment.ecr.policy_arn,
        aws_iam_role_policy_attachment.eks_service_policy.policy_arn,
        aws_iam_role_policy_attachment.eks_cluster_policy.policy_arn,
      ]
    }

1 Answers

According to the error message, your depends_on argument value should reference an object, and not an exported attribute. You can update to:

depends_on = [
  aws_iam_role_policy_attachment.eks_worker_node
  aws_iam_role_policy_attachment.eks_cni,
  aws_iam_role_policy_attachment.ecr,
  aws_iam_role_policy_attachment.eks_service_policy,
  aws_iam_role_policy_attachment.eks_cluster_policy
]

to comply with the new usage.

like image 170
Matt Schuchard Avatar answered Sep 05 '25 00:09

Matt Schuchard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!