UNPKG

@pulumi/digitalocean

Version:

A Pulumi package for creating and managing DigitalOcean cloud resources.

208 lines (207 loc) 6.18 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "./types/input"; import * as outputs from "./types/output"; /** * 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. * * ## Example Usage * * Most common usage will probably be to supply a size to Droplet: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const main = digitalocean.getSizes({ * filters: [{ * key: "slug", * values: ["s-1vcpu-1gb"], * }], * }); * const web = new digitalocean.Droplet("web", { * image: "ubuntu-18-04-x64", * name: "web-1", * region: digitalocean.Region.SGP1, * size: digitalocean.DropletSlug[main.then(main => main.sizes)[0].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: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const main = digitalocean.getSizes({ * filters: [ * { * key: "vcpus", * values: [ * "1", * "2", * ], * }, * { * key: "regions", * values: ["sgp1"], * }, * ], * sorts: [{ * key: "price_monthly", * direction: "asc", * }], * }); * const web = new digitalocean.Droplet("web", { * image: "ubuntu-18-04-x64", * name: "web-1", * region: digitalocean.Region.SGP1, * size: digitalocean.DropletSlug[main.then(main => main.sizes)[0].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: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const main = digitalocean.getSizes({ * sorts: [ * { * key: "memory", * direction: "asc", * }, * { * key: "disk", * direction: "desc", * }, * ], * }); * ``` */ export declare function getSizes(args?: GetSizesArgs, opts?: pulumi.InvokeOptions): Promise<GetSizesResult>; /** * A collection of arguments for invoking getSizes. */ export interface GetSizesArgs { /** * Filter the results. * The `filter` block is documented below. */ filters?: inputs.GetSizesFilter[]; /** * Sort the results. * The `sort` block is documented below. */ sorts?: inputs.GetSizesSort[]; } /** * A collection of values returned by getSizes. */ export interface GetSizesResult { readonly filters?: outputs.GetSizesFilter[]; /** * The provider-assigned unique ID for this managed resource. */ readonly id: string; readonly sizes: outputs.GetSizesSize[]; readonly sorts?: outputs.GetSizesSort[]; } /** * 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. * * ## Example Usage * * Most common usage will probably be to supply a size to Droplet: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const main = digitalocean.getSizes({ * filters: [{ * key: "slug", * values: ["s-1vcpu-1gb"], * }], * }); * const web = new digitalocean.Droplet("web", { * image: "ubuntu-18-04-x64", * name: "web-1", * region: digitalocean.Region.SGP1, * size: digitalocean.DropletSlug[main.then(main => main.sizes)[0].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: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const main = digitalocean.getSizes({ * filters: [ * { * key: "vcpus", * values: [ * "1", * "2", * ], * }, * { * key: "regions", * values: ["sgp1"], * }, * ], * sorts: [{ * key: "price_monthly", * direction: "asc", * }], * }); * const web = new digitalocean.Droplet("web", { * image: "ubuntu-18-04-x64", * name: "web-1", * region: digitalocean.Region.SGP1, * size: digitalocean.DropletSlug[main.then(main => main.sizes)[0].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: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const main = digitalocean.getSizes({ * sorts: [ * { * key: "memory", * direction: "asc", * }, * { * key: "disk", * direction: "desc", * }, * ], * }); * ``` */ export declare function getSizesOutput(args?: GetSizesOutputArgs, opts?: pulumi.InvokeOutputOptions): pulumi.Output<GetSizesResult>; /** * A collection of arguments for invoking getSizes. */ export interface GetSizesOutputArgs { /** * Filter the results. * The `filter` block is documented below. */ filters?: pulumi.Input<pulumi.Input<inputs.GetSizesFilterArgs>[]>; /** * Sort the results. * The `sort` block is documented below. */ sorts?: pulumi.Input<pulumi.Input<inputs.GetSizesSortArgs>[]>; }