1. Packages
  2. DigitalOcean Provider
  3. API Docs
  4. getProjects
DigitalOcean v4.41.0 published on Wednesday, Mar 26, 2025 by Pulumi

digitalocean.getProjects

Explore with Pulumi AI

DigitalOcean v4.41.0 published on Wednesday, Mar 26, 2025 by Pulumi

Retrieve information about all DigitalOcean projects associated with an account, with the ability to filter and sort the results. If no filters are specified, all projects will be returned.

Note: You can use the digitalocean.Project data source to obtain metadata about a single project if you already know the id to retrieve or the unique name of the project.

Example Usage

Use the filter block with a key string and values list to filter projects.

For example to find all staging environment projects:

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

const staging = digitalocean.getProjects({
    filters: [{
        key: "environment",
        values: ["Staging"],
    }],
});
Copy
import pulumi
import pulumi_digitalocean as digitalocean

staging = digitalocean.get_projects(filters=[{
    "key": "environment",
    "values": ["Staging"],
}])
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 {
		_, err := digitalocean.GetProjects(ctx, &digitalocean.GetProjectsArgs{
			Filters: []digitalocean.GetProjectsFilter{
				{
					Key: "environment",
					Values: []string{
						"Staging",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var staging = DigitalOcean.GetProjects.Invoke(new()
    {
        Filters = new[]
        {
            new DigitalOcean.Inputs.GetProjectsFilterInputArgs
            {
                Key = "environment",
                Values = new[]
                {
                    "Staging",
                },
            },
        },
    });

});
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.GetProjectsArgs;
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 staging = DigitaloceanFunctions.getProjects(GetProjectsArgs.builder()
            .filters(GetProjectsFilterArgs.builder()
                .key("environment")
                .values("Staging")
                .build())
            .build());

    }
}
Copy
variables:
  staging:
    fn::invoke:
      function: digitalocean:getProjects
      arguments:
        filters:
          - key: environment
            values:
              - Staging
Copy

You can filter on multiple fields and sort the results as well:

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

const non_default_production = digitalocean.getProjects({
    filters: [
        {
            key: "environment",
            values: ["Production"],
        },
        {
            key: "is_default",
            values: ["false"],
        },
    ],
    sorts: [{
        key: "name",
        direction: "asc",
    }],
});
Copy
import pulumi
import pulumi_digitalocean as digitalocean

non_default_production = digitalocean.get_projects(filters=[
        {
            "key": "environment",
            "values": ["Production"],
        },
        {
            "key": "is_default",
            "values": ["false"],
        },
    ],
    sorts=[{
        "key": "name",
        "direction": "asc",
    }])
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 {
		_, err := digitalocean.GetProjects(ctx, &digitalocean.GetProjectsArgs{
			Filters: []digitalocean.GetProjectsFilter{
				{
					Key: "environment",
					Values: []string{
						"Production",
					},
				},
				{
					Key: "is_default",
					Values: []string{
						"false",
					},
				},
			},
			Sorts: []digitalocean.GetProjectsSort{
				{
					Key:       "name",
					Direction: pulumi.StringRef("asc"),
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var non_default_production = DigitalOcean.GetProjects.Invoke(new()
    {
        Filters = new[]
        {
            new DigitalOcean.Inputs.GetProjectsFilterInputArgs
            {
                Key = "environment",
                Values = new[]
                {
                    "Production",
                },
            },
            new DigitalOcean.Inputs.GetProjectsFilterInputArgs
            {
                Key = "is_default",
                Values = new[]
                {
                    "false",
                },
            },
        },
        Sorts = new[]
        {
            new DigitalOcean.Inputs.GetProjectsSortInputArgs
            {
                Key = "name",
                Direction = "asc",
            },
        },
    });

});
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.GetProjectsArgs;
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 non-default-production = DigitaloceanFunctions.getProjects(GetProjectsArgs.builder()
            .filters(            
                GetProjectsFilterArgs.builder()
                    .key("environment")
                    .values("Production")
                    .build(),
                GetProjectsFilterArgs.builder()
                    .key("is_default")
                    .values("false")
                    .build())
            .sorts(GetProjectsSortArgs.builder()
                .key("name")
                .direction("asc")
                .build())
            .build());

    }
}
Copy
variables:
  non-default-production:
    fn::invoke:
      function: digitalocean:getProjects
      arguments:
        filters:
          - key: environment
            values:
              - Production
          - key: is_default
            values:
              - 'false'
        sorts:
          - key: name
            direction: asc
Copy

Using getProjects

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 getProjects(args: GetProjectsArgs, opts?: InvokeOptions): Promise<GetProjectsResult>
function getProjectsOutput(args: GetProjectsOutputArgs, opts?: InvokeOptions): Output<GetProjectsResult>
Copy
def get_projects(filters: Optional[Sequence[GetProjectsFilter]] = None,
                 sorts: Optional[Sequence[GetProjectsSort]] = None,
                 opts: Optional[InvokeOptions] = None) -> GetProjectsResult
def get_projects_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetProjectsFilterArgs]]]] = None,
                 sorts: Optional[pulumi.Input[Sequence[pulumi.Input[GetProjectsSortArgs]]]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetProjectsResult]
