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

Compare region_backend_service.backend[].group as a relative path #1487

Merged
merged 1 commit into from
May 14, 2018

Conversation

tmshn
Copy link
Contributor

@tmshn tmshn commented May 13, 2018

In a region_backend_service resource, backend[].group argument is compared using full url. Therefore, if you pass a self_link of instance_group with beta feature enabled, you'll suffer from persisting perpetual diff.

E.g.:

resource "google_compute_instance_group_manager" "foo" {
  // ...configs (omitted)...
  // ↓ This is beta feature
  update_strategy       = "ROLLING_UPDATE" 
  rolling_update_policy = {
    type           = "PROACTIVE"
    minimal_action = "REPLACE"
  }
}

resource "google_compute_region_backend_service" "foo" {
  // ...configs (omitted)...
  backend = [
    {
        group = "${google_compute_instance_group_manager.foo.self_link}"
    },
  ]
}

With this configuration, following diff always occurs.

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  ~ google_compute_region_backend_service.foo
      backend.1111111111.description: "" => ""
      backend.1111111111.group:       "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instanceGroups/igm-foo" => ""
      backend.2222222222.description: "" => ""
      backend.2222222222.group:       "" => "https://www.googleapis.com/compute/beta/projects/my-project/zones/us-central1-a/instanceGroups/igm-foo"

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

------------------------------------------------------------------------

To suppress this, I set compareSelfLinkRelativePaths as DiffSuppressFunc for backend[].group, like non-regional backend_service does.
https://github.com/terraform-providers/terraform-provider-google/blob/v1.12.0/google/resource_compute_backend_service.go#L80

@tmshn
Copy link
Contributor Author

tmshn commented May 13, 2018

Should I add a test for this?

@emilymye
Copy link
Contributor

I actually think this is the appropriate behavior - if a resource is changed to a beta resource, it should be recreated. If after the initial v1 --> beta change the diff persists, that's more an issue around how we compute the instance group for the initial diff.

@danawillow
Copy link
Contributor

@emilymye that's not actually true- v1 and beta resources are the same underneath. the self_link only describes which API we used to access it. I'm going to go ahead and merge this, hope you don't mind :)

@danawillow danawillow merged commit 2d580ea into hashicorp:master May 14, 2018
@danawillow
Copy link
Contributor

@tmshn whoops, merged before realizing you'll also need to change the hash function. take a look at how we do it for regular backend services- it's already been fixed there.

@tmshn
Copy link
Contributor Author

tmshn commented May 15, 2018

@danawillow Oh I missed that! Thanks to point out. I fixed it in #1491.

@tmshn tmshn deleted the region-bs-diff branch May 15, 2018 03:45
danawillow pushed a commit that referenced this pull request May 22, 2018
Along the change on region_backend_service.backend[].group to use DiffSuppressFunc (#1487), we also need to change hash function, as [pointed out](#1487 (comment)).

Fixed this in a same way regular backend services do.
https://github.com/terraform-providers/terraform-provider-google/blob/v1.12.0/google/resource_compute_backend_service_migrate.go#L102-L103
@ghost
Copy link

ghost commented Nov 18, 2018

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants