Skip to content

Commit

Permalink
Allow to add custom tags to subnets, and fix Public tag (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonincms authored Sep 5, 2024
1 parent 6345c6f commit 0ed5bb9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ resource "aws_subnet" "quortex" {
tags = merge(
{
"Name" = "${var.subnet_name_prefix}${each.key}",
"Public" = "true",
"Public" = tostring(each.value.public),
"kubernetes.io/cluster/${var.cluster_name}" = "shared",
},
each.value.public ? {
"kubernetes.io/role/elb" = "1" # tagged so that Kubernetes knows to use only those subnets for external load balancers
} : {
"kubernetes.io/role/internal-elb" = "1"
},
var.tags
var.tags,
each.value.tags
)

depends_on = [aws_vpc_ipv4_cidr_block_association.secondary]
Expand Down
6 changes: 3 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ variable "vpc_cidr_block" {
}

variable "subnets" {
type = map(object({ availability_zone = string, cidr = string, public = bool }))
type = map(object({ availability_zone = string, cidr = string, public = bool, tags = optional(map(string), {}) }))
description = <<EOT
A map representing the subnets that need to be created. Each item should
specify the subnet's Availability Zone, cidr block, and whether the subnet
should be public or not.
specify the subnet's Availability Zone, cidr block, whether the subnet
should be public or not and optionally extra tags to add.
EOT
}

Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

terraform {
required_version = ">= 0.12"
required_version = ">= 1.3.0"

required_providers {
aws = {
Expand Down

0 comments on commit 0ed5bb9

Please sign in to comment.