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

count doesn't iterate in subblocks under the resource #10182

Closed
cblecker opened this issue Nov 17, 2016 · 5 comments
Closed

count doesn't iterate in subblocks under the resource #10182

cblecker opened this issue Nov 17, 2016 · 5 comments

Comments

@cblecker
Copy link
Contributor

Terraform Version

Terraform v0.7.11

Affected Resource(s)

  • Tested with google_compute_backend_service, but may affect others

Terraform Configuration Files

resource "google_compute_backend_service" "backend-service" {
  name        = "backend-service"
  port_name   = "port${var.svc_port}"
  protocol    = "HTTP"
  timeout_sec = 10

  backend {
    count = "${length(var.instance_groups)}"
    group = "https://www.googleapis.com/compute/v1/projects/${var.project_name}/zones/${lookup(var.instance_groups_regions, "${var.instance_groups[count.index]}")}/instanceGroups/${var.instance_groups[count.index]}"
  }

  health_checks = ["${google_compute_http_health_check.http-health-check.self_link}"]
}

Expected Behavior

Terraform would have expanded and created multiple backend blocks inside the google_compute_backend_service resource.

Actual Behavior

* google_compute_backend_service.backend-service: backend.0: invalid or unknown key: count

Important Factoids

This may not be intended functionality, but does have useful possibilities for resources with multiple of a subblock.

@hydroxide
Copy link

Chiming in because I have already encountered several cases where this would prove useful.

  • aws_instance - Conditionally declaring ebs_block_devices and ephemeral_block_devices depending on instance type
  • aws_elb - Conditionally declare listeners based on environment (dev, stage, prod)

@davewalter
Copy link
Contributor

We also encountered this when attempting to add a variable number of backends to a backend_service.

@zachgersh
Copy link
Contributor

zachgersh commented Dec 22, 2016

@jbardin - would love to actually implement this. Trying to figure out what level to implement this at and it would seem that it belongs in the schema package but I want to double check.

Other assumption, we would follow the same sort of API that count has on a resource. So, that you would get backend.0..backend.n.

@mitchellh
Copy link
Contributor

Going to close this as a dup of #7034! Same idea.

@ghost
Copy link

ghost commented Apr 17, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

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

No branches or pull requests

6 participants