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"],
}],
});
import pulumi
import pulumi_digitalocean as digitalocean
staging = digitalocean.get_projects(filters=[{
"key": "environment",
"values": ["Staging"],
}])
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
})
}
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",
},
},
},
});
});
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());
}
}
variables:
staging:
fn::invoke:
function: digitalocean:getProjects
arguments:
filters:
- key: environment
values:
- Staging
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",
}],
});
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",
}])
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
})
}
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",
},
},
});
});
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());
}
}
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
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>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]func GetProjects(ctx *Context, args *GetProjectsArgs, opts ...InvokeOption) (*GetProjectsResult, error)
func GetProjectsOutput(ctx *Context, args *GetProjectsOutputArgs, opts ...InvokeOption) GetProjectsResultOutput> 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)
}public static CompletableFuture<GetProjectsResult> getProjects(GetProjectsArgs args, InvokeOptions options)
public static Output<GetProjectsResult> getProjects(GetProjectsArgs args, InvokeOptions options)
fn::invoke:
function: digitalocean:index/getProjects:getProjects
arguments:
# arguments dictionaryThe following arguments are supported:
- Filters
List<Pulumi.
Digital Ocean. Inputs. Get Projects Filter> - Filter the results.
The
filterblock is documented below. - Sorts
List<Pulumi.
Digital Ocean. Inputs. Get Projects Sort> - Sort the results.
The
sortblock is documented below.
- Filters
[]Get
Projects Filter - Filter the results.
The
filterblock is documented below. - Sorts
[]Get
Projects Sort - Sort the results.
The
sortblock is documented below.
- filters
List<Get
Projects Filter> - Filter the results.
The
filterblock is documented below. - sorts
List<Get
Projects Sort> - Sort the results.
The
sortblock is documented below.
- filters
Get
Projects Filter[] - Filter the results.
The
filterblock is documented below. - sorts
Get
Projects Sort[] - Sort the results.
The
sortblock is documented below.
- filters
Sequence[Get
Projects Filter] - Filter the results.
The
filterblock is documented below. - sorts
Sequence[Get
Projects 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.
getProjects Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Projects
List<Pulumi.
Digital Ocean. Outputs. Get Projects Project> - A set of projects satisfying any
filterandsortcriteria. Each project has the following attributes: - Filters
List<Pulumi.
Digital Ocean. Outputs. Get Projects Filter> - Sorts
List<Pulumi.
Digital Ocean. Outputs. Get Projects Sort>
- Id string
- The provider-assigned unique ID for this managed resource.
- Projects
[]Get
Projects Project - A set of projects satisfying any
filterandsortcriteria. Each project has the following attributes: - Filters
[]Get
Projects Filter - Sorts
[]Get
Projects Sort
- id String
- The provider-assigned unique ID for this managed resource.
- projects
List<Get
Projects Project> - A set of projects satisfying any
filterandsortcriteria. Each project has the following attributes: - filters
List<Get
Projects Filter> - sorts
List<Get
Projects Sort>
- id string
- The provider-assigned unique ID for this managed resource.
- projects
Get
Projects Project[] - A set of projects satisfying any
filterandsortcriteria. Each project has the following attributes: - filters
Get
Projects Filter[] - sorts
Get
Projects Sort[]
- id str
- The provider-assigned unique ID for this managed resource.
- projects
Sequence[Get
Projects Project] - A set of projects satisfying any
filterandsortcriteria. Each project has the following attributes: - filters
Sequence[Get
Projects Filter] - sorts
Sequence[Get
Projects Sort]
- id String
- The provider-assigned unique ID for this managed resource.
- projects List<Property Map>
- A set of projects satisfying any
filterandsortcriteria. Each project has the following attributes: - filters List<Property Map>
- sorts List<Property Map>
Supporting Types
GetProjectsFilter
- Key string
- Filter the projects by this key. This may be one of
name,purpose,description,environment, oris_default. - Values List<string>
- A list of values to match against the
keyfield. Only retrieves projects where thekeyfield takes on one or more 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 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 projects by this key. This may be one of
name,purpose,description,environment, oris_default. - Values []string
- A list of values to match against the
keyfield. Only retrieves projects where thekeyfield takes on one or more 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 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 projects by this key. This may be one of
name,purpose,description,environment, oris_default. - values List<String>
- A list of values to match against the
keyfield. Only retrieves projects where thekeyfield takes on one or more 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. - match
By 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 projects by this key. This may be one of
name,purpose,description,environment, oris_default. - values string[]
- A list of values to match against the
keyfield. Only retrieves projects where thekeyfield takes on one or more 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. - match
By 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 projects by this key. This may be one of
name,purpose,description,environment, oris_default. - values Sequence[str]
- A list of values to match against the
keyfield. Only retrieves projects where thekeyfield takes on one or more 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 projects by this key. This may be one of
name,purpose,description,environment, oris_default. - values List<String>
- A list of values to match against the
keyfield. Only retrieves projects where thekeyfield takes on one or more 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. - match
By 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.
GetProjectsProject
- Created
At string - The date and time when the project was created, (ISO8601)
- Description string
- The description of the project
- Environment string
- The environment of the project's resources. The possible values are:
Development,Staging,Production. - Id string
- The ID of the project
- Is
Default bool - Name string
- The name of the project
- Owner
Id int - The ID of the project owner
- Owner
Uuid string - The unique universal identifier of the project owner
- Purpose string
- The purpose of the project (Default: "Web Application")
- Resources List<string>
- A set of uniform resource names (URNs) for the resources associated with the project
- Updated
At string - The date and time when the project was last updated, (ISO8601)
- Created
At string - The date and time when the project was created, (ISO8601)
- Description string
- The description of the project
- Environment string
- The environment of the project's resources. The possible values are:
Development,Staging,Production. - Id string
- The ID of the project
- Is
Default bool - Name string
- The name of the project
- Owner
Id int - The ID of the project owner
- Owner
Uuid string - The unique universal identifier of the project owner
- Purpose string
- The purpose of the project (Default: "Web Application")
- Resources []string
- A set of uniform resource names (URNs) for the resources associated with the project
- Updated
At string - The date and time when the project was last updated, (ISO8601)
- created
At String - The date and time when the project was created, (ISO8601)
- description String
- The description of the project
- environment String
- The environment of the project's resources. The possible values are:
Development,Staging,Production. - id String
- The ID of the project
- is
Default Boolean - name String
- The name of the project
- owner
Id Integer - The ID of the project owner
- owner
Uuid String - The unique universal identifier of the project owner
- purpose String
- The purpose of the project (Default: "Web Application")
- resources List<String>
- A set of uniform resource names (URNs) for the resources associated with the project
- updated
At String - The date and time when the project was last updated, (ISO8601)
- created
At string - The date and time when the project was created, (ISO8601)
- description string
- The description of the project
- environment string
- The environment of the project's resources. The possible values are:
Development,Staging,Production. - id string
- The ID of the project
- is
Default boolean - name string
- The name of the project
- owner
Id number - The ID of the project owner
- owner
Uuid string - The unique universal identifier of the project owner
- purpose string
- The purpose of the project (Default: "Web Application")
- resources string[]
- A set of uniform resource names (URNs) for the resources associated with the project
- updated
At string - The date and time when the project was last updated, (ISO8601)
- created_
at str - The date and time when the project was created, (ISO8601)
- description str
- The description of the project
- environment str
- The environment of the project's resources. The possible values are:
Development,Staging,Production. - id str
- The ID of the project
- is_
default bool - name str
- The name of the project
- owner_
id int - The ID of the project owner
- owner_
uuid str - The unique universal identifier of the project owner
- purpose str
- The purpose of the project (Default: "Web Application")
- resources Sequence[str]
- A set of uniform resource names (URNs) for the resources associated with the project
- updated_
at str - The date and time when the project was last updated, (ISO8601)
- created
At String - The date and time when the project was created, (ISO8601)
- description String
- The description of the project
- environment String
- The environment of the project's resources. The possible values are:
Development,Staging,Production. - id String
- The ID of the project
- is
Default Boolean - name String
- The name of the project
- owner
Id Number - The ID of the project owner
- owner
Uuid String - The unique universal identifier of the project owner
- purpose String
- The purpose of the project (Default: "Web Application")
- resources List<String>
- A set of uniform resource names (URNs) for the resources associated with the project
- updated
At String - The date and time when the project was last updated, (ISO8601)
GetProjectsSort
Package Details
- Repository
- DigitalOcean pulumi/pulumi-digitalocean
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
digitaloceanTerraform Provider.
