DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi
digitalocean.getTag
Explore with Pulumi AI
Get information on a tag. This data source provides the name as configured on your DigitalOcean account. This is useful if the tag name in question is not managed by the provider or you need validate if the tag exists in the account.
An error is triggered if the provided tag name does not exist.
Example Usage
Get the tag:
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const example = digitalocean.getTag({
name: "example",
});
const exampleDroplet = new digitalocean.Droplet("example", {
image: "ubuntu-18-04-x64",
name: "example-1",
region: digitalocean.Region.NYC2,
size: digitalocean.DropletSlug.DropletS1VCPU1GB,
tags: [example.then(example => example.name)],
});
import pulumi
import pulumi_digitalocean as digitalocean
example = digitalocean.get_tag(name="example")
example_droplet = digitalocean.Droplet("example",
image="ubuntu-18-04-x64",
name="example-1",
region=digitalocean.Region.NYC2,
size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
tags=[example.name])
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 {
example, err := digitalocean.LookupTag(ctx, &digitalocean.LookupTagArgs{
Name: "example",
}, nil)
if err != nil {
return err
}
_, err = digitalocean.NewDroplet(ctx, "example", &digitalocean.DropletArgs{
Image: pulumi.String("ubuntu-18-04-x64"),
Name: pulumi.String("example-1"),
Region: pulumi.String(digitalocean.RegionNYC2),
Size: pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
Tags: pulumi.StringArray{
pulumi.String(example.Name),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
return await Deployment.RunAsync(() =>
{
var example = DigitalOcean.GetTag.Invoke(new()
{
Name = "example",
});
var exampleDroplet = new DigitalOcean.Droplet("example", new()
{
Image = "ubuntu-18-04-x64",
Name = "example-1",
Region = DigitalOcean.Region.NYC2,
Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
Tags = new[]
{
example.Apply(getTagResult => getTagResult.Name),
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.DigitaloceanFunctions;
import com.pulumi.digitalocean.inputs.GetTagArgs;
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) {
final var example = DigitaloceanFunctions.getTag(GetTagArgs.builder()
.name("example")
.build());
var exampleDroplet = new Droplet("exampleDroplet", DropletArgs.builder()
.image("ubuntu-18-04-x64")
.name("example-1")
.region("nyc2")
.size("s-1vcpu-1gb")
.tags(example.applyValue(getTagResult -> getTagResult.name()))
.build());
}
}
resources:
exampleDroplet:
type: digitalocean:Droplet
name: example
properties:
image: ubuntu-18-04-x64
name: example-1
region: nyc2
size: s-1vcpu-1gb
tags:
- ${example.name}
variables:
example:
fn::invoke:
Function: digitalocean:getTag
Arguments:
name: example
Using getTag
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getTag(args: GetTagArgs, opts?: InvokeOptions): Promise<GetTagResult>
function getTagOutput(args: GetTagOutputArgs, opts?: InvokeOptions): Output<GetTagResult>
def get_tag(name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetTagResult
def get_tag_output(name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetTagResult]
func LookupTag(ctx *Context, args *LookupTagArgs, opts ...InvokeOption) (*LookupTagResult, error)
func LookupTagOutput(ctx *Context, args *LookupTagOutputArgs, opts ...InvokeOption) LookupTagResultOutput
> Note: This function is named LookupTag
in the Go SDK.
public static class GetTag
{
public static Task<GetTagResult> InvokeAsync(GetTagArgs args, InvokeOptions? opts = null)
public static Output<GetTagResult> Invoke(GetTagInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetTagResult> getTag(GetTagArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: digitalocean:index/getTag:getTag
arguments:
# arguments dictionary
The following arguments are supported:
- 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.
getTag Result
The following output properties are available:
- 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.
- Name string
- 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.
- Name string
- 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.
- name String
- 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.
- name string
- 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.
- name str
- 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.
- name String
- 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.
Package Details
- Repository
- DigitalOcean pulumi/pulumi-digitalocean
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
digitalocean
Terraform Provider.