Skip to content

Commit e985555

Browse files
committed
feat: separate external public/private subnet ids
1 parent 1f8f286 commit e985555

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/main.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
locals {
22
enabled = module.this.enabled
33

4-
external_vpc_id = var.vpc_id != null ? { "ExternalVpcId" = var.vpc_id } : {}
5-
networking_stack = var.networking_stack != null ? { "NetworkingStack" = var.networking_stack } : {}
6-
subnet_ids = var.subnet_ids != null ? { "ExternalVpcSubnetIds" = join(",", var.subnet_ids) } : {}
4+
external_vpc_id = var.vpc_id != null ? { "ExternalVpcId" = var.vpc_id } : {}
5+
networking_stack = var.networking_stack != null ? { "NetworkingStack" = var.networking_stack } : {}
6+
subnet_ids = concat(coalesce(var.public_subnet_ids, []), coalesce(var.private_subnet_ids, []))
7+
external_vpc_subnet_ids = length(local.subnet_ids) > 0 ? { "ExternalVpcSubnetIds" = join(",", local.subnet_ids) } : {}
78
// If var.security_group_id is provided, we use it. Otherwise, if we are using the external networking stack, we create one.
89
external_security_group_id = var.security_group_id != null ? { "ExternalVpcSecurityGroupId" = var.security_group_id } : {}
910
// If var.security_group_id is not provided and we are using the external networking stack, we create one.
@@ -14,7 +15,7 @@ locals {
1415
}, var.parameters
1516
, local.networking_stack
1617
, local.external_vpc_id
17-
, local.subnet_ids
18+
, local.external_vpc_subnet_ids
1819
, local.external_security_group_id
1920
, local.created_security_group_id
2021
)
@@ -70,7 +71,7 @@ module "iam_policy" {
7071
]
7172
}
7273

73-
// Typically when runs-on is installed, and we're using the embedded networking stack, we need a security group.
74+
// Typically when runs-on is installed, and we're using the embedded networking stack, we need a security group.
7475
// This is a batties included optional feature.
7576
module "security_group" {
7677
source = "cloudposse/security-group/aws"

src/variables.tf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,16 @@ variable "vpc_id" {
5656
default = null
5757
}
5858

59-
variable "subnet_ids" {
59+
variable "public_subnet_ids" {
6060
type = list(string)
61-
description = "Subnet IDs"
61+
description = "Public subnet IDs"
62+
nullable = true
63+
default = null
64+
}
65+
66+
variable "private_subnet_ids" {
67+
type = list(string)
68+
description = "Private subnet IDs"
6269
nullable = true
6370
default = null
6471
}

0 commit comments

Comments
 (0)