-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a module for ASG tagging at 03-kubernetes-initialize/aws-asg-tagg…
…ing.
- Loading branch information
Prashant Tiwari
committed
Jan 7, 2024
1 parent
7996faa
commit 7c9f6ec
Showing
4 changed files
with
54 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/_nebari/stages/kubernetes_initialize/template/modules/tagging/aws-asg-tagging.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
data "aws_eks_node_group" "user" { | ||
cluster_name = var.cluster_name | ||
node_group_name = "user" | ||
} | ||
|
||
resource "aws_autoscaling_group_tag" "dedicated_user" { | ||
for_each = toset( | ||
[for asg in flatten( | ||
[for resources in data.aws_eks_node_group.user.resources : resources.autoscaling_groups] | ||
) : asg.name] | ||
) | ||
|
||
autoscaling_group_name = each.value | ||
tag { | ||
key = "k8s.io/cluster-autoscaler/node-template/label/dedicated" | ||
value = "user" | ||
propagate_at_launch = true | ||
} | ||
depends_on = [ | ||
data.aws_eks_node_group.user | ||
] | ||
} | ||
|
||
data "aws_eks_node_group" "worker" { | ||
cluster_name = var.cluster_name | ||
node_group_name = "worker" | ||
} | ||
|
||
resource "aws_autoscaling_group_tag" "dedicated_worker" { | ||
for_each = toset( | ||
[for asg in flatten( | ||
[for resources in data.aws_eks_node_group.worker.resources : resources.autoscaling_groups] | ||
) : asg.name] | ||
) | ||
autoscaling_group_name = each.value | ||
tag { | ||
key = "k8s.io/cluster-autoscaler/node-template/label/dedicated" | ||
value = "worker" | ||
propagate_at_launch = true | ||
} | ||
depends_on = [ | ||
data.aws_eks_node_group.worker, | ||
] | ||
} |
4 changes: 4 additions & 0 deletions
4
src/_nebari/stages/kubernetes_initialize/template/modules/tagging/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
variable "cluster_name" { | ||
description = "Name of the cluster." | ||
type = string | ||
} |