Skip to content

incompatible with computed resource names #620

@bartekmo

Description

@bartekmo

It is not possible to use the module in combination with resource names generated during the apply phase (eg. with random suffixes commonly added for temporary or testing environments). The problem applies to several submodules (eg. subnets and firewall-rules).

example braking code snippet:

resource "random_string" "suffix" {}

module "vpn" {
[...]
subnets = [{
  subnet_name = "subnet1-${random_string.suffix.result}"
}]
}

The core reason for the problem is using resource names for index in for_each loop. Terraform needs to determine the number and identifiers of all resources before planning. Using name as index means that the resource identifier in the example code would be

google_compute_subnetwork.subnetwork["subnet1-${random_string.suffix.result}"]

which is obviously not known before plan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions