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

Providing GCP URL paths allows resources to be created but refresh needlessly #897

Closed
spacez320 opened this issue Dec 24, 2017 · 2 comments
Assignees

Comments

@spacez320
Copy link

spacez320 commented Dec 24, 2017

It appears that you can successfully create resources using attribute values that just provide an API path (example: projects/wf-gcp-gb-vpchost-prod/global/networks/wf-gcp-gb-vpchost-prod-network) but these don't persist -- Terraform tries to constantly recreate them on every plan/apply unless you provide the full path (example: https://www.googleapis.com/compute/v1/projects/wf-gcp-gb-vpchost-prod/global/networks/wf-gcp-gb-vpchost-prod-network).

Terraform Version

Terraform v0.11.1

Affected Resource(s)

  • google_compute_forwarding_rule
  • google_compute_instance_group
  • probably others

Terraform Configuration Files

# Causes a resource refresh even if the resource is already present and not changing:

resource "google_compute_forwarding_rule" "internal" {                          
  count = "${var.internal_only ? "1" : "0"}"                    
                                                                                
  backend_service = "${google_compute_region_backend_service.internal.self_link}"
  load_balancing_scheme = "${local.scheme}"                                     
  name = "${local.base_name}-forwarder"                        
  network = "projects/wf-gcp-gb-vpchost-prod/global/networks/wf-gcp-gb-vpchost-prod-network"
  ports = ["${var.service_port}"]                               
  project = "${var.project}"                                      
  region = "${var.region}"                                       
  subnetwork = "projects/wf-gcp-gb-vpchost-prod/regions/${var.region}/subnetworks/${var.network}"
}
# Does not resource refresh after creation, as expected:

resource "google_compute_forwarding_rule" "internal" {                          
  count = "${var.internal_only ? "1" : "0"}"                    
                                                                                
  backend_service = "${google_compute_region_backend_service.internal.self_link}"
  load_balancing_scheme = "${local.scheme}"                                     
  name = "${local.base_name}-forwarder"                        
  network = "https://www.googleapis.com/compute/v1/projects/wf-gcp-gb-vpchost-prod/global/networks/wf-gcp-gb-vpchost-prod-network"
  ports = ["${var.service_port}"]                               
  project = "${var.project}"                                      
  region = "${var.region}"                                       
  subnetwork = "https://www.googleapis.com/compute/v1/projects/wf-gcp-gb-vpchost-prod/regions/${var.region}/subnetworks/${var.network}"
}

Debug Output

https://gist.github.com/spacez320/b5cebc3c5f8adfb0c9c3f201f8d4c2a8

Expected Behavior

Nothing was changing about the sources, so it shouldn't have appeared in the plan output.

Actual Behavior

The resource refreshes, and appears to try to remove part of the full URL to match local configuration.

Steps to Reproduce

  1. Create a resource that has an attribute requiring an API resource URL.
  2. Provide a URL API path, removing https://www.googleapis.com/compute/v1.
  3. terraform apply, observe the resource is successfully created.
  4. terraform plan, observe that Terraform wants to destory/recreate the resource.

Adding back the URL API path to the attribute causes this behavior to cease, although it seems like this is a bug since you can create the resource with the more succinct URL path.

@rosbo rosbo self-assigned this Jan 2, 2018
@rosbo
Copy link
Contributor

rosbo commented Jan 2, 2018

Hi,

This issue was fixed in #487.

Make sure to update the Google Terraform provider to the latest version.

Thank you.

Feel free to reopen if you are still experiencing this issue after updating to the latest version.

@ghost
Copy link

ghost commented Mar 30, 2020

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 👉 [email protected]. Thanks!

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

No branches or pull requests

2 participants