hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.75k stars 9.11k forks source link

Launch Template - Network Interface Tags does not Propagate to AWS #24180

Open evairmarinho opened 2 years ago

evairmarinho commented 2 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

terraform-cli: 1.1.5 AWS provider: 3.74.1

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

Launch template state with parameter changes

resource "aws_launch_template" "workers" {
  default_version         = 1
  description             = "EKS Managed Node Group custom LT for XXX-YYY"
  disable_api_termination = false
  key_name                = "XXX-YYY"
  latest_version          = 1
  name                    = "XXX-YYY-G6336AA"
  name_prefix             = "XXX-YYY"
  security_group_names    = []
  tags = {
    "Environment"                           = "env"
    "IAC"                                   = "true"
    "k8s.io/cluster-autoscaler/eks-cluster" = "owned"
    "k8s.io/cluster-autoscaler/enabled"     = "TRUE"
  }
  tags_all = {
    "Environment"                           = "env"
    "IAC"                                   = "true"
    "k8s.io/cluster-autoscaler/eks-cluster" = "owned"
    "k8s.io/cluster-autoscaler/enabled"     = "TRUE"
  }
  update_default_version = true
  vpc_security_group_ids = []

  block_device_mappings {
    device_name = "/dev/xvda"

    ebs {
      delete_on_termination = "true"
      encrypted             = "true"
      iops                  = 0
      kms_key_id            = "arn:aws:kms:<region>:<account>:alias/aws/ebs"
      throughput            = 0
      volume_size           = 30
      volume_type           = "gp3"
    }
  }

  metadata_options {
    http_endpoint               = "enabled"
    http_protocol_ipv6          = "disabled"
    http_put_response_hop_limit = 0
    http_tokens                 = "optional"
    instance_metadata_tags      = "disabled"
  }

  monitoring {
    enabled = false
  }

  network_interfaces {
    associate_public_ip_address = "false"
    delete_on_termination       = "true"
    device_index                = 0
    ipv4_address_count          = 0
    ipv4_addresses              = []
    ipv6_address_count          = 0
    ipv6_addresses              = []
    network_card_index          = 0
    security_groups = [
      "sg-123456",
    ]
  }

  tag_specifications {
    resource_type = "instance"
    tags = {
      "Environment"                           = "env"
      "IAC"                                   = "true"
      "k8s.io/cluster-autoscaler/eks-cluster" = "owned"
      "k8s.io/cluster-autoscaler/enabled"     = "TRUE"
    }
  }
  tag_specifications {
    resource_type = "volume"
    tags = {
      "Environment"                           = "env"
      "IAC"                                   = "true"
      "k8s.io/cluster-autoscaler/eks-cluster" = "owned"
      "k8s.io/cluster-autoscaler/enabled"     = "TRUE"
    }
  }
  tag_specifications {
    resource_type = "network-interface"
    tags = {
      "Environment"                           = "env"
      "IAC"                                   = "true"
      "k8s.io/cluster-autoscaler/eks-cluster" = "owned"
      "k8s.io/cluster-autoscaler/enabled"     = "TRUE"
    }
  }
}

Debug Output

Panic Output

Expected Behavior

Tags should be propagated to Network Interafces (ENI) of EC2 Instances.

Actual Behavior

None tag are propagated to AWS in ENI.

Steps to Reproduce

Important Factoids

References

dpeper commented 2 years ago

I'm seeing the same with version 4.14.0 of the provider.

andre-lx commented 2 years ago

We have the same behaviour using the official Cloudformation.

Maybe is an AWS launch template issue?

alicancakil commented 2 years ago

I observed the same problem with version 4.21.0 of the provider. Is there any workaround?

natalicot commented 11 months ago

I have the same problem in 5.18.1 any workarounds?

mingduan64 commented 10 months ago

I think there's issue occuring with launch template, I tried to add resource tag for Network Interface on launch template and increase the node manually, ENI still unable to heriatge tags from launch template.