Skip to content

Commit

Permalink
option for owned shared tag
Browse files Browse the repository at this point in the history
  • Loading branch information
arti-shalb committed Apr 9, 2021
1 parent b517059 commit 0650abf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions subnets_tagging/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
locals {
cluster_tag = var.shared_vpc ? "shared" : "owned"
}

data "aws_subnet" "public_subnet" {
count = length(var.public_subnets)
id = var.public_subnets[count.index]
Expand All @@ -7,7 +11,7 @@ resource "aws_ec2_tag" "public_subnet_tag_cluster" {
count = length(var.public_subnets)
resource_id = data.aws_subnet.public_subnet[count.index].id
key = "kubernetes.io/cluster/${var.cluster_name}"
value = "owned"
value = local.cluster_tag
}

resource "aws_ec2_tag" "public_subnet_tag_elb" {
Expand All @@ -26,7 +30,7 @@ resource "aws_ec2_tag" "private_subnet_tag_cluster" {
count = length(var.private_subnets)
resource_id = data.aws_subnet.private_subnet[count.index].id
key = "kubernetes.io/cluster/${var.cluster_name}"
value = "owned"
value = local.cluster_tag
}

resource "aws_ec2_tag" "private_subnet_tag_elb" {
Expand Down
5 changes: 5 additions & 0 deletions subnets_tagging/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ variable "public_subnets" {
variable "cluster_name" {
type = string
description = "k8s cluster name for tagging"
}

variable "shared_vpc" {
type = string
description = "set to true if there are more then one k8s cluster in vpc"
}

0 comments on commit 0650abf

Please sign in to comment.