Terraform-aws-eks: Don't want to use a EKS cluster name for the name_prefix of Auto Scaling Group

Created on 4 Aug 2019  路  12Comments  路  Source: terraform-aws-modules/terraform-aws-eks

I have issues

The Auto Scaling Group name_prefix uses the EKS cluster name.

https://github.com/terraform-aws-modules/terraform-aws-eks/blob/6ea3582940c0312b5031c8c9c8dafb1e86a98ceb/workers.tf#L5

In this case, there are the following problems.

For example, when replacing the Auto Scaling Group with Blue-Green Deployment, use the name parameter to specify blue orgreen.

module "eks" {
  source                 = "terraform-aws-modules/eks/aws"
  cluster_name           = "staging"
  ...

  worker_groups = [
    {
      name                          = "blue"
      ...
    },
    {
      name                          = "green"
      ...
    },
  ]
}

If you also want EKS clusters to be Blue-Green Deployment, add -blue or-green to cluster_name parameter.

module "eks" {
  source                 = "terraform-aws-modules/eks/aws"
  cluster_name           = "staging-blue"
  ...

  worker_groups = [
    {
      name                          = "blue"
      ...
    },
    {
      name                          = "green"
      ...
    },
  ]
}

module "eks" {
  source                 = "terraform-aws-modules/eks/aws"
  cluster_name           = "staging-green"
  ...

  worker_groups = [
    {
      name = "blue"
      ...
    },
    {
      name = "green"
      ...
    },
  ]
}

As a result, the Auto Scaling Group's name_prefix parameter will have a duplicate blue, such asstaging-blue-blue-.

I'm submitting a...

  • [ ] bug report
  • [x] feature request
  • [x] support request
  • [ ] kudos, thank you, warm fuzzy

What's the expected behavior?

For example, how about adding a parameter that can specify an arbitrary name prefix instead of ${aws_eks_cluster.this.name}.

diff --git a/workers.tf b/workers.tf
index c50e1bc..54967a2 100644
--- a/workers.tf
+++ b/workers.tf
@@ -2,7 +2,7 @@

 resource "aws_autoscaling_group" "workers" {
   count       = local.worker_group_count
-  name_prefix = "${aws_eks_cluster.this.name}-${lookup(var.worker_groups[count.index], "name", count.index)}"
+  name_prefix = "${lookup(var.worker_groups[count.index], "name_prefix", aws_eks_cluster.this.name)}-${lookup(var.worker_groups[count.index], "name", count.index)}"
   desired_capacity = lookup(
     var.worker_groups[count.index],
     "asg_desired_capacity",

However, I do not think that the variable name name_prefix is easy to understand.

I can not think of good parameter names.

Or is there any better way?

Are you able to fix this problem and submit a PR? Link here if you have already.

I have not made a PR yet.

Environment details

  • Affected module version: v5.1.0
  • OS: any
  • Terraform version: any

Any other relevant info

none

stale

All 12 comments

I don't really like the name_prefix solution either but changing is a large breaking change as it requires all resources to be recreated. This makes the upgrade path difficult.

Please add your voice to https://github.com/terraform-aws-modules/terraform-aws-eks/issues/88

@max-rocket-internet

This issue is not a problem using name_prefix. The problem is that $ {aws_eks_cluster.this.name} used in name_prefix cannot be changed.

Therefore, I think that the purpose is different from Issue https://github.com/terraform-aws-modules/terraform-aws-eks/issues/88.

@tsub very sorry, I think wasn't paying close enough attention. Reopening!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because it has not had recent activity since being marked as stale.

Let's keep this issue open. I am going to get back to #709 this or next week and fix it.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because it has not had recent activity since being marked as stale.

Was there ever any follow up to this issue? It seems to have been closed without being solved :-)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because it has not had recent activity since being marked as stale.

nobody follow?

Was this page helpful?
0 / 5 - 0 ratings