# Why does terraform think that I might be modifying an availability zone

**URL:** <https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079>\
**Category:** Terraform\
**Created:** [November 1, 2024, 3:21pm UTC](https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079 "2024-11-01T15:21:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![RandellP](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/randellp/32/43667_2.png) [@RandellP](https://discuss.hashicorp.com/u/RandellP)\
**Post date:** [November 1, 2024, 3:21pm UTC](https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079/1 "2024-11-01T15:21:31Z")

</div>

Running a terraform plan. And I see this

```auto
  # module.aws_us_west_2.data.aws_availability_zones.available will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "aws_availability_zones" "available" {
      + group_names = (known after apply)
      + id = (known after apply)
      + names = (known after apply)
      + zone_ids = (known after apply)
    }

```

My code has this

```auto
data "aws_availability_zones" "available" {}

```

I can’t touch the zone, it’s owned by AWS. So what could possibly convince terraform that it depends on one of my resources or modules? Let alone that they could change it in some way?

Because of this of course it wasn’t to replace a bunch of things that use the zone name in their name.

---

<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:** [November 1, 2024, 3:41pm UTC](https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079/2 "2024-11-01T15:41:29Z")

</div>

The data source change says:

```auto
# module.aws_us_west_2.data.aws_availability_zones.available will be read during apply
# (depends on a resource or a module with changes pending)

```

You haven’t supplied the configuration which is needed to see _why_, but you have made the data source depend on a managed resource with changes, which means the data source cannot be read until after those changes have been applied.

Can you show an example of the config that causes this?

---

<div class="post-metadata">

**Author:** ![RandellP](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/randellp/32/43667_2.png) [@RandellP](https://discuss.hashicorp.com/u/RandellP)\
**Post date:** [November 1, 2024, 6:07pm UTC](https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079/3 "2024-11-01T18:07:53Z")

</div>

I am not sure what you mean by the config. Google wasn’t much help either. What information are you looking for?

Also… you said “you have made the data source depend a managed resource with changes”. The only way I can think of to do that for a read only resource like that would be to have a filter on the data directive that is derived from another resource. But I don’t have anything like that. So I am still confused on how it thinks that I did.

---

<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:** [November 1, 2024, 8:57pm UTC](https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079/4 "2024-11-01T20:57:50Z")

</div>

“config” here would mean enough of your terraform configuration to piece together all of the dependencies related to the data source in question.

Since the data source block itself doesn’t contain any references, and the data source is located at `module.aws_us_west_2.data.aws_availability_zones`, my next guess would be that you have a `depends_on` in the `aws_us_west_2` module call, which indirectly applies that dependency to the data source (and everything else) it contains.

---

<div class="post-metadata">

**Author:** ![RandellP](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/randellp/32/43667_2.png) [@RandellP](https://discuss.hashicorp.com/u/RandellP)\
**Post date:** [November 5, 2024, 11:28pm UTC](https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079/6 "2024-11-05T23:28:06Z")

</div>

So that would be a lot of code. But help me understand what you are saying. I get that we have resources which use the name of the availability zone in their name, and so if the az data source were to change, those resources that depend on it would need to be updated or recreated. But that doesn’t explain why terraform thinks the AZ data source is going to change. The data object clearly has no explicit depends\_on, and an empty block so it isn’t depending on something to get text to use as a filter. It should essentially be parent-less. The resource itself is also read-only, so it can’t change. Yet terraform is saying `depends on a resource or a module with changes pending`  
Seems like you might be saying, that because the data source is in a module. If that module specifically depends on something else, terraform just assumed that everything in the module now depends on whatever the module depends on. So the fix would be to move the data source to the top of the state, and pass it down?

---

<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:** [November 6, 2024, 12:17am UTC](https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079/7 "2024-11-06T00:17:29Z")

</div>

> If that module specifically depends on something else, terraform just assumed that everything in the module now depends on whatever the module depends on

Terraform doesn’t assume anything here 😉 Putting `depends_on` in a module call explicitly states “everything in this module depends on these things”.

You could move the data source outside of the module, but there is never a reason you need `depends_on` in a module call, and it’s a mistake to use it in many cases. It would be better to remove the `depends_on` and make sure the data flow represents the necessary dependencies. If there is something in the module which has an out-of-band dependency on something outside of the module, you can pass in the data from the dependency and set `depends_on` directly in the resource which requires it.

---

<div class="post-metadata">

**Author:** ![RandellP](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/randellp/32/43667_2.png) [@RandellP](https://discuss.hashicorp.com/u/RandellP)\
**Post date:** [November 6, 2024, 1:21am UTC](https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079/8 "2024-11-06T01:21:04Z")

</div>

Well, not all the resources in the module depend on things from the dependency. The this one, the az. It doesn’t depend on anything. It is just needed in the module, so that is where the data object is.  
As for the module depends on. The top level is calling several modules. And the depends\_on is to make sure they happen in the right order. We already pass in a variety of values to the module, and inside various resources use those values to figure out their values. So it sounds like you are saying that terraform would figure out the order without the depends\_on due to the inputs? so there is no reason to have it on the module?

---

<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:** [November 6, 2024, 12:54pm UTC](https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079/9 "2024-11-06T12:54:58Z")

</div>

Yes, Terraform determines the order of operations by the references between all the configuration objects (`depends_on` is not doing anything other than creating an artificial reference). There is no need to use `depends_on` unless you have resources which have a real-world dependency but no way to create a natural reference between them in the configuration.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/hashicorp/original/1X/79bf76adfd92a75631996933098f9ce29d37abf3.svg) [@system](https://discuss.hashicorp.com/u/system)\
**Post date:** [May 5, 2025, 12:55pm UTC](https://discuss.hashicorp.com/t/why-does-terraform-think-that-i-might-be-modifying-an-availability-zone/71079/10 "2025-05-05T12:55:03Z")

</div>

Closed on May 5, 2025, 12:55pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