Copy
func GetProjects(ctx *Context, args *GetProjectsArgs, opts ...InvokeOption) (*GetProjectsResult, error)
func GetProjectsOutput(ctx *Context, args *GetProjectsOutputArgs, opts ...InvokeOption) GetProjectsResultOutput
Copy

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

public static class GetProjects 
{
    public static Task<GetProjectsResult> InvokeAsync(GetProjectsArgs args, InvokeOptions? opts = null)
    public static Output<GetProjectsResult> Invoke(GetProjectsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetProjectsResult> getProjects(GetProjectsArgs args, InvokeOptions options)
public static Output<GetProjectsResult> getProjects(GetProjectsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: digitalocean:index/getProjects:getProjects
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Filters List<Pulumi.DigitalOcean.Inputs.GetProjectsFilter>
Filter the results. The filter block is documented below.
Sorts List<Pulumi.DigitalOcean.Inputs.GetProjectsSort>
Sort the results. The sort block is documented below.
Filters []GetProjectsFilter
Filter the results. The filter block is documented below.
Sorts []GetProjectsSort
Sort the results. The sort block is documented below.
filters List<GetProjectsFilter>
Filter the results. The filter block is documented below.
sorts List<GetProjectsSort>
Sort the results. The sort block is documented below.
filters GetProjectsFilter[]
Filter the results. The filter block is documented below.
sorts GetProjectsSort[]
Sort the results. The sort block is documented below.
filters Sequence[GetProjectsFilter]
Filter the results. The filter block is documented below.
sorts Sequence[GetProjectsSort]
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.

getProjects Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Projects List<Pulumi.DigitalOcean.Outputs.GetProjectsProject>
A set of projects satisfying any filter and sort criteria. Each project has the following attributes:
Filters List<Pulumi.DigitalOcean.Outputs.GetProjectsFilter>
Sorts List<Pulumi.DigitalOcean.Outputs.GetProjectsSort>
Id string
The provider-assigned unique ID for this managed resource.
Projects []GetProjectsProject
A set of projects satisfying any filter and sort criteria. Each project has the following attributes:
Filters []GetProjectsFilter
Sorts []GetProjectsSort
id String
The provider-assigned unique ID for this managed resource.
projects List<GetProjectsProject>
A set of projects satisfying any filter and sort criteria. Each project has the following attributes:
filters List<GetProjectsFilter>
sorts List<GetProjectsSort>
id string
The provider-assigned unique ID for this managed resource.
projects GetProjectsProject[]
A set of projects satisfying any filter and sort criteria. Each project has the following attributes:
filters GetProjectsFilter[]
sorts GetProjectsSort[]
id str
The provider-assigned unique ID for this managed resource.
projects Sequence[GetProjectsProject]
A set of projects satisfying any filter and sort criteria. Each project has the following attributes:
filters Sequence[GetProjectsFilter]
sorts Sequence[GetProjectsSort]
id String
The provider-assigned unique ID for this managed resource.
projects List<Property Map>
A set of projects satisfying any filter and sort criteria. Each project has the following attributes:
filters List<Property Map>
sorts List<Property Map>

Supporting Types

GetProjectsFilter

Key This property is required. string
Filter the projects by this key. This may be one of name, purpose, description, environment, or is_default.
Values This property is required. List<string>
A list of values to match against the key field. Only retrieves projects where the key field takes on one or more 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 projects by this key. This may be one of name, purpose, description, environment, or is_default.
Values This property is required. []string
A list of values to match against the key field. Only retrieves projects where the key field takes on one or more 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 projects by this key. This may be one of name, purpose, description, environment, or is_default.
values This property is required. List<String>
A list of values to match against the key field. Only retrieves projects where the key field takes on one or more 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 projects by this key. This may be one of name, purpose, description, environment, or is_default.
values This property is required. string[]
A list of values to match against the key field. Only retrieves projects where the key field takes on one or more 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 projects by this key. This may be one of name, purpose, description, environment, or is_default.
values This property is required. Sequence[str]
A list of values to match against the key field. Only retrieves projects where the key field takes on one or more 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 projects by this key. This may be one of name, purpose, description, environment, or is_default.
values This property is required. List<String>
A list of values to match against the key field. Only retrieves projects where the key field takes on one or more 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.

GetProjectsProject

CreatedAt This property is required. string
The date and time when the project was created, (ISO8601)
Description This property is required. string
The description of the project
Environment This property is required. string
The environment of the project's resources. The possible values are: Development, Staging, Production.
Id This property is required. string
The ID of the project
IsDefault This property is required. bool
Name This property is required. string
The name of the project
OwnerId This property is required. int
The ID of the project owner
OwnerUuid This property is required. string
The unique universal identifier of the project owner
Purpose This property is required. string
The purpose of the project (Default: "Web Application")
Resources This property is required. List<string>
A set of uniform resource names (URNs) for the resources associated with the project
UpdatedAt This property is required. string
The date and time when the project was last updated, (ISO8601)
CreatedAt This property is required. string
The date and time when the project was created, (ISO8601)
Description This property is required. string
The description of the project
Environment This property is required. string
The environment of the project's resources. The possible values are: Development, Staging, Production.
Id This property is required. string
The ID of the project
IsDefault This property is required. bool
Name This property is required. string
The name of the project
OwnerId This property is required. int
The ID of the project owner
OwnerUuid This property is required. string
The unique universal identifier of the project owner
Purpose This property is required. string
The purpose of the project (Default: "Web Application")
Resources This property is required. []string
A set of uniform resource names (URNs) for the resources associated with the project
UpdatedAt This property is required. string
The date and time when the project was last updated, (ISO8601)
createdAt This property is required. String
The date and time when the project was created, (ISO8601)
description This property is required. String
The description of the project
environment This property is required. String
The environment of the project's resources. The possible values are: Development, Staging, Production.
id This property is required. String
The ID of the project
isDefault This property is required. Boolean
name This property is required. String
The name of the project
ownerId This property is required. Integer
The ID of the project owner
ownerUuid This property is required. String
The unique universal identifier of the project owner
purpose This property is required. String
The purpose of the project (Default: "Web Application")
resources This property is required. List<String>
A set of uniform resource names (URNs) for the resources associated with the project
updatedAt This property is required. String
The date and time when the project was last updated, (ISO8601)
createdAt This property is required. string
The date and time when the project was created, (ISO8601)
description This property is required. string
The description of the project
environment This property is required. string
The environment of the project's resources. The possible values are: Development, Staging, Production.
id This property is required. string
The ID of the project
isDefault This property is required. boolean
name This property is required. string
The name of the project
ownerId This property is required. number
The ID of the project owner
ownerUuid This property is required. string
The unique universal identifier of the project owner
purpose This property is required. string
The purpose of the project (Default: "Web Application")
resources This property is required. string[]
A set of uniform resource names (URNs) for the resources associated with the project
updatedAt This property is required. string
The date and time when the project was last updated, (ISO8601)
created_at This property is required. str
The date and time when the project was created, (ISO8601)
description This property is required. str
The description of the project
environment This property is required. str
The environment of the project's resources. The possible values are: Development, Staging, Production.
id This property is required. str
The ID of the project
is_default This property is required. bool
name This property is required. str
The name of the project
owner_id This property is required. int
The ID of the project owner
owner_uuid This property is required. str
The unique universal identifier of the project owner
purpose This property is required. str
The purpose of the project (Default: "Web Application")
resources This property is required. Sequence[str]
A set of uniform resource names (URNs) for the resources associated with the project
updated_at This property is required. str
The date and time when the project was last updated, (ISO8601)
createdAt This property is required. String
The date and time when the project was created, (ISO8601)
description This property is required. String
The description of the project
environment This property is required. String
The environment of the project's resources. The possible values are: Development, Staging, Production.
id This property is required. String
The ID of the project
isDefault This property is required. Boolean
name This property is required. String
The name of the project
ownerId This property is required. Number
The ID of the project owner
ownerUuid This property is required. String
The unique universal identifier of the project owner
purpose This property is required. String
The purpose of the project (Default: "Web Application")
resources This property is required. List<String>
A set of uniform resource names (URNs) for the resources associated with the project
updatedAt This property is required. String
The date and time when the project was last updated, (ISO8601)

GetProjectsSort

Key This property is required. string
Sort the projects by this key. This may be one of name, purpose, description, or environment.
Direction string
The sort direction. This may be either asc or desc.
Key This property is required. string
Sort the projects by this key. This may be one of name, purpose, description, or environment.
Direction string
The sort direction. This may be either asc or desc.
key This property is required. String
Sort the projects by this key. This may be one of name, purpose, description, or environment.
direction String
The sort direction. This may be either asc or desc.
key This property is required. string
Sort the projects by this key. This may be one of name, purpose, description, or environment.
direction string
The sort direction. This may be either asc or desc.
key This property is required. str
Sort the projects by this key. This may be one of name, purpose, description, or environment.
direction str
The sort direction. This may be either asc or desc.
key This property is required. String
Sort the projects by this key. This may be one of name, purpose, description, or environment.
direction String
The sort direction. This may be either asc or desc.

Package Details

Repository
DigitalOcean pulumi/pulumi-digitalocean
License
Apache-2.0
Notes
This Pulumi package is based on the digitalocean Terraform Provider.
DigitalOcean v4.41.0 published on Wednesday, Mar 26, 2025 by Pulumi