-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
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.
pvillaverde
Metadata
Metadata
Assignees
Labels
No labels