hashicorp / boundary-reference-architecture

Example reference architecture for a high availability Boundary deployment on AWS.
https://boundaryproject.io
Mozilla Public License 2.0
213 stars 105 forks source link

destroy error var.target_ips is set of string with 1 element #55

Closed pilasguru closed 3 years ago

pilasguru commented 3 years ago

Trying to destroy I receive this error:

│ Error: Invalid for_each argument
│
│   on boundary/hosts.tf line 9, in resource "boundary_host" "backend_servers":
│    9:   for_each        = var.target_ips
│     ├────────────────
│     │ var.target_ips is set of string with 1 element
│
│ The "for_each" 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
│ for_each depends on.

boundary/vars.tf

variable "target_ips" {
  type    = set(string)
  default = []
}

boundary/hosts.tf

resource "boundary_host" "backend_servers" {
  for_each        = var.target_ips
  type            = "static"
  name            = "backend_server_${each.value}"
  description     = "Backend server #${each.value}"
  address         = each.key
  host_catalog_id = boundary_host_catalog.backend_servers.id
}

Do I need to configure something before destroy?

pilasguru commented 3 years ago

Solved with:

terraform destroy -target module.aws