Tag class

Manages an individual Organizations resource tag. This resource should only be used in cases where Organizations resources are created outside Terraform (e.g., Organizations Accounts implicitly created by AWS Control Tower).

> NOTE: This tagging resource should not be combined with the Terraform resource for managing the parent resource. For example, using aws.organizations.Account and aws.organizations.Tag to manage tags of the same Organizations account will cause a perpetual difference where the aws.organizations.Account resource will try to remove the tag being added by the aws.organizations.Tag resource. However, if the parent resource is created in the same configuration (i.e., if you have no other choice), you should add ignoreChanges = [tags] in the parent resource's lifecycle block. This ensures that Terraform ignores differences in tags managed via the separate tagging resource, avoiding the perpetual difference mentioned above.

> 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";

const example = aws.organizations.getOrganization({});
const exampleOrganizationalUnit = new aws.organizations.OrganizationalUnit("example", {
    name: "ExampleOU",
    parentId: example.then(example => example.roots?.[0]?.id),
}, {
    ignoreChanges: ["tags"],
});
const exampleTag = new aws.organizations.Tag("example", {
    resourceId: exampleOrganizationalUnit.id,
    key: "ExampleKey",
    value: "ExampleValue",
});
import pulumi
import pulumi_aws as aws

example = aws.organizations.get_organization()
example_organizational_unit = aws.organizations.OrganizationalUnit("example",
    name="ExampleOU",
    parent_id=example.roots[0].id,
    opts = pulumi.ResourceOptions(ignore_changes=["tags"]))
example_tag = aws.organizations.Tag("example",
    resource_id=example_organizational_unit.id,
    key="ExampleKey",
    value="ExampleValue")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = Aws.Organizations.GetOrganization.Invoke();

    var exampleOrganizationalUnit = new Aws.Organizations.OrganizationalUnit("example", new()
    {
        Name = "ExampleOU",
        ParentId = example.Apply(getOrganizationResult => getOrganizationResult.Roots[0]?.Id),
    }, new CustomResourceOptions
    {
        IgnoreChanges =
        {
            "tags",
        },
    });

    var exampleTag = new Aws.Organizations.Tag("example", new()
    {
        ResourceId = exampleOrganizationalUnit.Id,
        Key = "ExampleKey",
        Value = "ExampleValue",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/organizations"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := organizations.LookupOrganization(ctx, &organizations.LookupOrganizationArgs{}, nil)
		if err != nil {
			return err
		}
		exampleOrganizationalUnit, err := organizations.NewOrganizationalUnit(ctx, "example", &organizations.OrganizationalUnitArgs{
			Name:     pulumi.String("ExampleOU"),
			ParentId: pulumi.String(example.Roots[0].Id),
		}, pulumi.IgnoreChanges([]string{
			"tags",
		}))
		if err != nil {
			return err
		}
		_, err = organizations.NewTag(ctx, "example", &organizations.TagArgs{
			ResourceId: exampleOrganizationalUnit.ID().ToIDOutput().ToStringOutput(),
			Key:        pulumi.String("ExampleKey"),
			Value:      pulumi.String("ExampleValue"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_organizations_getorganization" "example" {
}

resource "aws_organizations_organizationalunit" "example" {
  lifecycle {
    ignore_changes = [tags]
  }
  name      = "ExampleOU"
  parent_id = data.aws_organizations_getorganization.example.roots[0].id
}
resource "aws_organizations_tag" "example" {
  resource_id = aws_organizations_organizationalunit.example.id
  key         = "ExampleKey"
  value       = "ExampleValue"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.organizations.OrganizationsFunctions;
import com.pulumi.aws.organizations.inputs.GetOrganizationArgs;
import com.pulumi.aws.organizations.OrganizationalUnit;
import com.pulumi.aws.organizations.OrganizationalUnitArgs;
import com.pulumi.aws.organizations.Tag;
import com.pulumi.aws.organizations.TagArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var example = OrganizationsFunctions.getOrganization(GetOrganizationArgs.builder()
            .build());

        var exampleOrganizationalUnit = new OrganizationalUnit("exampleOrganizationalUnit", OrganizationalUnitArgs.builder()
            .name("ExampleOU")
            .parentId(example.roots()[0].id())
            .build(), CustomResourceOptions.builder()
                .ignoreChanges("tags")
                .build());

        var exampleTag = new Tag("exampleTag", TagArgs.builder()
            .resourceId(exampleOrganizationalUnit.id())
            .key("ExampleKey")
            .value("ExampleValue")
            .build());

    }
}
resources:
  exampleOrganizationalUnit:
    type: aws:organizations:OrganizationalUnit
    name: example
    properties:
      name: ExampleOU
      parentId: ${example.roots[0].id}
    options:
      ignoreChanges:
        - tags
  exampleTag:
    type: aws:organizations:Tag
    name: example
    properties:
      resourceId: ${exampleOrganizationalUnit.id}
      key: ExampleKey
      value: ExampleValue
variables:
  example:
    fn::invoke:
      function: aws:organizations:getOrganization
      arguments: {}

Import

Using pulumi import, import aws.organizations.Tag using the Organizations resource identifier and key, separated by a comma (,). For example:

$ pulumi import aws:organizations/tag:Tag example ou-1234567,ExampleKey

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

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
key ↔ Output<String>
Tag name.
latefinal
resourceId ↔ Output<String>
Id of the Organizations resource to tag.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited
value ↔ Output<String>
Tag value.
latefinal

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.