@pulumi/digitalocean
Version:
A Pulumi package for creating and managing DigitalOcean cloud resources.
186 lines • 5.78 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSizesOutput = exports.getSizes = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* 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",
* },
* ],
* });
* ```
*/
function getSizes(args, opts) {
args = args || {};
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {});
return pulumi.runtime.invoke("digitalocean:index/getSizes:getSizes", {
"filters": args.filters,
"sorts": args.sorts,
}, opts);
}
exports.getSizes = getSizes;
/**
* 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",
* },
* ],
* });
* ```
*/
function getSizesOutput(args, opts) {
args = args || {};
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {});
return pulumi.runtime.invokeOutput("digitalocean:index/getSizes:getSizes", {
"filters": args.filters,
"sorts": args.sorts,
}, opts);
}
exports.getSizesOutput = getSizesOutput;
//# sourceMappingURL=getSizes.js.map