Show / Hide Table of Contents

Class GetSizes

Inheritance
System.Object
GetSizes
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.DigitalOcean
Assembly: Pulumi.DigitalOcean.dll
Syntax
public static class GetSizes

Methods

View Source

InvokeAsync(GetSizesArgs, InvokeOptions)

Retrieves information about the Droplet sizes that DigitalOcean supports, with the ability to filter and sort the results. If no filters are specified, all sizes will be returned.

{{% examples %}}

Example Usage

{{% example %}}

Most common usage will probably be to supply a size to droplet:

using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

class MyStack : Stack
{
public MyStack()
{
    var main = Output.Create(DigitalOcean.GetSizes.InvokeAsync(new DigitalOcean.GetSizesArgs
    {
        Filter = 
        {

            {
                { "key", "slug" },
                { "values", 
                {
                    "s-1vcpu-1gb",
                } },
            },
        },
    }));
    var web = new DigitalOcean.Droplet("web", new DigitalOcean.DropletArgs
    {
        Image = "ubuntu-18-04-x64",
        Region = "sgp1",
        Size = main.Apply(main => main.Sizes)[0].Apply(sizes => sizes.Slug),
    });
}

}

The data source also supports multiple filters and sorts. For example, to fetch sizes with 1 or 2 virtual CPU that are available "sgp1" region, then pick the cheapest one:

using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

class MyStack : Stack
{
public MyStack()
{
    var main = Output.Create(DigitalOcean.GetSizes.InvokeAsync(new DigitalOcean.GetSizesArgs
    {
        Filter = 
        {

            {
                { "key", "vcpus" },
                { "values", 
                {
                    1,
                    2,
                } },
            },

            {
                { "key", "regions" },
                { "values", 
                {
                    "sgp1",
                } },
            },
        },
        Sort = 
        {

            {
                { "key", "price_monthly" },
                { "direction", "asc" },
            },
        },
    }));
    var web = new DigitalOcean.Droplet("web", new DigitalOcean.DropletArgs
    {
        Image = "ubuntu-18-04-x64",
        Region = "sgp1",
        Size = main.Apply(main => main.Sizes)[0].Apply(sizes => sizes.Slug),
    });
}

}

The data source can also handle multiple sorts. In which case, the sort will be applied in the order it is defined. For example, to sort by memory in ascending order, then sort by disk in descending order between sizes with same memory:

using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

class MyStack : Stack
{
public MyStack()
{
    var main = Output.Create(DigitalOcean.GetSizes.InvokeAsync(new DigitalOcean.GetSizesArgs
    {
        Sorts = 
        {
            new DigitalOcean.Inputs.GetSizesSortArgs
            {
                Direction = "asc",
                Key = "memory",
            },
            new DigitalOcean.Inputs.GetSizesSortArgs
            {
                Direction = "desc",
                Key = "disk",
            },
        },
    }));
}

}

{{% /example %}} {{% /examples %}}

Declaration
public static Task<GetSizesResult> InvokeAsync(GetSizesArgs args = null, InvokeOptions options = null)
Parameters
Type Name Description
GetSizesArgs args
InvokeOptions options
Returns
Type Description
System.Threading.Tasks.Task<GetSizesResult>
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.