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 using a data resource #21634

Closed
Lasering opened this issue Jun 6, 2019 · 1 comment
Closed

count using a data resource #21634

Lasering opened this issue Jun 6, 2019 · 1 comment

Comments

@Lasering
Copy link

Lasering commented Jun 6, 2019

I'm so sorry. This is working correctly. I didn't do all the correct tests before creating the issue. Please disregard it.

Terraform Version

Terraform v0.12.1

Terraform Configuration Files

variable "server" {
  type = string
  default = "google.com"
}

data "dns_aaaa_record_set" "server-ipv6" {
  host = var.server
}

resource "null_resource" "test" {
  count = length(data.dns_aaaa_record_set.server-ipv6.addrs)
  <some useful provisioner>
}

Expected Behavior

terraform plan should run successfully.

Actual Behavior

Error: Invalid count argument

  on main.tf line 11, in resource "null_resource" "test":
  11:   count = length(data.dns_aaaa_record_set.server-ipv6.addrs)

The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.

Steps to Reproduce

terraform init
terraform plan

Additional Context

It used to work under Terraform v0.12.0.

This comment also conveys the idea it should work.

Even using locals fails:

locals {
  server = "google.com"
}

data "dns_aaaa_record_set" "server-ipv6" {
  host = local.server
}

resource "null_resource" "test" {
  count = length(data.dns_aaaa_record_set.server-ipv6.addrs)
  <some useful provisioner>
}

Is this a regression or is it the intended behavior?

@Lasering Lasering closed this as completed Jun 6, 2019
@ghost
Copy link

ghost commented Jul 25, 2019

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 Jul 25, 2019
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

1 participant