Terraform module to provision AWS Transit Gateway, AWS Resource Access Manager (AWS RAM) Resource, and share the Transit Gateway with the Organization or another AWS Account.
When var.config.*.subnet_route_table_ids is in the same state and has not yet been applied, the following occurs:
module.tgw_attachment.data.aws_ec2_transit_gateway.this[0]: Read complete after 0s [id=tgw-9435ccad528479164]
╷
│ Error: Invalid count argument
│
│ on .terraform/modules/tgw_attachment/modules/subnet_route/main.tf line 19, in resource "aws_route" "count":
│ 19: count = var.route_keys_enabled ? 0 : length(local.route_config_list)
│
│ 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.
╵
This also happens when var.route_keys_enabled is true:
module.tgw_attachment.data.aws_ec2_transit_gateway.this[0]: Read complete after 0s [id=tgw-9435ccad528479164]
╷
│ Error: Invalid for_each argument
│
│ on .terraform/modules/tgw_attachment/modules/subnet_route/main.tf line 8, in resource "aws_route" "keys":
│ 8: for_each = var.route_keys_enabled ? local.route_config_map : {}
│ ├────────────────
│ │ local.route_config_map will be known only after apply
│ │ var.route_keys_enabled is true
│
│ 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.
Expected Behavior
When var.subnet_route_table_ids derives from a value in the same state, creating a TGW attachment should still be possible.
This is coming from operations in the subnet_route submodule that are too complex on unknown values (namely setproduct()).
Found a bug? Maybe our Slack Community can help.
Describe the Bug
When
var.config.*.subnet_route_table_ids
is in the same state and has not yet been applied, the following occurs:This also happens when
var.route_keys_enabled
is true:Expected Behavior
When
var.subnet_route_table_ids
derives from a value in the same state, creating a TGW attachment should still be possible.This is coming from operations in the
subnet_route
submodule that are too complex on unknown values (namelysetproduct()
).https://github.com/cloudposse/terraform-aws-transit-gateway/blob/dc12987db8dbe740314e62acf51c804e69d19eb8/modules/subnet_route/main.tf#L3-L4
Steps to Reproduce
Steps to reproduce the behavior:
var.subnet_route_table_ids
terraform plan
Screenshots
If applicable, add screenshots or logs to help explain your problem.
Environment (please complete the following information):
Anything that will help us triage the bug will help. Here are some ideas:
v0.9.1
v1.3.4
Additional Context
Add any other context about the problem here.