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

data lookup forcing new resource on apply #6

Closed
hawksight opened this issue Nov 26, 2018 · 1 comment
Closed

data lookup forcing new resource on apply #6

hawksight opened this issue Nov 26, 2018 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@hawksight
Copy link

hawksight commented Nov 26, 2018

Using the module as follows:

module "internal-lb" {
  source      = "../gcloud-lb-internal"
  project     = "${var.project}"
  region      = "${var.region}"
  name        = "${var.vpc}-es-lb-internal"
  network     = "${var.vpc}"
  subnetwork  = "${data.google_compute_subnetwork.link.name}"
  ports       = ["9200"]
  health_port = "9200"
  source_tags = "${var.lb_source_tags}"
  target_tags = ["${module.cluster.K8S_TAG}"]

  # Related to number of instances / cluster_zones in module.cluster
  backends = [
    { group = "${module.cluster.K8S_INSTANCE_GROUP_URLS[0]}" },
  ]
}

I have found that because of the data lookup within the module code, for the subnetwork name / self_link, this means that terraform always plans to recreate the forwawrding_rule.

Example (minus all the things that stay the same):

-/+ module.elastic.module.internal-lb.google_compute_forwarding_rule.default (new resource required)
      id:                                  "vpc-du-es-lb-internal" => <computed> (forces new resource)
      network:                             "https://www.googleapis.com/compute/v1/projects/sopost-infra-dev/global/networks/vpc-du" => "${data.google_compute_network.network.self_link}" (forces new resource)
      self_link:                           "https://www.googleapis.com/compute/v1/projects/sopost-infra-dev/regions/us-central1/forwardingRules/vpc-du-es-lb-internal" => <computed>
      service_name:                        "" => <computed>
      subnetwork:                          "https://www.googleapis.com/compute/v1/projects/sopost-infra-dev/regions/us-central1/subnetworks/elastic-sub" => "${data.google_compute_subnetwork.network.self_link}" (forces new resource)

Normally not an issue, but its not the quickest of actions to perform on google cloud, however I can see why you've done it that way (less inputs).

I happen to be wrapping this module and passing the the subnetwork to ensure everything is created in a specific subnetwork, but I get the same result when I hard code the value of subnetwork for the input.

Not sure how this is avoidable currently without taking the data lookups out and passing the value explicitly. Unless I am missing something?

@aaron-lane aaron-lane added the bug Something isn't working label Sep 19, 2019
@paulpalamarchuk paulpalamarchuk self-assigned this Oct 23, 2019
@paulpalamarchuk
Copy link

The bug is not reproducible on TF0.12 (based on PR)
Test conf:

module "gce-ilb" {
  source       = "../../"
  region       = var.region
  name         = "group-ilb"
  project      = var.project
  network      = "cft-gke-test-jpuo" //local.network
  subnetwork   = data.google_compute_subnetwork.link.name
  ports        = [local.named_ports[0].port]
  source_tags  = local.source_tags
  target_tags  = local.target_tags
  health_check = local.health_check

  backends = [
    {
      group = "https://www.googleapis.com/compute/v1/projects/.../regions/us-central1/instanceGroups/mig2-mig"
    },
    {
      group = "https://www.googleapis.com/compute/v1/projects/.../regions/us-central1/instanceGroups/mig3-mig"
    },
  ]
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants