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

digitalocean.getTag

Explore with Pulumi AI

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

    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:

    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.
    Name string
    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.
    Name string
    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.
    name String
    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.
    name string
    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.
    name str
    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.
    name String
    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.

    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