Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filestore instance constantly re-creating due to the network 'name' #16548

Open
chilversc opened this issue Nov 16, 2023 · 2 comments
Open

Filestore instance constantly re-creating due to the network 'name' #16548

chilversc opened this issue Nov 16, 2023 · 2 comments

Comments

@chilversc
Copy link

chilversc commented Nov 16, 2023

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.6.1
on linux_amd64
+ provider [registry.terraform.io/hashicorp/google](http://registry.terraform.io/hashicorp/google) v5.6.0

Affected Resource(s)

  • google_filestore_instance

Terraform Configuration Files

provider "google" {
  project = "gcp-dev"
}

resource "google_compute_network" "vpc" {
  name                    = "app-name-vpc"
  auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "network" {
  name          = "app-name-network"
  ip_cidr_range = "172.160.0.0/24"
  region        = "europe-west4"
  network       = google_compute_network.vpc.id
}

resource "google_filestore_instance" "filestore" {
  name     = "app-name-filestore"
  location = "europe-west4-a"
  tier     = "STANDARD"

  file_shares {
    capacity_gb = 1024
    name        = "salt_master"
  }

  networks {
    network           = google_compute_network.vpc.id
    modes             = ["MODE_IPV4"]
    connect_mode      = "DIRECT_PEERING"
    reserved_ip_range = "172.16.255.0/29"
  }
}

Output from second plan

google_compute_network.vpc: Refreshing state... [id=projects/gcp-dev/global/networks/app-name-vpc]
google_compute_subnetwork.network: Refreshing state... [id=projects/gcp-dev/regions/europe-west4/subnetworks/app-name-network]
google_filestore_instance.filestore: Refreshing state... [id=projects/gcp-dev/locations/europe-west4-a/instances/app-name-filestore]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with
the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # google_filestore_instance.filestore must be replaced
-/+ resource "google_filestore_instance" "filestore" {
      ~ create_time      = "2023-11-14T15:18:28.430171058Z" -> (known after apply)
      ~ effective_labels = {} -> (known after apply)
      + etag             = (known after apply)
      ~ id               = "projects/gcp-dev/locations/europe-west4-a/instances/app-name-filestore" -> (known after apply)
      - labels           = {} -> null
        name             = "app-name-filestore"
      ~ terraform_labels = {} -> (known after apply)
      + zone             = (known after apply)
        # (3 unchanged attributes hidden)

      ~ file_shares {
            name          = "salt_master"
          + source_backup = (known after apply)
            # (1 unchanged attribute hidden)
        }

      ~ networks {
          ~ ip_addresses      = [
              - "172.16.255.2",
            ] -> (known after apply)
          ~ network           = "app-name-vpc" -> "projects/gcp-dev/global/networks/app-name-vpc" # forces replacement
            # (3 unchanged attributes hidden)
        }
    }

Plan: 1 to add, 0 to change, 1 to destroy.

Expected Behavior

The Filestore instance should not be replaced (or even updated).

Actual Behavior

The Filestore instance is replaced.

Steps to Reproduce

  1. terraform apply
  2. terraform plan

References

It seems like this issue should have been fixed back in v4.28.0. However plan is still causing a diff for me.

b/312432561

@chilversc chilversc added the bug label Nov 16, 2023
@github-actions github-actions bot added forward/review In review; remove label to forward service/filestore labels Nov 16, 2023
@edwardmedia edwardmedia self-assigned this Nov 16, 2023
@edwardmedia
Copy link
Contributor

looks like a diffsuppress needs to be added on network

@NimJay
Copy link

NimJay commented Mar 22, 2024

A workaround is to use ignore_changes:

resource "google_filestore_instance" "my_filestore_instance" {
...
    lifecycle {
        ignore_changes = [networks[0].network]
    }
...
}

But if you expect your VPC (virtual private cloud) network to change (i.e., if you intend to manually change the network), avoid this workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants