# Depends\_on having issues

**URL:** <https://discuss.hashicorp.com/t/depends-on-having-issues/49570>\
**Category:** Terraform\
**Created:** [February 1, 2023, 3:47am UTC](https://discuss.hashicorp.com/t/depends-on-having-issues/49570 "2023-02-01T03:47:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PBSankar](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/pbsankar/32/33556_2.png) [@PBSankar](https://discuss.hashicorp.com/u/PBSankar)\
**Post date:** [February 1, 2023, 3:47am UTC](https://discuss.hashicorp.com/t/depends-on-having-issues/49570/1 "2023-02-01T03:47:59Z")

</div>

Hello,  
Please help me to fix this issue.

I have the following code, which is not working.

depends\_on = [var.instance\_name[count.index] == backend ? backend : null]

below the error which throwing :

Error: Invalid expression  
│  
│ on azurevm.tf line 48, in resource “azurerm\_virtual\_machine” “main”:  
│ 48: depends\_on = var.instance\_name[count.index] == backend ? backend : null  
│  
│ A static list expression is required.

---

<div class="post-metadata">

**Author:** ![maxb](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxb/32/26655_2.png) [@maxb](https://discuss.hashicorp.com/u/maxb)\
**Post date:** [February 1, 2023, 6:16am UTC](https://discuss.hashicorp.com/t/depends-on-having-issues/49570/2 "2023-02-01T06:16:41Z")

</div>

> [@PBSankar](#):
>
> A static list expression is required

Terraform is telling you that it does not allow you to use count.index in a depends\_on.

Dependencies are between entire blocks - it doesn’t track separate dependencies for e.g. item [0] and [1] of a block.

---

<div class="post-metadata">

**Author:** ![jbardin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jbardin/32/3325_2.png) [@jbardin](https://discuss.hashicorp.com/u/jbardin)\
**Post date:** [February 1, 2023, 3:17pm UTC](https://discuss.hashicorp.com/t/depends-on-having-issues/49570/3 "2023-02-01T15:17:27Z")

</div>

@PBSankar,

In order to evaluate an expression, Terraform first must connect all dependencies to have the data for evaluation. This means that if an expression like your `depends_on` example were allowed, the dependencies would have already been connected before the result is even known, making the result useless which is why it’s not allowed. I would assume `var.instance_name` is already taken into account in the resource config, and the `backend` data is coming from another expression, so this `depends_on` probably has no effect whatsoever.
