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.Accountandaws.organizations.Tagto manage tags of the same Organizations account will cause a perpetual difference where theaws.organizations.Accountresource will try to remove the tag being added by theaws.organizations.Tagresource. However, if the parent resource is created in the same configuration (i.e., if you have no other choice), you should addignore_changes </span>= [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
ignore_tagsconfiguration.
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),
});
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)
example_tag = aws.organizations.Tag("example",
resource_id=example_organizational_unit.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),
})
if err != nil {
return err
}
_, err = organizations.NewTag(ctx, "example", &organizations.TagArgs{
ResourceId: exampleOrganizationalUnit.ID(),
Key: pulumi.String("ExampleKey"),
Value: pulumi.String("ExampleValue"),
})
if err != nil {
return err
}
return nil
})
}
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),
});
var exampleTag = new Aws.Organizations.Tag("example", new()
{
ResourceId = exampleOrganizationalUnit.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 java.util.List;
import java.util.ArrayList;
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());
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}
exampleTag:
type: aws:organizations:Tag
name: example
properties:
resourceId: ${exampleOrganizationalUnit.id}
key: ExampleKey
value: ExampleValue
variables:
example:
fn::invoke:
function: aws:organizations:getOrganization
arguments: {}
Create Tag Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Tag(name: string, args: TagArgs, opts?: CustomResourceOptions);@overload
def Tag(resource_name: str,
args: TagArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Tag(resource_name: str,
opts: Optional[ResourceOptions] = None,
key: Optional[str] = None,
resource_id: Optional[str] = None,
value: Optional[str] = None)func NewTag(ctx *Context, name string, args TagArgs, opts ...ResourceOption) (*Tag, error)public Tag(string name, TagArgs args, CustomResourceOptions? opts = null)type: aws:organizations:Tag
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args TagArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args TagArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args TagArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args TagArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args TagArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var exampletagResourceResourceFromOrganizationstag = new Aws.Organizations.Tag("exampletagResourceResourceFromOrganizationstag", new()
{
Key = "string",
ResourceId = "string",
Value = "string",
});
example, err := organizations.NewTag(ctx, "exampletagResourceResourceFromOrganizationstag", &organizations.TagArgs{
Key: pulumi.String("string"),
ResourceId: pulumi.String("string"),
Value: pulumi.String("string"),
})
var exampletagResourceResourceFromOrganizationstag = new com.pulumi.aws.organizations.Tag("exampletagResourceResourceFromOrganizationstag", com.pulumi.aws.organizations.TagArgs.builder()
.key("string")
.resourceId("string")
.value("string")
.build());
exampletag_resource_resource_from_organizationstag = aws.organizations.Tag("exampletagResourceResourceFromOrganizationstag",
key="string",
resource_id="string",
value="string")
const exampletagResourceResourceFromOrganizationstag = new aws.organizations.Tag("exampletagResourceResourceFromOrganizationstag", {
key: "string",
resourceId: "string",
value: "string",
});
type: aws:organizations:Tag
properties:
key: string
resourceId: string
value: string
Tag Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Tag resource accepts the following input properties:
- Key string
- Tag name.
- Resource
Id string - Id of the Organizations resource to tag.
- Value string
- Tag value.
- Key string
- Tag name.
- Resource
Id string - Id of the Organizations resource to tag.
- Value string
- Tag value.
- key String
- Tag name.
- resource
Id String - Id of the Organizations resource to tag.
- value String
- Tag value.
- key string
- Tag name.
- resource
Id string - Id of the Organizations resource to tag.
- value string
- Tag value.
- key str
- Tag name.
- resource_
id str - Id of the Organizations resource to tag.
- value str
- Tag value.
- key String
- Tag name.
- resource
Id String - Id of the Organizations resource to tag.
- value String
- Tag value.
Outputs
All input properties are implicitly available as output properties. Additionally, the Tag resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Tag Resource
Get an existing Tag resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: TagState, opts?: CustomResourceOptions): Tag@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
key: Optional[str] = None,
resource_id: Optional[str] = None,
value: Optional[str] = None) -> Tagfunc GetTag(ctx *Context, name string, id IDInput, state *TagState, opts ...ResourceOption) (*Tag, error)public static Tag Get(string name, Input<string> id, TagState? state, CustomResourceOptions? opts = null)public static Tag get(String name, Output<String> id, TagState state, CustomResourceOptions options)resources: _: type: aws:organizations:Tag get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Key string
- Tag name.
- Resource
Id string - Id of the Organizations resource to tag.
- Value string
- Tag value.
- Key string
- Tag name.
- Resource
Id string - Id of the Organizations resource to tag.
- Value string
- Tag value.
- key String
- Tag name.
- resource
Id String - Id of the Organizations resource to tag.
- value String
- Tag value.
- key string
- Tag name.
- resource
Id string - Id of the Organizations resource to tag.
- value string
- Tag value.
- key str
- Tag name.
- resource_
id str - Id of the Organizations resource to tag.
- value str
- Tag value.
- key String
- Tag name.
- resource
Id String - Id of the Organizations resource to tag.
- value String
- Tag value.
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
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.
