digitalocean.Tag
Explore with Pulumi AI
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)
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.
Constructor 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
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:
- 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:
- 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 string
- 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 intCount - A count of the total number of resources that the tag is applied to.
- Volume
Snapshots intCount - 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.
- 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 string
- 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 intCount - A count of the total number of resources that the tag is applied to.
- Volume
Snapshots intCount - 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.
- databases
Count Integer - A count of the database clusters that the tag is applied to.
- droplets
Count Integer - A count of the Droplets the tag is applied to.
- id String
- The provider-assigned unique ID for this managed resource.
- images
Count Integer - A count of the images that the tag is applied to.
- total
Resource IntegerCount - A count of the total number of resources that the tag is applied to.
- volume
Snapshots IntegerCount - A count of the volume snapshots that the tag is applied to.
- volumes
Count Integer - A count of the volumes that the tag is applied to.
- databases
Count number - A count of the database clusters that the tag is applied to.
- droplets
Count number - A count of the Droplets the tag is applied to.
- id string
- The provider-assigned unique ID for this managed resource.
- images
Count number - A count of the images that the tag is applied to.
- total
Resource numberCount - A count of the total number of resources that the tag is applied to.
- volume
Snapshots numberCount - A count of the volume snapshots that the tag is applied to.
- volumes
Count 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_ intcount - A count of the total number of resources that the tag is applied to.
- volume_
snapshots_ intcount - 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.
- databases
Count Number - A count of the database clusters that the tag is applied to.
- droplets
Count Number - A count of the Droplets the tag is applied to.
- id String
- The provider-assigned unique ID for this managed resource.
- images
Count Number - A count of the images that the tag is applied to.
- total
Resource NumberCount - A count of the total number of resources that the tag is applied to.
- volume
Snapshots NumberCount - A count of the volume snapshots that the tag is applied to.
- volumes
Count 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.
- 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 string
- The name of the tag
- Total
Resource intCount - A count of the total number of resources that the tag is applied to.
- Volume
Snapshots intCount - 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.
- 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 string
- The name of the tag
- Total
Resource intCount - A count of the total number of resources that the tag is applied to.
- Volume
Snapshots intCount - 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.
- databases
Count Integer - A count of the database clusters that the tag is applied to.
- droplets
Count Integer - A count of the Droplets the tag is applied to.
- images
Count Integer - A count of the images that the tag is applied to.
- name String
- The name of the tag
- total
Resource IntegerCount - A count of the total number of resources that the tag is applied to.
- volume
Snapshots IntegerCount - A count of the volume snapshots that the tag is applied to.
- volumes
Count Integer - A count of the volumes that the tag is applied to.
- databases
Count number - A count of the database clusters that the tag is applied to.
- droplets
Count number - A count of the Droplets the tag is applied to.
- images
Count number - A count of the images that the tag is applied to.
- name string
- The name of the tag
- total
Resource numberCount - A count of the total number of resources that the tag is applied to.
- volume
Snapshots numberCount - A count of the volume snapshots that the tag is applied to.
- volumes
Count 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_ intcount - A count of the total number of resources that the tag is applied to.
- volume_
snapshots_ intcount - 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.
- databases
Count Number - A count of the database clusters that the tag is applied to.
- droplets
Count Number - A count of the Droplets the tag is applied to.
- images
Count Number - A count of the images that the tag is applied to.
- name String
- The name of the tag
- total
Resource NumberCount - A count of the total number of resources that the tag is applied to.
- volume
Snapshots NumberCount - A count of the volume snapshots that the tag is applied to.
- volumes
Count 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.