diff --git a/README.md b/README.md index b63ab8d..4bd6e40 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ No modules. | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source | | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | | [aws_route_table.selected](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route_table) | data source | -| [aws_subnet_ids.selected](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | data source | +| [aws_subnets.selected](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnets) | data source | | [aws_vpc.selected](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source | ## Inputs diff --git a/vpce.tf b/vpce.tf index 69f35cf..756a5e3 100644 --- a/vpce.tf +++ b/vpce.tf @@ -1,11 +1,14 @@ locals { region = var.vpc_endpoints_enabled && var.vpc_id != null ? split(":", data.aws_vpc.selected[0].arn)[3] : data.aws_region.current.name - subnets = var.vpc_endpoints_enabled ? var.subnet_ids != [] ? var.subnet_ids : data.aws_subnet_ids.selected[0].ids : [] + subnets = var.vpc_endpoints_enabled ? var.subnet_ids != [] ? var.subnet_ids : data.aws_subnets.selected[0].ids : [] } -data "aws_subnet_ids" "selected" { - count = var.vpc_endpoints_enabled ? 1 : 0 - vpc_id = var.vpc_id +data "aws_subnets" "selected" { + count = var.vpc_endpoints_enabled ? 1 : 0 + filter { + name = "vpc-id" + values = [var.vpc_id] + } } data "aws_route_table" "selected" {