1. Packages
  2. Digitalocean Provider
  3. API Docs
  4. getRegions
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

digitalocean.getRegions

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Retrieve information about all supported DigitalOcean regions, with the ability to filter and sort the results. If no filters are specified, all regions will be returned.

    Note: You can use the digitalocean.getRegion data source to obtain metadata about a single region if you already know the slug to retrieve.

    Example Usage

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

    For example to find all available regions:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const available = digitalocean.getRegions({
        filters: [{
            key: "available",
            values: ["true"],
        }],
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    available = digitalocean.get_regions(filters=[{
        "key": "available",
        "values": ["true"],
    }])
    
    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.GetRegions(ctx, &digitalocean.GetRegionsArgs{
    			Filters: []digitalocean.GetRegionsFilter{
    				{
    					Key: "available",
    					Values: []string{
    						"true",
    					},
    				},
    			},
    		}, 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 available = DigitalOcean.GetRegions.Invoke(new()
        {
            Filters = new[]
            {
                new DigitalOcean.Inputs.GetRegionsFilterInputArgs
                {
                    Key = "available",
                    Values = new[]
                    {
                        "true",
                    },
                },
            },
        });
    
    });
    
    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.GetRegionsArgs;
    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 available = DigitaloceanFunctions.getRegions(GetRegionsArgs.builder()
                .filters(GetRegionsFilterArgs.builder()
                    .key("available")
                    .values("true")
                    .build())
                .build());
    
        }
    }
    
    variables:
      available:
        fn::invoke:
          Function: digitalocean:getRegions
          Arguments:
            filters:
              - key: available
                values:
                  - 'true'
    

    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 available = digitalocean.getRegions({
        filters: [
            {
                key: "available",
                values: ["true"],
            },
            {
                key: "features",
                values: ["private_networking"],
            },
        ],
        sorts: [{
            key: "name",
            direction: "desc",
        }],
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    available = digitalocean.get_regions(filters=[
            {
                "key": "available",
                "values": ["true"],
            },
            {
                "key": "features",
                "values": ["private_networking"],
            },
        ],
        sorts=[{
            "key": "name",
            "direction": "desc",
        }])
    
    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.GetRegions(ctx, &digitalocean.GetRegionsArgs{
    			Filters: []digitalocean.GetRegionsFilter{
    				{
    					Key: "available",
    					Values: []string{
    						"true",
    					},
    				},
    				{
    					Key: "features",
    					Values: []string{
    						"private_networking",
    					},
    				},
    			},
    			Sorts: []digitalocean.GetRegionsSort{
    				{
    					Key:       "name",
    					Direction: pulumi.StringRef("desc"),
    				},
    			},
    		}, 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 available = DigitalOcean.GetRegions.Invoke(new()
        {
            Filters = new[]
            {
                new DigitalOcean.Inputs.GetRegionsFilterInputArgs
                {
                    Key = "available",
                    Values = new[]
                    {
                        "true",
                    },
                },
                new DigitalOcean.Inputs.GetRegionsFilterInputArgs
                {
                    Key = "features",
                    Values = new[]
                    {
                        "private_networking",
                    },
                },
            },
            Sorts = new[]
            {
                new DigitalOcean.Inputs.GetRegionsSortInputArgs
                {
                    Key = "name",
                    Direction = "desc",
                },
            },
        });
    
    });
    
    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.GetRegionsArgs;
    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 available = DigitaloceanFunctions.getRegions(GetRegionsArgs.builder()
                .filters(            
                    GetRegionsFilterArgs.builder()
                        .key("available")
                        .values("true")
                        .build(),
                    GetRegionsFilterArgs.builder()
                        .key("features")
                        .values("private_networking")
                        .build())
                .sorts(GetRegionsSortArgs.builder()
                    .key("name")
                    .direction("desc")
                    .build())
                .build());
    
        }
    }
    
    variables:
      available:
        fn::invoke:
          Function: digitalocean:getRegions
          Arguments:
            filters:
              - key: available
                values:
                  - 'true'
              - key: features
                values:
                  - private_networking
            sorts:
              - key: name
                direction: desc
    

    Using getRegions

    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 getRegions(args: GetRegionsArgs, opts?: InvokeOptions): Promise<GetRegionsResult>
    function getRegionsOutput(args: GetRegionsOutputArgs, opts?: InvokeOptions): Output<GetRegionsResult>
    def get_regions(filters: Optional[Sequence[GetRegionsFilter]] = None,
                    sorts: Optional[Sequence[GetRegionsSort]] = None,
                    opts: Optional[InvokeOptions] = None) -> GetRegionsResult
    def get_regions_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetRegionsFilterArgs]]]] = None,
                    sorts: Optional[pulumi.Input[Sequence[pulumi.Input[GetRegionsSortArgs]]]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetRegionsResult]
    func GetRegions(ctx *Context, args *GetRegionsArgs, opts ...InvokeOption) (*GetRegionsResult, error)
    func GetRegionsOutput(ctx *Context, args *GetRegionsOutputArgs, opts ...InvokeOption) GetRegionsResultOutput

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

    public static class GetRegions 
    {
        public static Task<GetRegionsResult> InvokeAsync(GetRegionsArgs args, InvokeOptions? opts = null)
        public static Output<GetRegionsResult> Invoke(GetRegionsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetRegionsResult> getRegions(GetRegionsArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: digitalocean:index/getRegions:getRegions
      arguments:
        # arguments dictionary

    The following arguments are supported:

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

    getRegions Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Regions List<Pulumi.DigitalOcean.Outputs.GetRegionsRegion>
    A set of regions satisfying any filter and sort criteria. Each region has the following attributes:
    Filters List<Pulumi.DigitalOcean.Outputs.GetRegionsFilter>
    Sorts List<Pulumi.DigitalOcean.Outputs.GetRegionsSort>
    Id string
    The provider-assigned unique ID for this managed resource.
    Regions []GetRegionsRegion
    A set of regions satisfying any filter and sort criteria. Each region has the following attributes:
    Filters []GetRegionsFilter
    Sorts []GetRegionsSort
    id String
    The provider-assigned unique ID for this managed resource.
    regions List<GetRegionsRegion>
    A set of regions satisfying any filter and sort criteria. Each region has the following attributes:
    filters List<GetRegionsFilter>
    sorts List<GetRegionsSort>
    id string
    The provider-assigned unique ID for this managed resource.
    regions GetRegionsRegion[]
    A set of regions satisfying any filter and sort criteria. Each region has the following attributes:
    filters GetRegionsFilter[]
    sorts GetRegionsSort[]
    id str
    The provider-assigned unique ID for this managed resource.
    regions Sequence[GetRegionsRegion]
    A set of regions satisfying any filter and sort criteria. Each region has the following attributes:
    filters Sequence[GetRegionsFilter]
    sorts Sequence[GetRegionsSort]
    id String
    The provider-assigned unique ID for this managed resource.
    regions List<Property Map>
    A set of regions satisfying any filter and sort criteria. Each region has the following attributes:
    filters List<Property Map>
    sorts List<Property Map>

    Supporting Types

    GetRegionsFilter

    Key string
    Filter the regions by this key. This may be one of slug, name, available, features, or sizes.
    Values List<string>
    A list of values to match against the key field. Only retrieves regions 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 string
    Filter the regions by this key. This may be one of slug, name, available, features, or sizes.
    Values []string
    A list of values to match against the key field. Only retrieves regions 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 String
    Filter the regions by this key. This may be one of slug, name, available, features, or sizes.
    values List<String>
    A list of values to match against the key field. Only retrieves regions 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 string
    Filter the regions by this key. This may be one of slug, name, available, features, or sizes.
    values string[]
    A list of values to match against the key field. Only retrieves regions 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 str
    Filter the regions by this key. This may be one of slug, name, available, features, or sizes.
    values Sequence[str]
    A list of values to match against the key field. Only retrieves regions 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 String
    Filter the regions by this key. This may be one of slug, name, available, features, or sizes.
    values List<String>
    A list of values to match against the key field. Only retrieves regions 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.

    GetRegionsRegion

    Available bool
    A boolean value that represents whether new Droplets can be created in this region.
    Features List<string>
    A set of features available in this region.
    Name string
    The display name of the region.
    Sizes List<string>
    A set of identifying slugs for the Droplet sizes available in this region.
    Slug string
    A human-readable string that is used as a unique identifier for each region.
    Available bool
    A boolean value that represents whether new Droplets can be created in this region.
    Features []string
    A set of features available in this region.
    Name string
    The display name of the region.
    Sizes []string
    A set of identifying slugs for the Droplet sizes available in this region.
    Slug string
    A human-readable string that is used as a unique identifier for each region.
    available Boolean
    A boolean value that represents whether new Droplets can be created in this region.
    features List<String>
    A set of features available in this region.
    name String
    The display name of the region.
    sizes List<String>
    A set of identifying slugs for the Droplet sizes available in this region.
    slug String
    A human-readable string that is used as a unique identifier for each region.
    available boolean
    A boolean value that represents whether new Droplets can be created in this region.
    features string[]
    A set of features available in this region.
    name string
    The display name of the region.
    sizes string[]
    A set of identifying slugs for the Droplet sizes available in this region.
    slug string
    A human-readable string that is used as a unique identifier for each region.
    available bool
    A boolean value that represents whether new Droplets can be created in this region.
    features Sequence[str]
    A set of features available in this region.
    name str
    The display name of the region.
    sizes Sequence[str]
    A set of identifying slugs for the Droplet sizes available in this region.
    slug str
    A human-readable string that is used as a unique identifier for each region.
    available Boolean
    A boolean value that represents whether new Droplets can be created in this region.
    features List<String>
    A set of features available in this region.
    name String
    The display name of the region.
    sizes List<String>
    A set of identifying slugs for the Droplet sizes available in this region.
    slug String
    A human-readable string that is used as a unique identifier for each region.

    GetRegionsSort

    Key string
    Sort the regions by this key. This may be one of slug, name, or available.
    Direction string
    The sort direction. This may be either asc or desc.
    Key string
    Sort the regions by this key. This may be one of slug, name, or available.
    Direction string
    The sort direction. This may be either asc or desc.
    key String
    Sort the regions by this key. This may be one of slug, name, or available.
    direction String
    The sort direction. This may be either asc or desc.
    key string
    Sort the regions by this key. This may be one of slug, name, or available.
    direction string
    The sort direction. This may be either asc or desc.
    key str
    Sort the regions by this key. This may be one of slug, name, or available.
    direction str
    The sort direction. This may be either asc or desc.
    key String
    Sort the regions by this key. This may be one of slug, name, or available.
    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 logo
    DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi