DigitalOcean

v4.16.0 published on Wednesday, Sep 28, 2022 by Pulumi

Tag

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

using System.Collections.Generic;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    // Create a new tag
    var foobar = new DigitalOcean.Tag("foobar");

    // Create a new Droplet in nyc3 with the foobar tag
    var web = new DigitalOcean.Droplet("web", new()
    {
        Image = "ubuntu-18-04-x64",
        Region = "nyc3",
        Size = "s-1vcpu-1gb",
        Tags = new[]
        {
            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 {
		foobar, err := digitalocean.NewTag(ctx, "foobar", nil)
		if err != nil {
			return err
		}
		_, err = digitalocean.NewDroplet(ctx, "web", &digitalocean.DropletArgs{
			Image:  pulumi.String("ubuntu-18-04-x64"),
			Region: pulumi.String("nyc3"),
			Size:   pulumi.String("s-1vcpu-1gb"),
			Tags: pulumi.StringArray{
				foobar.ID(),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
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.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) {
        var foobar = new Tag("foobar");

        var web = new Droplet("web", DropletArgs.builder()        
            .image("ubuntu-18-04-x64")
            .region("nyc3")
            .size("s-1vcpu-1gb")
            .tags(foobar.id())
            .build());

    }
}
import pulumi
import pulumi_digitalocean as digitalocean

# Create a new tag
foobar = digitalocean.Tag("foobar")
# Create a new Droplet in nyc3 with the foobar tag
web = digitalocean.Droplet("web",
    image="ubuntu-18-04-x64",
    region="nyc3",
    size="s-1vcpu-1gb",
    tags=[foobar.id])
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

// Create a new tag
const foobar = new digitalocean.Tag("foobar", {});
// Create a new Droplet in nyc3 with the foobar tag
const web = new digitalocean.Droplet("web", {
    image: "ubuntu-18-04-x64",
    region: "nyc3",
    size: "s-1vcpu-1gb",
    tags: [foobar.id],
});
resources:
  # Create a new tag
  foobar:
    type: digitalocean:Tag
  # Create a new Droplet in nyc3 with the foobar tag
  web:
    type: digitalocean:Droplet
    properties:
      image: ubuntu-18-04-x64
      region: nyc3
      size: s-1vcpu-1gb
      tags:
        - ${foobar.id}

Create Tag Resource

new Tag(name: string, args?: TagArgs, opts?: CustomResourceOptions);
@overload
def Tag(resource_name: str,
        opts: Optional[ResourceOptions] = None,
        name: Optional[str] = None)
@overload
def Tag(resource_name: str,
        args: Optional[TagArgs] = None,
        opts: Optional[ResourceOptions] = 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.

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.

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

Package Details

Repository
https://github.com/pulumi/pulumi-digitalocean
License
Apache-2.0
Notes

This Pulumi package is based on the digitalocean Terraform Provider.