Tag class

Manages an individual DynamoDB resource tag. This resource should only be used in cases where DynamoDB resources are created outside the provider (e.g., Table replicas in other regions).

> NOTE: This tagging resource should not be combined with the resource for managing the parent resource. For example, using aws.dynamodb.Table and aws.dynamodb.Tag to manage tags of the same DynamoDB Table in the same region will cause a perpetual difference where the aws.dynamodb.Table resource will try to remove the tag being added by the aws.dynamodb.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 replica = aws.getRegion({});
const current = aws.getRegion({});
const example = new aws.dynamodb.Table("example", {replicas: [{
    regionName: replica.then(replica => replica.region),
}]});
const test = new aws.dynamodb.Tag("test", {
    resourceArn: std.replaceOutput({
        text: example.arn,
        search: current.then(current => current.region),
        replace: replica.then(replica => replica.region),
    }).result,
    key: "testkey",
    value: "testvalue",
});
import pulumi
import pulumi_aws as aws
import pulumi_std as std

replica = aws.get_region()
current = aws.get_region()
example = aws.dynamodb.Table("example", replicas=[{
    "region_name": replica.region,
}])
test = aws.dynamodb.Tag("test",
    resource_arn=std.replace_output(text=example.arn,
        search=current.region,
        replace=replica.region).result,
    key="testkey",
    value="testvalue")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Std = Pulumi.Std;

return await Deployment.RunAsync(() =>
{
    var replica = Aws.GetRegion.Invoke();

    var current = Aws.GetRegion.Invoke();

    var example = new Aws.DynamoDB.Table("example", new()
    {
        Replicas = new[]
        {
            new Aws.DynamoDB.Inputs.TableReplicaArgs
            {
                RegionName = replica.Apply(getRegionResult => getRegionResult.Region),
            },
        },
    });

    var test = new Aws.DynamoDB.Tag("test", new()
    {
        ResourceArn = Std.Replace.Invoke(new()
        {
            Text = example.Arn,
            Search = current.Apply(getRegionResult => getRegionResult.Region),
            Replace = replica.Apply(getRegionResult => getRegionResult.Region),
        }).Apply(invoke => invoke.Result),
        Key = "testkey",
        Value = "testvalue",
    });

});
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		replica, err := aws.GetRegion(ctx, &aws.GetRegionArgs{}, nil)
		if err != nil {
			return err
		}
		current, err := aws.GetRegion(ctx, &aws.GetRegionArgs{}, nil)
		if err != nil {
			return err
		}
		example, err := dynamodb.NewTable(ctx, "example", &dynamodb.TableArgs{
			Replicas: dynamodb.TableReplicaTypeArray{
				&dynamodb.TableReplicaTypeArgs{
					RegionName: pulumi.String(replica.Region),
				},
			},
		})
		if err != nil {
			return err
		}
		_, err = dynamodb.NewTag(ctx, "test", &dynamodb.TagArgs{
			ResourceArn: std.ReplaceOutput(ctx, std.ReplaceOutputArgs{
				Text:    example.Arn,
				Search:  pulumi.String(current.Region),
				Replace: pulumi.String(replica.Region),
			}, nil).Result(),
			Key:   pulumi.String("testkey"),
			Value: pulumi.String("testvalue"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
    std = {
      source = "pulumi/std"
    }
  }
}

data "aws_getregion" "replica" {
}
data "aws_getregion" "current" {
}

resource "aws_dynamodb_table" "example" {
  replicas {
    region_name = data.aws_getregion.replica.region
  }
}
resource "aws_dynamodb_tag" "test" {
  resource_arn = replace(aws_dynamodb_table.example.arn, data.aws_getregion.current.region, data.aws_getregion.replica.region)
  key          = "testkey"
  value        = "testvalue"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetRegionArgs;
import com.pulumi.aws.dynamodb.Table;
import com.pulumi.aws.dynamodb.TableArgs;
import com.pulumi.aws.dynamodb.inputs.TableReplicaArgs;
import com.pulumi.aws.dynamodb.Tag;
import com.pulumi.aws.dynamodb.TagArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.ReplaceArgs;
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 replica = AwsFunctions.getRegion(GetRegionArgs.builder()
            .build());

        final var current = AwsFunctions.getRegion(GetRegionArgs.builder()
            .build());

        var example = new Table("example", TableArgs.builder()
            .replicas(TableReplicaArgs.builder()
                .regionName(replica.region())
                .build())
            .build());

        var test = new Tag("test", TagArgs.builder()
            .resourceArn(StdFunctions.replace(ReplaceArgs.builder()
                .text(example.arn())
                .search(current.region())
                .replace(replica.region())
                .build()).applyValue(_invoke -> _invoke.result()))
            .key("testkey")
            .value("testvalue")
            .build());

    }
}
resources:
  example:
    type: aws:dynamodb:Table
    properties:
      replicas:
        - regionName: ${replica.region}
  test:
    type: aws:dynamodb:Tag
    properties:
      resourceArn:
        fn::invoke:
          function: std:replace
          arguments:
            text: ${example.arn}
            search: ${current.region}
            replace: ${replica.region}
          return: result
      key: testkey
      value: testvalue
variables:
  replica:
    fn::invoke:
      function: aws:getRegion
      arguments: {}
  current:
    fn::invoke:
      function: aws:getRegion
      arguments: {}

Import

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

$ pulumi import aws:dynamodb/tag:Tag example arn:aws:dynamodb:us-east-1:123456789012:table/example,Name

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
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceArn ↔ Output<String>
ARN of the DynamoDB 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.