Skip to content

Commit 7f883fa

Browse files
committed
feat: add rds subnet groups for intra subnets
1 parent 7c1f791 commit 7f883fa

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,22 @@ resource "aws_subnet" "intra" {
859859
)
860860
}
861861

862+
resource "aws_db_subnet_group" "intra" {
863+
count = local.create_intra_subnets && var.create_intra_subnet_group ? 1 : 0
864+
865+
name = lower(coalesce(var.intra_subnet_group_name, "${var.name}-intra"))
866+
description = "Intra subnet group for ${var.name}"
867+
subnet_ids = aws_subnet.intra[*].id
868+
869+
tags = merge(
870+
{
871+
"Name" = lower(coalesce(var.intra_subnet_group_name, "${var.name}-intra"))
872+
},
873+
var.tags,
874+
var.intra_subnet_group_tags,
875+
)
876+
}
877+
862878
locals {
863879
num_intra_route_tables = var.create_multiple_intra_route_tables ? local.len_intra_subnets : 1
864880
}

outputs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,17 @@ output "intra_network_acl_arn" {
505505
value = try(aws_network_acl.intra[0].arn, null)
506506
}
507507

508+
output "intra_subnet_group" {
509+
description = "ID of intra subnet group"
510+
value = try(aws_db_subnet_group.intra[0].id, null)
511+
}
512+
513+
output "intra_subnet_group_name" {
514+
description = "Name of intra subnet group"
515+
value = try(aws_db_subnet_group.intra[0].name, null)
516+
}
517+
518+
508519
################################################################################
509520
# NAT Gateway
510521
################################################################################

variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,24 @@ variable "intra_route_table_tags" {
992992
default = {}
993993
}
994994

995+
variable "create_intra_subnet_group" {
996+
description = "Controls if RDS subnet group should be created (n.b. intra_subnets must also be set)"
997+
type = bool
998+
default = true
999+
}
1000+
1001+
variable "intra_subnet_group_name" {
1002+
description = "Name of intra subnet group"
1003+
type = string
1004+
default = null
1005+
}
1006+
1007+
variable "intra_subnet_group_tags" {
1008+
description = "Additional tags for the intra subnet group"
1009+
type = map(string)
1010+
default = {}
1011+
}
1012+
9951013
################################################################################
9961014
# Intra Network ACLs
9971015
################################################################################

0 commit comments

Comments
 (0)