There is a limitation where the value of vpc_name cannot be a value that is known after apply. Meaning you cannot use the output from a VPC module or you get this:
Error: Invalid for_each argument
│
│ on .terraform/modules/vpes/main.tf line 69, in resource "ibm_is_subnet_reserved_ip" "ip":
│ 69: for_each = {
│ 70: # Create a map based on endpoint IP name
│ 71: for gateway_ip in local.endpoint_ip_list :
│ 72: (gateway_ip.ip_name) => gateway_ip
│ 73: }
│ ├────────────────
│ │ local.endpoint_ip_list is tuple with 2 elements
│
│ The "for_each" map includes keys derived from resource attributes that cannot be determined until apply, and so Terraform cannot determine the full set of keys that
│ will identify the instances of this resource.
│
│ When working with unknown values in for_each, it's better to define the map keys statically in your configuration and place apply-time results only in the map values.
│
│ Alternatively, you could use the -target planning option to first apply only the resources that the for_each value depends on, and then apply a second time to fully
│ converge.
╵
╷
│ Error: Invalid for_each argument
│
│ on .terraform/modules/vpes/main.tf line 85, in resource "ibm_is_virtual_endpoint_gateway" "vpe":
│ 85: for_each = { # Create a map based on gateway name
│ 86: for gateway in local.gateway_list :
│ 87: (gateway.name) => gateway
│ 88: }
│ ├────────────────
│ │ local.gateway_list is tuple with 2 elements
│
│ The "for_each" map includes keys derived from resource attributes that cannot be determined until apply, and so Terraform cannot determine the full set of keys that
│ will identify the instances of this resource.
│
│ When working with unknown values in for_each, it's better to define the map keys statically in your configuration and place apply-time results only in the map values.
│
│ Alternatively, you could use the -target planning option to first apply only the resources that the for_each value depends on, and then apply a second time to fully
│ converge.
The vpc_name is only actually used for VPE naming, so it doesn't have to be the actual name of the VPC. We should at the very least make that clear in the variable description, and that it cant be a value that is only known after apply
There is a limitation where the value of
vpc_name
cannot be a value that is known after apply. Meaning you cannot use the output from a VPC module or you get this:The
vpc_name
is only actually used for VPE naming, so it doesn't have to be the actual name of the VPC. We should at the very least make that clear in the variable description, and that it cant be a value that is only known after apply