DigitalOcean v4.40.2 published on Wednesday, Mar 19, 2025 by Pulumi
digitalocean.getTags
Explore with Pulumi AI
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);
import pulumi
import pulumi_digitalocean as digitalocean
list = digitalocean.get_tags(sorts=[{
    "key": "total_resource_count",
    "direction": "asc",
}])
pulumi.export("sortedTags", list.tags)
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
	})
}
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),
    };
});
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.applyValue(getTagsResult -> getTagsResult.tags()));
    }
}
variables:
  list:
    fn::invoke:
      function: digitalocean:getTags
      arguments:
        sorts:
          - key: total_resource_count
            direction: asc
outputs:
  sortedTags: ${list.tags}
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>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]func GetTags(ctx *Context, args *GetTagsArgs, opts ...InvokeOption) (*GetTagsResult, error)
func GetTagsOutput(ctx *Context, args *GetTagsOutputArgs, opts ...InvokeOption) GetTagsResultOutput> 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)
}public static CompletableFuture<GetTagsResult> getTags(GetTagsArgs args, InvokeOptions options)
public static Output<GetTagsResult> getTags(GetTagsArgs args, InvokeOptions options)
fn::invoke:
  function: digitalocean:index/getTags:getTags
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Filters
List<Pulumi.Digital Ocean. Inputs. Get Tags Filter> 
- Filter the results.
The filterblock is documented below.
- Sorts
List<Pulumi.Digital Ocean. Inputs. Get Tags Sort> 
- Sort the results.
The sortblock is documented below.
- Filters
[]GetTags Filter 
- Filter the results.
The filterblock is documented below.
- Sorts
[]GetTags Sort 
- Sort the results.
The sortblock is documented below.
- filters
List<GetTags Filter> 
- Filter the results.
The filterblock is documented below.
- sorts
List<GetTags Sort> 
- Sort the results.
The sortblock is documented below.
- filters
GetTags Filter[] 
- Filter the results.
The filterblock is documented below.
- sorts
GetTags Sort[] 
- Sort the results.
The sortblock is documented below.
- filters
Sequence[GetTags Filter] 
- Filter the results.
The filterblock is documented below.
- sorts
Sequence[GetTags Sort] 
- Sort the results.
The sortblock is documented below.
- filters List<Property Map>
- Filter the results.
The filterblock is documented below.
- sorts List<Property Map>
- Sort the results.
The sortblock is documented below.
getTags Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- 
List<Pulumi.Digital Ocean. Outputs. Get Tags Tag> 
- Filters
List<Pulumi.Digital Ocean. Outputs. Get Tags Filter> 
- Sorts
List<Pulumi.Digital Ocean. Outputs. Get Tags Sort> 
- Id string
- The provider-assigned unique ID for this managed resource.
- 
[]GetTags Tag 
- Filters
[]GetTags Filter 
- Sorts
[]GetTags Sort 
- id String
- The provider-assigned unique ID for this managed resource.
- 
List<GetTags Tag> 
- filters
List<GetTags Filter> 
- sorts
List<GetTags Sort> 
- id string
- The provider-assigned unique ID for this managed resource.
- 
GetTags Tag[] 
- filters
GetTags Filter[] 
- sorts
GetTags Sort[] 
- id str
- The provider-assigned unique ID for this managed resource.
- 
Sequence[GetTags Tag] 
- filters
Sequence[GetTags Filter] 
- sorts
Sequence[GetTags Sort] 
- id String
- The provider-assigned unique ID for this managed resource.
- List<Property Map>
- filters List<Property Map>
- sorts List<Property Map>
Supporting Types
GetTagsFilter  
- Key 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, ordatabases_count.
- Values List<string>
- Only retrieves tags which keys has value that matches one of the values provided here.
- All bool
- Set to trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set.
- MatchBy string
- One of exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas substrings to find within the string field.
- Key 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, ordatabases_count.
- Values []string
- Only retrieves tags which keys has value that matches one of the values provided here.
- All bool
- Set to trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set.
- MatchBy string
- One of exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas substrings to find within the string field.
- key 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, ordatabases_count.
- values List<String>
- Only retrieves tags which keys has value that matches one of the values provided here.
- all Boolean
- Set to trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set.
- matchBy String
- One of exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas substrings to find within the string field.
- key 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, ordatabases_count.
- values string[]
- Only retrieves tags which keys has value that matches one of the values provided here.
- all boolean
- Set to trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set.
- matchBy string
- One of exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas substrings to find within the string field.
- key 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, ordatabases_count.
- values Sequence[str]
- Only retrieves tags which keys has value that matches one of the values provided here.
- all bool
- Set to trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set.
- match_by str
- One of exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas substrings to find within the string field.
- key 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, ordatabases_count.
- values List<String>
- Only retrieves tags which keys has value that matches one of the values provided here.
- all Boolean
- Set to trueto require that a field match all of thevaluesinstead 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 thevaluesare present in the list or set.
- matchBy String
- One of exact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas substrings to find within the string field.
GetTagsSort  
GetTagsTag  
- 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.
- TotalResource intCount 
- A count of the total number of resources that the tag is applied to.
- VolumeSnapshots intCount 
- 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.
- TotalResource intCount 
- A count of the total number of resources that the tag is applied to.
- VolumeSnapshots intCount 
- 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.
- totalResource IntegerCount 
- A count of the total number of resources that the tag is applied to.
- volumeSnapshots IntegerCount 
- 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.
- totalResource numberCount 
- A count of the total number of resources that the tag is applied to.
- volumeSnapshots numberCount 
- 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_ 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.
- 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.
- totalResource NumberCount 
- A count of the total number of resources that the tag is applied to.
- volumeSnapshots NumberCount 
- 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 digitaloceanTerraform Provider.