Skip to content

Commit

Permalink
allow name and name_prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
barryib committed May 19, 2021
1 parent 71d234d commit 7f11929
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion modules/node_groups/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ The role ARN specified in `var.default_iam_role_arn` will be used by default. In
| launch\_template_version | The version of the LT to use | string | none |
| max\_capacity | Max number of workers | number | `var.workers_group_defaults[asg_max_size]` |
| min\_capacity | Min number of workers | number | `var.workers_group_defaults[asg_min_size]` |
| name | Name of the node group | string | Auto generated |
| name | Name of the node group | string | Will use autogenerate name prefix |
| name_prefix | Name prefix of the node group | string | Auto generated |
| source\_security\_group\_ids | Source security groups for remote access to workers | list(string) | If key\_name is specified: THE REMOTE ACCESS WILL BE OPENED TO THE WORLD |
| subnets | Subnets to contain workers | list(string) | `var.workers_group_defaults[subnets]` |
| version | Kubernetes version | string | Provider default behavior |
Expand Down
3 changes: 2 additions & 1 deletion modules/node_groups/launchtemplate.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ data "cloudinit_config" "workers_userdata" {
# Trivia: AWS transparently creates a copy of your LaunchTemplate and actually uses that copy then for the node group. If you DONT use a custom AMI,
# then the default user-data for bootstrapping a cluster is merged in the copy.
resource "aws_launch_template" "workers" {
for_each = { for k, v in local.node_groups_expanded : k => v if v["create_launch_template"] }
for_each = { for k, v in local.node_groups_expanded : k => v if v["create_launch_template"] }

name_prefix = lookup(each.value, "name", join("-", [var.cluster_name, each.key]))
description = lookup(each.value, "name", join("-", [var.cluster_name, each.key]))
update_default_version = true
Expand Down
10 changes: 6 additions & 4 deletions modules/node_groups/node_groups.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
resource "aws_eks_node_group" "workers" {
for_each = local.node_groups_expanded

node_group_name_prefix = lookup(each.value, "name", join("-", [var.cluster_name, each.key]))
cluster_name = var.cluster_name
node_role_arn = each.value["iam_role_arn"]
subnet_ids = each.value["subnets"]
node_group_name_prefix = lookup(each.value, "name", null) == null ? lookup(each.value, "name_prefix", join("-", [var.cluster_name, each.key])) : null
node_group_name = lookup(each.value, "name", null)

cluster_name = var.cluster_name
node_role_arn = each.value["iam_role_arn"]
subnet_ids = each.value["subnets"]

scaling_config {
desired_size = each.value["desired_capacity"]
Expand Down

0 comments on commit 7f11929

Please sign in to comment.