Tag class

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

> NOTE: This tagging resource should not be combined with the resource for managing the parent resource. For example, using aws.autoscaling.Group and aws.autoscaling.Tag to manage tags of the same ASG will cause a perpetual difference where the aws.autoscaling.Group resource will try to remove the tag being added by the aws.autoscaling.Tag resource.

> NOTE: This tagging resource does not use the provider ignoreTags configuration.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as std from "@pulumi/std";

const example = new aws.eks.NodeGroup("example", {
    clusterName: "example",
    nodeGroupName: "example",
});
const exampleTag: {[key: string]: aws.autoscaling.Tag} = {};
std.flattenOutput({
    input: example.resources.apply(resources => resources.map(resources => (resources.autoscalingGroups))),
}).apply(invoke => {
    for (const range of Object.entries(.map(asg => (asg.name)).reduce((__obj, entry) => ({ ...__obj, [String(entry)]: entry }), {})).sort().map(([k, v]) => ({key: k, value: v}))) {
        exampleTag[range.key] = new aws.autoscaling.Tag(`example-${range.key}`, {
            tag: {
                key: "k8s.io/cluster-autoscaler/node-template/label/eks.amazonaws.com/capacityType",
                value: "SPOT",
                propagateAtLaunch: false,
            },
            autoscalingGroupName: range.value,
        });
    }
});
import pulumi
from typing import Any
import pulumi_aws as aws
import pulumi_std as std

example = aws.eks.NodeGroup("example",
    cluster_name="example",
    node_group_name="example")
example_tag: dict[str, aws.autoscaling.Tag] = {}
def create_example(range_body):
    for example_tag_range in [{"key": k, "value": v} for [k, v] in sorted((range_body).items())]:
        example_tag[example_tag_range['key']] = aws.autoscaling.Tag(f"example-{example_tag_range['key']}",
            tag={
                "key": "k8s.io/cluster-autoscaler/node-template/label/eks.amazonaws.com/capacityType",
                "value": "SPOT",
                "propagate_at_launch": False,
            },
            autoscaling_group_name=example_tag_range["value"])

std.flatten_output(input=example.resources.apply(lambda resources: [resources.autoscaling_groups for resources in resources])).apply(lambda resolved_outputs: create_example({str(entry): entry for entry in [asg["name"] for asg in resolved_outputs['invoke'].result]}))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Std = Pulumi.Std;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.Eks.NodeGroup("example", new()
    {
        ClusterName = "example",
        NodeGroupName = "example",
    });

    var exampleTag = new List<Aws.AutoScaling.Tag>();
    foreach (var range in Std.Flatten.Invoke(new()
    {
        Input = example.Resources.Apply(resources => resources.Select(resources =>
        {
            return resources.AutoscalingGroups;
        }).ToList()),
    }).Apply(invoke => .Select(asg =>
    {
        return asg.Name;
    }).ToList().ToDictionary(item => {
        var entry = item.Value;
        return entry;
    }, item => {
        var entry = item.Value;
        return entry;
    })).Select(pair => new { pair.Key, pair.Value }))
    {
        exampleTag.Add(new Aws.AutoScaling.Tag($"example-{range.Key}", new()
        {
            TagDetails = new Aws.AutoScaling.Inputs.TagTagArgs
            {
                Key = "k8s.io/cluster-autoscaler/node-template/label/eks.amazonaws.com/capacityType",
                Value = "SPOT",
                PropagateAtLaunch = false,
            },
            AutoscalingGroupName = range.Value,
        }));
    }
});
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
    std = {
      source = "pulumi/std"
    }
  }
}

resource "aws_eks_nodegroup" "example" {
  cluster_name    = "example"
  node_group_name = "example"
}
resource "aws_autoscaling_tag" "example" {
  for_each = {for entry in [for asg in flatten([for resources in aws_eks_nodegroup.example.resources : resources.autoscalingGroups]) : asg.name] : entry => entry}
  tag = {
    key                 = "k8s.io/cluster-autoscaler/node-template/label/eks.amazonaws.com/capacityType"
    value               = "SPOT"
    propagate_at_launch = false
  }
  autoscaling_group_name = each.value
}
resources:
  example:
    type: aws:eks:NodeGroup
    properties:
      clusterName: example
      nodeGroupName: example
  exampleTag:
    type: aws:autoscaling:Tag
    name: example
    properties:
      tag:
        key: k8s.io/cluster-autoscaler/node-template/label/eks.amazonaws.com/capacityType
        value: SPOT
        propagateAtLaunch: false
      autoscalingGroupName: ${range.value}
    options: {}

Import

Using pulumi import, import aws.autoscaling.Tag using the ASG name and key, separated by a comma (,). For example:

$ pulumi import aws:autoscaling/tag:Tag example asg-example,k8s.io/cluster-autoscaler/node-template/label/eks.amazonaws.com/capacityType

Constructors

Tag(String name, {TagArgs? args, CustomResourceOptions? options})
Creates a new Tag. name The Pulumi resource name. args Arguments used to configure this Tag. The set of arguments for Tag. options Resource options controlling this resource's behavior.
Tag.reference(String urn)
Creates a typed reference to an existing Tag resource.

Properties

autoscalingGroupName ↔ Output<String>
Name of the Autoscaling Group to apply the tag to.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tag ↔ Output<TagTag>
Tag to create. The tag block is documented below.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {TagState? state, CustomResourceOptions? options}) → Tag
Gets an existing Tag resource's state with the given name and id.