1. Packages
  2. DigitalOcean Provider
  3. API Docs
  4. getTags
DigitalOcean v4.42.0 published on Thursday, Apr 17, 2025 by Pulumi

digitalocean.getTags

Explore with Pulumi AI

DigitalOcean v4.42.0 published on Thursday, Apr 17, 2025 by Pulumi

Returns a list of tags in your DigitalOcean account, with the ability to filter and sort the results. If no filters are specified, all tags will be returned.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const list = digitalocean.getTags({
    sorts: [{
        key: "total_resource_count",
        direction: "asc",
    }],
});
export const sortedTags = list.then(list => list.tags);
Copy
import pulumi
import pulumi_digitalocean as digitalocean

list = digitalocean.get_tags(sorts=[{
    "key": "total_resource_count",
    "direction": "asc",
}])
pulumi.export("sortedTags", list.tags)
Copy
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 {
		list, err := digitalocean.GetTags(ctx, &digitalocean.GetTagsArgs{
			Sorts: []digitalocean.GetTagsSort{
				{
					Key:       "total_resource_count",
					Direction: pulumi.StringRef("asc"),
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("sortedTags", list.Tags)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var list = DigitalOcean.GetTags.Invoke(new()
    {
        Sorts = new[]
        {
            new DigitalOcean.Inputs.GetTagsSortInputArgs
            {
                Key = "total_resource_count",
                Direction = "asc",
            },
        },
    });

    return new Dictionary<string, object?>
    {
        ["sortedTags"] = list.Apply(getTagsResult => getTagsResult.Tags),
    };
});
Copy
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.GetTagsArgs;
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 list = DigitaloceanFunctions.getTags(GetTagsArgs.builder()
            .sorts(GetTagsSortArgs.builder()
                .key("total_resource_count")
                .direction("asc")
                .build())
            .build());

        ctx.export("sortedTags", list.tags());
    }
}
Copy
variables:
  list:
    fn::invoke:
      function: digitalocean:getTags
      arguments:
        sorts:
          - key: total_resource_count
            direction: asc
outputs:
  sortedTags: ${list.tags}
Copy

Using getTags

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 getTags(args: GetTagsArgs, opts?: InvokeOptions): Promise<GetTagsResult>
function getTagsOutput(args: GetTagsOutputArgs, opts?: InvokeOptions): Output<GetTagsResult>
Copy
def get_tags(filters: Optional[Sequence[GetTagsFilter]] = None,
             sorts: Optional[Sequence[GetTagsSort]] = None,
             opts: Optional[InvokeOptions] = None) -> GetTagsResult
def get_tags_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetTagsFilterArgs]]]] = None,
             sorts: Optional[pulumi.Input[Sequence[pulumi.Input[GetTagsSortArgs]]]] = None,
             opts: Optional[InvokeOptions] = None) -> Output[GetTagsResult]
Copy
func GetTags(ctx *Context, args *GetTagsArgs, opts ...InvokeOption) (*GetTagsResult, error)
func GetTagsOutput(ctx *Context, args *GetTagsOutputArgs, opts ...InvokeOption) GetTagsResultOutput
Copy

> Note: This function is named GetTags in the Go SDK.

