1. Packages
  2. DigitalOcean
  3. API Docs
  4. Tag
DigitalOcean v4.30.2 published on Wednesday, Jun 5, 2024 by Pulumi

digitalocean.Tag

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.30.2 published on Wednesday, Jun 5, 2024 by Pulumi

    Provides a DigitalOcean Tag resource. A Tag is a label that can be applied to a Droplet resource in order to better organize or facilitate the lookups and actions on it. Tags created with this resource can be referenced in your Droplet configuration via their ID or name.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    // Create a new tag
    const foobar = new digitalocean.Tag("foobar", {name: "foobar"});
    // Create a new Droplet in nyc3 with the foobar tag
    const web = new digitalocean.Droplet("web", {
        image: "ubuntu-18-04-x64",
        name: "web-1",
        region: digitalocean.Region.NYC3,
        size: digitalocean.DropletSlug.DropletS1VCPU1GB,
        tags: [foobar.id],
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    # Create a new tag
    foobar = digitalocean.Tag("foobar", name="foobar")
    # Create a new Droplet in nyc3 with the foobar tag
    web = digitalocean.Droplet("web",
        image="ubuntu-18-04-x64",
        name="web-1",
        region=digitalocean.Region.NYC3,
        size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
        tags=[foobar.id])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Create a new tag
    		foobar, err := digitalocean.NewTag(ctx, "foobar", &digitalocean.TagArgs{
    			Name: pulumi.String("foobar"),
    		})
    		if err != nil {
    			return err
    		}
    		// Create a new Droplet in nyc3 with the foobar tag
    		_, err = digitalocean.NewDroplet(ctx, "web", &digitalocean.DropletArgs{
    			Image:  pulumi.String("ubuntu-18-04-x64"),
    			Name:   pulumi.String("web-1"),
    			Region: pulumi.String(digitalocean.RegionNYC3),
    			Size:   pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
    			Tags: pulumi.StringArray{
    				foobar.ID(),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        // Create a new tag
        var foobar = new DigitalOcean.Tag("foobar", new()
        {
            Name = "foobar",
        });
    
        // Create a new Droplet in nyc3 with the foobar tag
        var web = new DigitalOcean.Droplet("web", new()
        {
            Image = "ubuntu-18-04-x64",
            Name = "web-1",
            Region = DigitalOcean.Region.NYC3,
            Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
            Tags = new[]
            {
                foobar.Id,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.digitalocean.Tag;
    import com.pulumi.digitalocean.TagArgs;
    import com.pulumi.digitalocean.Droplet;
    import com.pulumi.digitalocean.DropletArgs;
    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) {
            // Create a new tag
            var foobar = new Tag("foobar", TagArgs.builder()
                .name("foobar")
                .build());
    
            // Create a new Droplet in nyc3 with the foobar tag
            var web = new Droplet("web", DropletArgs.builder()
                .image("ubuntu-18-04-x64")
                .name("web-1")
                .region("nyc3")
                .size("s-1vcpu-1gb")
                .tags(foobar.id())
                .build());
    
        }
    }
    
    resources:
      # Create a new tag
      foobar:
        type: digitalocean:Tag
        properties:
          name: foobar
      # Create a new Droplet in nyc3 with the foobar tag
      web:
        type: digitalocean:Droplet
        properties:
          image: ubuntu-18-04-x64
          name: web-1
          region: nyc3
          size: s-1vcpu-1gb
          tags:
            - ${foobar.id}
    

    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: Optional[TagArgs] = None,
            opts: Optional[ResourceOptions] = None)
    
    @overload
    def Tag(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            name: Optional[str] = None)
    func NewTag(ctx *Context, name string, args *TagArgs, opts ...ResourceOption) (*Tag, error)
    public Tag(string name, TagArgs? args = null, CustomResourceOptions? opts = null)
    public Tag(String name, TagArgs args)
    public Tag(String name, TagArgs args, CustomResourceOptions options)
    
    type: digitalocean: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.

    Example

    The following reference example uses placeholder values for all input properties.

    var tagResource = new DigitalOcean.Tag("tagResource", new()
    {
        Name = "string",
    });
    
    example, err := digitalocean.NewTag(ctx, "tagResource", &digitalocean.TagArgs{
    	Name: pulumi.String("string"),
    })
    
    var tagResource = new Tag("tagResource", TagArgs.builder()
        .name("string")
        .build());
    
    tag_resource = digitalocean.Tag("tagResource", name="string")
    
    const tagResource = new digitalocean.Tag("tagResource", {name: "string"});
    
    type: digitalocean:Tag
    properties:
        name: 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

    The Tag resource accepts the following input properties:

    Name string
    The name of the tag
    Name string
    The name of the tag
    name String
    The name of the tag
    name string
    The name of the tag
    name str
    The name of the tag
    name String
    The name of the tag

    Outputs

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

    DatabasesCount int
    A count of the database clusters that the tag is applied to.
    DropletsCount int
    A count of the Droplets the tag is applied to.
    Id string
    The provider-assigned unique ID for this managed resource.
    ImagesCount int
    A count of the images that the tag is applied to.
    TotalResourceCount int
    A count of the total number of resources that the tag is applied to.
    VolumeSnapshotsCount int
    A count of the volume snapshots that the tag is applied to.
    VolumesCount int
    A count of the volumes that the tag is applied to.
    DatabasesCount int
    A count of the database clusters that the tag is applied to.
    DropletsCount int
    A count of the Droplets the tag is applied to.
    Id string
    The provider-assigned unique ID for this managed resource.
    ImagesCount int
    A count of the images that the tag is applied to.
    TotalResourceCount int
    A count of the total number of resources that the tag is applied to.
    VolumeSnapshotsCount int
    A count of the volume snapshots that the tag is applied to.
    VolumesCount int
    A count of the volumes that the tag is applied to.
    databasesCount Integer
    A count of the database clusters that the tag is applied to.
    dropletsCount Integer
    A count of the Droplets the tag is applied to.
    id String
    The provider-assigned unique ID for this managed resource.
    imagesCount Integer
    A count of the images that the tag is applied to.
    totalResourceCount Integer
    A count of the total number of resources that the tag is applied to.
    volumeSnapshotsCount Integer
    A count of the volume snapshots that the tag is applied to.
    volumesCount Integer
    A count of the volumes that the tag is applied to.
    databasesCount number
    A count of the database clusters that the tag is applied to.
    dropletsCount number
    A count of the Droplets the tag is applied to.
    id string
    The provider-assigned unique ID for this managed resource.
    imagesCount number
    A count of the images that the tag is applied to.
    totalResourceCount number
    A count of the total number of resources that the tag is applied to.
    volumeSnapshotsCount number
    A count of the volume snapshots that the tag is applied to.
    volumesCount number
    A count of the volumes that the tag is applied to.
    databases_count int
    A count of the database clusters that the tag is applied to.
    droplets_count int
    A count of the Droplets the tag is applied to.
    id str
    The provider-assigned unique ID for this managed resource.
    images_count int
    A count of the images that the tag is applied to.
    total_resource_count int
    A count of the total number of resources that the tag is applied to.
    volume_snapshots_count int
    A count of the volume snapshots that the tag is applied to.
    volumes_count int
    A count of the volumes that the tag is applied to.
    databasesCount Number
    A count of the database clusters that the tag is applied to.
    dropletsCount Number
    A count of the Droplets the tag is applied to.
    id String
    The provider-assigned unique ID for this managed resource.
    imagesCount Number
    A count of the images that the tag is applied to.
    totalResourceCount Number
    A count of the total number of resources that the tag is applied to.
    volumeSnapshotsCount Number
    A count of the volume snapshots that the tag is applied to.
    volumesCount Number
    A count of the volumes that the tag is applied to.

    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,
            databases_count: Optional[int] = None,
            droplets_count: Optional[int] = None,
            images_count: Optional[int] = None,
            name: Optional[str] = None,
            total_resource_count: Optional[int] = None,
            volume_snapshots_count: Optional[int] = None,
            volumes_count: Optional[int] = None) -> Tag
    func 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)
    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:
    DatabasesCount int
    A count of the database clusters that the tag is applied to.
    DropletsCount int
    A count of the Droplets the tag is applied to.
    ImagesCount int
    A count of the images that the tag is applied to.
    Name string
    The name of the tag
    TotalResourceCount int
    A count of the total number of resources that the tag is applied to.
    VolumeSnapshotsCount int
    A count of the volume snapshots that the tag is applied to.
    VolumesCount int
    A count of the volumes that the tag is applied to.
    DatabasesCount int
    A count of the database clusters that the tag is applied to.
    DropletsCount int
    A count of the Droplets the tag is applied to.
    ImagesCount int
    A count of the images that the tag is applied to.
    Name string
    The name of the tag
    TotalResourceCount int
    A count of the total number of resources that the tag is applied to.
    VolumeSnapshotsCount int
    A count of the volume snapshots that the tag is applied to.
    VolumesCount int
    A count of the volumes that the tag is applied to.
    databasesCount Integer
    A count of the database clusters that the tag is applied to.
    dropletsCount Integer
    A count of the Droplets the tag is applied to.
    imagesCount Integer
    A count of the images that the tag is applied to.
    name String
    The name of the tag
    totalResourceCount Integer
    A count of the total number of resources that the tag is applied to.
    volumeSnapshotsCount Integer
    A count of the volume snapshots that the tag is applied to.
    volumesCount Integer
    A count of the volumes that the tag is applied to.
    databasesCount number
    A count of the database clusters that the tag is applied to.
    dropletsCount number
    A count of the Droplets the tag is applied to.
    imagesCount number
    A count of the images that the tag is applied to.
    name string
    The name of the tag
    totalResourceCount number
    A count of the total number of resources that the tag is applied to.
    volumeSnapshotsCount number
    A count of the volume snapshots that the tag is applied to.
    volumesCount number
    A count of the volumes that the tag is applied to.
    databases_count int
    A count of the database clusters that the tag is applied to.
    droplets_count int
    A count of the Droplets the tag is applied to.
    images_count int
    A count of the images that the tag is applied to.
    name str
    The name of the tag
    total_resource_count int
    A count of the total number of resources that the tag is applied to.
    volume_snapshots_count int
    A count of the volume snapshots that the tag is applied to.
    volumes_count int
    A count of the volumes that the tag is applied to.
    databasesCount Number
    A count of the database clusters that the tag is applied to.
    dropletsCount Number
    A count of the Droplets the tag is applied to.
    imagesCount Number
    A count of the images that the tag is applied to.
    name String
    The name of the tag
    totalResourceCount Number
    A count of the total number of resources that the tag is applied to.
    volumeSnapshotsCount Number
    A count of the volume snapshots that the tag is applied to.
    volumesCount Number
    A count of the volumes that the tag is applied to.

    Import

    Tags can be imported using the name, e.g.

    $ pulumi import digitalocean:index/tag:Tag mytag tagname
    

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

    Package Details

    Repository
    DigitalOcean pulumi/pulumi-digitalocean
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the digitalocean Terraform Provider.
    digitalocean logo
    DigitalOcean v4.30.2 published on Wednesday, Jun 5, 2024 by Pulumi