-
-
Notifications
You must be signed in to change notification settings - Fork 199
Open
Labels
bug🐛 An issue with the system🐛 An issue with the system
Description
Describe the Bug
Only when trying to perform a terraform import I run into the following:
Error: Invalid for_each argument
│
│ on .terraform/modules/vpc_endpoints/modules/vpc-endpoints/main.tf line 72, in module "gateway_endpoint_label":
│ 72: for_each = local.enabled ? data.aws_vpc_endpoint_service.gateway_endpoint_service : {}
│ ├────────────────
│ │ data.aws_vpc_endpoint_service.gateway_endpoint_service will be known only after apply
│ │ local.enabled is true
│
│ 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.
My VPC endpoint does not contain a gateway_vpc_endpoints. I think this is because the module uses local.enabled for the existence of either a gateway or interface VPC endpoint rather than toggling them on individually. Or I'm doing it completely wrong. I'm doing:
module "vpc_endpoints" {
source = "cloudposse/vpc/aws//modules/vpc-endpoints"
version = "2.0.0"
context = module.vpc_endpoints_role_label.context
vpc_id = data.aws_vpc.vpc.id
gateway_vpc_endpoints = {}
interface_vpc_endpoints = {
"kinesis-streams" = {
name = "kinesis-streams"
security_group_ids = [module.dms_security_group.id]
subnet_ids = local.private_subnet_ids
policy = null
private_dns_enabled = true
}
}
}
Expected Behavior
No error on import
Steps to Reproduce
Steps to reproduce the behavior:
- Add some resource to import. I added
resource "aws_s3_bucket" "test_bucket" {bucket=test_name}. It doesn't even have to exist, you just need a resource to target terraform import aws_s3_bucket.test_bucket something-that-doesnt-exist-and-thats-ok
Environment (please complete the following information):
- TF version 1.1.7
- Module version 2.0.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug🐛 An issue with the system🐛 An issue with the system