Skip to content

Commit 507193e

Browse files
feat: Add support for subnet_configuration on VPC endpoints (#1164)
feat: Support subnet_configuration in aws_vpc_endpoint resource Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
1 parent 52de296 commit 507193e

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

examples/complete/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ module "vpc_endpoints" {
122122
service = "ecs"
123123
private_dns_enabled = true
124124
subnet_ids = module.vpc.private_subnets
125+
subnet_configurations = [
126+
for v in module.vpc.private_subnet_objects :
127+
{
128+
ipv4 = cidrhost(v.cidr_block, 10)
129+
subnet_id = v.id
130+
}
131+
]
125132
},
126133
ecs_telemetry = {
127134
create = false

modules/vpc-endpoints/README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,19 @@ module "endpoints" {
2626
tags = { Name = "dynamodb-vpc-endpoint" }
2727
},
2828
sns = {
29-
service = "sns"
30-
subnet_ids = ["subnet-12345678", "subnet-87654321"]
31-
tags = { Name = "sns-vpc-endpoint" }
29+
service = "sns"
30+
subnet_ids = ["subnet-12345678", "subnet-87654321"]
31+
subnet_configurations = [
32+
{
33+
ipv4 = "10.8.34.10"
34+
subnet_id = "subnet-12345678"
35+
},
36+
{
37+
ipv4 = "10.8.35.10"
38+
subnet_id = "subnet-87654321"
39+
}
40+
]
41+
tags = { Name = "sns-vpc-endpoint" }
3242
},
3343
sqs = {
3444
service = "sqs"

modules/vpc-endpoints/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ resource "aws_vpc_endpoint" "this" {
4646
}
4747
}
4848

49+
dynamic "subnet_configuration" {
50+
for_each = try(each.value.subnet_configurations, [])
51+
52+
content {
53+
ipv4 = try(subnet_configuration.value.ipv4, null)
54+
ipv6 = try(subnet_configuration.value.ipv6, null)
55+
subnet_id = try(subnet_configuration.value.subnet_id, null)
56+
}
57+
}
58+
4959
tags = merge(
5060
var.tags,
5161
{ "Name" = replace(each.key, ".", "-") },

0 commit comments

Comments
 (0)