Resource: aws_autoscaling_group_tag

Manages an individual Autoscaling Group (ASG) tag. This resource should only be used in cases where ASGs are created outside Terraform (e.g., ASGs implicitly created by EKS Node Groups).

Example Usage

resource "aws_eks_node_group" "example" {
  cluster_name    = "example"
  node_group_name = "example"

  # ... other configuration ...
}

resource "aws_autoscaling_group_tag" "example" {
  for_each = toset(
    [for asg in flatten(
      [for resources in aws_eks_node_group.example.resources : resources.autoscaling_groups]
    ) : asg.name]
  )

  autoscaling_group_name = each.value

  tag {
    key   = "k8s.io/cluster-autoscaler/node-template/label/eks.amazonaws.com/capacityType"
    value = "SPOT"

    propagate_at_launch = false
  }
}

Argument Reference

This resource supports the following arguments:

The tag block supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import aws_autoscaling_group_tag using the ASG name and key, separated by a comma (,). For example:

import {
  to = aws_autoscaling_group_tag.example
  id = "asg-example,k8s.io/cluster-autoscaler/node-template/label/eks.amazonaws.com/capacityType"
}

Using terraform import, import aws_autoscaling_group_tag using the ASG name and key, separated by a comma (,). For example:

% terraform import aws_autoscaling_group_tag.example asg-example,k8s.io/cluster-autoscaler/node-template/label/eks.amazonaws.com/capacityType