public static class GetTags 
{
    public static Task<GetTagsResult> InvokeAsync(GetTagsArgs args, InvokeOptions? opts = null)
    public static Output<GetTagsResult> Invoke(GetTagsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetTagsResult> getTags(GetTagsArgs args, InvokeOptions options)
public static Output<GetTagsResult> getTags(GetTagsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: digitalocean:index/getTags:getTags
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Filters List<Pulumi.DigitalOcean.Inputs.GetTagsFilter>
Filter the results. The filter block is documented below.
Sorts List<Pulumi.DigitalOcean.Inputs.GetTagsSort>
Sort the results. The sort block is documented below.
Filters []GetTagsFilter
Filter the results. The filter block is documented below.
Sorts []GetTagsSort
Sort the results. The sort block is documented below.
filters List<GetTagsFilter>
Filter the results. The filter block is documented below.
sorts List<GetTagsSort>
Sort the results. The sort block is documented below.
filters GetTagsFilter[]
Filter the results. The filter block is documented below.
sorts GetTagsSort[]
Sort the results. The sort block is documented below.
filters Sequence[GetTagsFilter]
Filter the results. The filter block is documented below.
sorts Sequence[GetTagsSort]
Sort the results. The sort block is documented below.
filters List<Property Map>
Filter the results. The filter block is documented below.
sorts List<Property Map>
Sort the results. The sort block is documented below.

getTags Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Tags []GetTagsTag
Filters []GetTagsFilter
Sorts []GetTagsSort
id String
The provider-assigned unique ID for this managed resource.
tags List<GetTagsTag>
filters List<GetTagsFilter>
sorts List<GetTagsSort>
id string
The provider-assigned unique ID for this managed resource.
tags GetTagsTag[]
filters GetTagsFilter[]
sorts GetTagsSort[]
id str
The provider-assigned unique ID for this managed resource.
tags Sequence[GetTagsTag]
filters Sequence[GetTagsFilter]
sorts Sequence[GetTagsSort]
id String
The provider-assigned unique ID for this managed resource.
tags List<Property Map>
filters List<Property Map>
sorts List<Property Map>

Supporting Types

GetTagsFilter

Key This property is required. string
Filter the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
Values This property is required. List<string>
Only retrieves tags which keys has value that matches one of the values provided here.
All bool
Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
MatchBy string
One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.
Key This property is required. string
Filter the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
Values This property is required. []string
Only retrieves tags which keys has value that matches one of the values provided here.
All bool
Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
MatchBy string
One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.
key This property is required. String
Filter the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
values This property is required. List<String>
Only retrieves tags which keys has value that matches one of the values provided here.
all Boolean
Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
matchBy String
One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.
key This property is required. string
Filter the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
values This property is required. string[]
Only retrieves tags which keys has value that matches one of the values provided here.
all boolean
Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
matchBy string
One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.
key This property is required. str
Filter the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
values This property is required. Sequence[str]
Only retrieves tags which keys has value that matches one of the values provided here.
all bool
Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
match_by str
One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.
key This property is required. String
Filter the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
values This property is required. List<String>
Only retrieves tags which keys has value that matches one of the values provided here.
all Boolean
Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
matchBy String
One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

GetTagsSort

Key This property is required. string
Sort the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
Direction string
The sort direction. This may be either asc or desc.
Key This property is required. string
Sort the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
Direction string
The sort direction. This may be either asc or desc.
key This property is required. String
Sort the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
direction String
The sort direction. This may be either asc or desc.
key This property is required. string
Sort the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
direction string
The sort direction. This may be either asc or desc.
key This property is required. str
Sort the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
direction str
The sort direction. This may be either asc or desc.
key This property is required. String
Sort the tags by this key. This may be one of name, total_resource_count, droplets_count, images_count, volumes_count, volume_snapshots_count, or databases_count.
direction String
The sort direction. This may be either asc or desc.

GetTagsTag

DatabasesCount This property is required. int
A count of the database clusters that the tag is applied to.
DropletsCount This property is required. int
A count of the Droplets the tag is applied to.
ImagesCount This property is required. int
A count of the images that the tag is applied to.
Name This property is required. string
The name of the tag.
TotalResourceCount This property is required. int
A count of the total number of resources that the tag is applied to.
VolumeSnapshotsCount This property is required. int
A count of the volume snapshots that the tag is applied to.
VolumesCount This property is required. int
A count of the volumes that the tag is applied to.
DatabasesCount This property is required. int
A count of the database clusters that the tag is applied to.
DropletsCount This property is required. int
A count of the Droplets the tag is applied to.
ImagesCount This property is required. int
A count of the images that the tag is applied to.
Name This property is required. string
The name of the tag.
TotalResourceCount This property is required. int
A count of the total number of resources that the tag is applied to.
VolumeSnapshotsCount This property is required. int
A count of the volume snapshots that the tag is applied to.
VolumesCount This property is required. int
A count of the volumes that the tag is applied to.
databasesCount This property is required. Integer
A count of the database clusters that the tag is applied to.
dropletsCount This property is required. Integer
A count of the Droplets the tag is applied to.
imagesCount This property is required. Integer
A count of the images that the tag is applied to.
name This property is required. String
The name of the tag.
totalResourceCount This property is required. Integer
A count of the total number of resources that the tag is applied to.
volumeSnapshotsCount This property is required. Integer
A count of the volume snapshots that the tag is applied to.
volumesCount This property is required. Integer
A count of the volumes that the tag is applied to.
databasesCount This property is required. number
A count of the database clusters that the tag is applied to.
dropletsCount This property is required. number
A count of the Droplets the tag is applied to.
imagesCount This property is required. number
A count of the images that the tag is applied to.
name This property is required. string
The name of the tag.
totalResourceCount This property is required. number
A count of the total number of resources that the tag is applied to.
volumeSnapshotsCount This property is required. number
A count of the volume snapshots that the tag is applied to.
volumesCount This property is required. number
A count of the volumes that the tag is applied to.
databases_count This property is required. int
A count of the database clusters that the tag is applied to.
droplets_count This property is required. int
A count of the Droplets the tag is applied to.
images_count This property is required. int
A count of the images that the tag is applied to.
name This property is required. str
The name of the tag.
total_resource_count This property is required. int
A count of the total number of resources that the tag is applied to.
volume_snapshots_count This property is required. int
A count of the volume snapshots that the tag is applied to.
volumes_count This property is required. int
A count of the volumes that the tag is applied to.
databasesCount This property is required. Number
A count of the database clusters that the tag is applied to.
dropletsCount This property is required. Number
A count of the Droplets the tag is applied to.
imagesCount This property is required. Number
A count of the images that the tag is applied to.
name This property is required. String
The name of the tag.
totalResourceCount This property is required. Number
A count of the total number of resources that the tag is applied to.
volumeSnapshotsCount This property is required. Number
A count of the volume snapshots that the tag is applied to.
volumesCount This property is required. 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 v4.42.0 published on Thursday, Apr 17, 2025 by Pulumi