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

Updating any subnet in a list causes subsequent subnets to be re-created #70

Closed
onetwopunch opened this issue Sep 12, 2019 · 2 comments · Fixed by #86
Closed

Updating any subnet in a list causes subsequent subnets to be re-created #70

onetwopunch opened this issue Sep 12, 2019 · 2 comments · Fixed by #86
Assignees
Labels
bug Something isn't working P2 high priority issues triaged Scoped and ready for work

Comments

@onetwopunch
Copy link

onetwopunch commented Sep 12, 2019

Expected behavior

When a subnet is modfied in source, only one resource is modified in the plan/apply

Actual behavior

When a subnet in the list of var.subnets is updated or deleted, it forces recreation of all subsequent subnets in the list.

Example

If I were to update the subnet_ip for subnet-01 it would force re-creation of subnet-02 as well.

module "vpc" {
    source  = "terraform-google-modules/network/google"
    version = "~> 1.0.0"
  
   ...  
   
    subnets = [
        {
            subnet_name           = "subnet-01"
            subnet_ip             = "10.10.10.0/24"
            subnet_region         = "us-west1"
        },
        {
            subnet_name           = "subnet-02"
            subnet_ip             = "10.10.20.0/24"
            subnet_region         = "us-west1"
            subnet_private_access = "true"
            subnet_flow_logs      = "true"
            description           = "This subnet has a description"
        },
    ]
    ...
}
@morgante
Copy link
Contributor

Thanks for the report.

We should solve this by switching subnets to use for_each: https://www.terraform.io/docs/configuration/resources.html#for_each-multiple-resource-instances-defined-by-a-map-or-set-of-strings

@aaron-lane aaron-lane added the bug Something isn't working label Sep 16, 2019
@tfhartmann
Copy link
Contributor

I also ran into this and started a feature branch that I got working. I should be able to open a PR later today 😄

@tfhartmann tfhartmann mentioned this issue Nov 8, 2019
8 tasks
@aaron-lane aaron-lane added the P2 high priority issues label Dec 2, 2019
@aaron-lane aaron-lane added the triaged Scoped and ready for work label Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 high priority issues triaged Scoped and ready for work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants