jenkins-x / terraform-aws-eks-jx

A Terraform module for creating Jenkins X infrastructure on AWS
Apache License 2.0
63 stars 42 forks source link

Additional_tags don't apply #318

Open rupertgti opened 2 years ago

rupertgti commented 2 years ago

Summary

I want to put some additional tags in my ec2 custom node groups. I think the terraform plan show the correct changes but in the "reality" in AWS the module don't apply the custom tags and the result is the default tags of module

Terraform plan:

module.eks-jx.module.cluster.module.eks.module.node_groups.aws_eks_node_group.workers["custom-nodes"] will be created
  + resource "aws_eks_node_group" "workers" {
      + ami_type               = "AL2_x86_64"
      + arn                    = (known after apply)
      + capacity_type          = (known after apply)
      + cluster_name           = "my-cluster-name"
      + disk_size              = 150
      + id                     = (known after apply)
      + instance_types         = [
          + "m5.2xlarge",
        ]
      + labels                 = {
          + "instancegroup"           = "custom-nodes"
          + "jenkins-x.io/managed-by" = "terraform"
          + "jenkins-x.io/name"       = "my-cluster-name"
          + "jenkins-x.io/part-of"    = "jx-platform"
        }
      + node_group_name        = (known after apply)
      + node_group_name_prefix = "my-cluster-name-custom-nodes"
      + node_role_arn          = "arn:aws:iam::account:role/my-cluster-name20211021102140086300000015"
      + release_version        = (known after apply)
      + resources              = (known after apply)
      + status                 = (known after apply)
      + subnet_ids             = [
          + "subnet-xxxxx",
          + "subnet-xxxxx",
          + "subnet-xxxxx",
        ]
      + tags                   = {
          + "Name"        = "my-cluster-name-custom-nodes"
          + "environment" = "tag1"
          + "project"     = "tag2"
          + "resource"    = "tag3"
          + "service"     = "tag4"
        }
      + tags_all               = {
          + "Name"        = "my-cluster-name-custom-nodes"
          + "environment" = "tag1"
          + "project"     = "tag2"
          + "resource"    = "tag3"
          + "service"     = "tag4"

I add this in main.tf of module "eks-jx" {:

  node_groups_managed = {
    custom-nodes = {
      ami_type                = "AL2_x86_64"
      disk_size               = 150
      desired_capacity        = 1
      max_capacity            = 50
      min_capacity            = 1
      instance_types          = [ "r5.2xlarge" ]
      k8s_labels = {
        instancegroup = "custom-nodes"
      }
      additional_tags = {
        service = "tag1"
        Name = "my-cluster-name-custom-nodes"
        project = "tag2"
        environment = "tag3"
        resource = "tag4"
      }
    }

the results in AWS Auto Scaling groups tags:

image

And my ec2 instances don't have the tags :(

Steps to reproduce the behavior

terraform plan and terraform apply

Terraform version

The output of terraform version is:

Terraform v0.13.7

Module version

1.16.1

Operating system

WSL2

ankitm123 commented 2 years ago

~I will take a deeper look at this tonight, but most likely this is happening because u dont have propagate at launch set to true. Try PropagateAtLaunch=true and see if that fixes it. See: https://docs.aws.amazon.com/autoscaling/ec2/userguide/autoscaling-tagging.html#add-tags~

Well, I see u have tag new instances set to true, so what I said before is not correct, will look.

ankitm123 commented 2 years ago

Looking at this a bit more, it's related to this: https://github.com/terraform-aws-modules/terraform-aws-eks/issues/860 which seems to be an AWS issue.

rupertgti commented 2 years ago

Thank you @ankitm123 for link to the main issue. But if it's an old problem, is it not possible to apply the workaround in the process: https://github.com/terraform-aws-modules/terraform-aws-eks/issues/860#issuecomment-632705746?

ankitm123 commented 2 years ago

But if it's an old problem, is it not possible to apply the workaround in the process: terraform-aws-modules/terraform-aws-eks#860 (comment)?

If you want to open a PR and fix it, I would be happy to review it :)

rupertgti commented 2 years ago

I 'll try it

ankitm123 commented 2 years ago

We are participating in hacktoberfest also :grimacing: