1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. tags
  5. TagBinding
Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi

gcp.tags.TagBinding

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi

    A TagBinding represents a connection between a TagValue and a cloud resource (currently project, folder, or organization). Once a TagBinding is created, the TagValue is applied to all the descendants of the cloud resource.

    To get more information about TagBinding, see:

    Example Usage

    Tag Binding Basic

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const project = new gcp.organizations.Project("project", {
        projectId: "project_id",
        name: "project_id",
        orgId: "123456789",
    });
    const key = new gcp.tags.TagKey("key", {
        parent: "organizations/123456789",
        shortName: "keyname",
        description: "For keyname resources.",
    });
    const value = new gcp.tags.TagValue("value", {
        parent: pulumi.interpolate`tagKeys/${key.name}`,
        shortName: "valuename",
        description: "For valuename resources.",
    });
    const binding = new gcp.tags.TagBinding("binding", {
        parent: pulumi.interpolate`//cloudresourcemanager.googleapis.com/projects/${project.number}`,
        tagValue: pulumi.interpolate`tagValues/${value.name}`,
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    project = gcp.organizations.Project("project",
        project_id="project_id",
        name="project_id",
        org_id="123456789")
    key = gcp.tags.TagKey("key",
        parent="organizations/123456789",
        short_name="keyname",
        description="For keyname resources.")
    value = gcp.tags.TagValue("value",
        parent=key.name.apply(lambda name: f"tagKeys/{name}"),
        short_name="valuename",
        description="For valuename resources.")
    binding = gcp.tags.TagBinding("binding",
        parent=project.number.apply(lambda number: f"//cloudresourcemanager.googleapis.com/projects/{number}"),
        tag_value=value.name.apply(lambda name: f"tagValues/{name}"))
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/tags"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		project, err := organizations.NewProject(ctx, "project", &organizations.ProjectArgs{
    			ProjectId: pulumi.String("project_id"),
    			Name:      pulumi.String("project_id"),
    			OrgId:     pulumi.String("123456789"),
    		})
    		if err != nil {
    			return err
    		}
    		key, err := tags.NewTagKey(ctx, "key", &tags.TagKeyArgs{
    			Parent:      pulumi.String("organizations/123456789"),
    			ShortName:   pulumi.String("keyname"),
    			Description: pulumi.String("For keyname resources."),
    		})
    		if err != nil {
    			return err
    		}
    		value, err := tags.NewTagValue(ctx, "value", &tags.TagValueArgs{
    			Parent: key.Name.ApplyT(func(name string) (string, error) {
    				return fmt.Sprintf("tagKeys/%v", name), nil
    			}).(pulumi.StringOutput),
    			ShortName:   pulumi.String("valuename"),
    			Description: pulumi.String("For valuename resources."),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = tags.NewTagBinding(ctx, "binding", &tags.TagBindingArgs{
    			Parent: project.Number.ApplyT(func(number string) (string, error) {
    				return fmt.Sprintf("//cloudresourcemanager.googleapis.com/projects/%v", number), nil
    			}).(pulumi.StringOutput),
    			TagValue: value.Name.ApplyT(func(name string) (string, error) {
    				return fmt.Sprintf("tagValues/%v", name), nil
    			}).(pulumi.StringOutput),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var project = new Gcp.Organizations.Project("project", new()
        {
            ProjectId = "project_id",
            Name = "project_id",
            OrgId = "123456789",
        });
    
        var key = new Gcp.Tags.TagKey("key", new()
        {
            Parent = "organizations/123456789",
            ShortName = "keyname",
            Description = "For keyname resources.",
        });
    
        var @value = new Gcp.Tags.TagValue("value", new()
        {
            Parent = key.Name.Apply(name => $"tagKeys/{name}"),
            ShortName = "valuename",
            Description = "For valuename resources.",
        });
    
        var binding = new Gcp.Tags.TagBinding("binding", new()
        {
            Parent = project.Number.Apply(number => $"//cloudresourcemanager.googleapis.com/projects/{number}"),
            TagValue = @value.Name.Apply(name => $"tagValues/{name}"),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.organizations.Project;
    import com.pulumi.gcp.organizations.ProjectArgs;
    import com.pulumi.gcp.tags.TagKey;
    import com.pulumi.gcp.tags.TagKeyArgs;
    import com.pulumi.gcp.tags.TagValue;
    import com.pulumi.gcp.tags.TagValueArgs;
    import com.pulumi.gcp.tags.TagBinding;
    import com.pulumi.gcp.tags.TagBindingArgs;
    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) {
            var project = new Project("project", ProjectArgs.builder()
                .projectId("project_id")
                .name("project_id")
                .orgId("123456789")
                .build());
    
            var key = new TagKey("key", TagKeyArgs.builder()
                .parent("organizations/123456789")
                .shortName("keyname")
                .description("For keyname resources.")
                .build());
    
            var value = new TagValue("value", TagValueArgs.builder()
                .parent(key.name().applyValue(name -> String.format("tagKeys/%s", name)))
                .shortName("valuename")
                .description("For valuename resources.")
                .build());
    
            var binding = new TagBinding("binding", TagBindingArgs.builder()
                .parent(project.number().applyValue(number -> String.format("//cloudresourcemanager.googleapis.com/projects/%s", number)))
                .tagValue(value.name().applyValue(name -> String.format("tagValues/%s", name)))
                .build());
    
        }
    }
    
    resources:
      project:
        type: gcp:organizations:Project
        properties:
          projectId: project_id
          name: project_id
          orgId: '123456789'
      key:
        type: gcp:tags:TagKey
        properties:
          parent: organizations/123456789
          shortName: keyname
          description: For keyname resources.
      value:
        type: gcp:tags:TagValue
        properties:
          parent: tagKeys/${key.name}
          shortName: valuename
          description: For valuename resources.
      binding:
        type: gcp:tags:TagBinding
        properties:
          parent: //cloudresourcemanager.googleapis.com/projects/${project.number}
          tagValue: tagValues/${value.name}
    

    Create TagBinding Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new TagBinding(name: string, args: TagBindingArgs, opts?: CustomResourceOptions);
    @overload
    def TagBinding(resource_name: str,
                   args: TagBindingArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def TagBinding(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   parent: Optional[str] = None,
                   tag_value: Optional[str] = None)
    func NewTagBinding(ctx *Context, name string, args TagBindingArgs, opts ...ResourceOption) (*TagBinding, error)
    public TagBinding(string name, TagBindingArgs args, CustomResourceOptions? opts = null)
    public TagBinding(String name, TagBindingArgs args)
    public TagBinding(String name, TagBindingArgs args, CustomResourceOptions options)
    
    type: gcp:tags:TagBinding
    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 TagBindingArgs
    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 TagBindingArgs
    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 TagBindingArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args TagBindingArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args TagBindingArgs
    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 tagBindingResource = new Gcp.Tags.TagBinding("tagBindingResource", new()
    {
        Parent = "string",
        TagValue = "string",
    });
    
    example, err := tags.NewTagBinding(ctx, "tagBindingResource", &tags.TagBindingArgs{
    	Parent:   pulumi.String("string"),
    	TagValue: pulumi.String("string"),
    })
    
    var tagBindingResource = new TagBinding("tagBindingResource", TagBindingArgs.builder()
        .parent("string")
        .tagValue("string")
        .build());
    
    tag_binding_resource = gcp.tags.TagBinding("tagBindingResource",
        parent="string",
        tag_value="string")
    
    const tagBindingResource = new gcp.tags.TagBinding("tagBindingResource", {
        parent: "string",
        tagValue: "string",
    });
    
    type: gcp:tags:TagBinding
    properties:
        parent: string
        tagValue: string
    

    TagBinding Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The TagBinding resource accepts the following input properties:

    Parent string
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    TagValue string
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    Parent string
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    TagValue string
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    parent String
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    tagValue String
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    parent string
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    tagValue string
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    parent str
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    tag_value str
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    parent String
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    tagValue String
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    Outputs

    All input properties are implicitly available as output properties. Additionally, the TagBinding resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}

    Look up Existing TagBinding Resource

    Get an existing TagBinding 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?: TagBindingState, opts?: CustomResourceOptions): TagBinding
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            name: Optional[str] = None,
            parent: Optional[str] = None,
            tag_value: Optional[str] = None) -> TagBinding
    func GetTagBinding(ctx *Context, name string, id IDInput, state *TagBindingState, opts ...ResourceOption) (*TagBinding, error)
    public static TagBinding Get(string name, Input<string> id, TagBindingState? state, CustomResourceOptions? opts = null)
    public static TagBinding get(String name, Output<String> id, TagBindingState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    The following state arguments are supported:
    Name string
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    Parent string
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    TagValue string
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    Name string
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    Parent string
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    TagValue string
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    name String
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    parent String
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    tagValue String
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    name string
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    parent string
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    tagValue string
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    name str
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    parent str
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    tag_value str
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    name String
    The generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}
    parent String
    The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123
    tagValue String
    The TagValue of the TagBinding. Must be of the form tagValues/456.


    Import

    TagBinding can be imported using any of these accepted formats:

    • tagBindings/{{name}}

    • {{name}}

    When using the pulumi import command, TagBinding can be imported using one of the formats above. For example:

    $ pulumi import gcp:tags/tagBinding:TagBinding default tagBindings/{{name}}
    
    $ pulumi import gcp:tags/tagBinding:TagBinding default {{name}}
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the google-beta Terraform Provider.
    gcp logo
    Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi