UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

254 lines • 9.35 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Autoscaler = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Represents an Autoscaler resource. * * Autoscalers allow you to automatically scale virtual machine instances in * managed instance groups according to an autoscaling policy that you * define. * * To get more information about Autoscaler, see: * * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/autoscalers) * * How-to Guides * * [Autoscaling Groups of Instances](https://cloud.google.com/compute/docs/autoscaler/) * * ## Example Usage * * ### Autoscaler Single Instance * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const debian9 = gcp.compute.getImage({ * family: "debian-11", * project: "debian-cloud", * }); * const defaultInstanceTemplate = new gcp.compute.InstanceTemplate("default", { * name: "my-instance-template", * machineType: "e2-medium", * canIpForward: false, * tags: [ * "foo", * "bar", * ], * disks: [{ * sourceImage: debian9.then(debian9 => debian9.id), * }], * networkInterfaces: [{ * network: "default", * }], * metadata: { * foo: "bar", * }, * serviceAccount: { * scopes: [ * "userinfo-email", * "compute-ro", * "storage-ro", * ], * }, * }); * const defaultTargetPool = new gcp.compute.TargetPool("default", {name: "my-target-pool"}); * const defaultInstanceGroupManager = new gcp.compute.InstanceGroupManager("default", { * name: "my-igm", * zone: "us-central1-f", * versions: [{ * instanceTemplate: defaultInstanceTemplate.id, * name: "primary", * }], * targetPools: [defaultTargetPool.id], * baseInstanceName: "autoscaler-sample", * }); * const _default = new gcp.compute.Autoscaler("default", { * name: "my-autoscaler", * zone: "us-central1-f", * target: defaultInstanceGroupManager.id, * autoscalingPolicy: { * maxReplicas: 5, * minReplicas: 1, * cooldownPeriod: 60, * stabilizationPeriod: 300, * metrics: [{ * name: "pubsub.googleapis.com/subscription/num_undelivered_messages", * filter: "resource.type = pubsub_subscription AND resource.label.subscription_id = our-subscription", * singleInstanceAssignment: 65535, * }], * }, * }); * ``` * ### Autoscaler Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const debian9 = gcp.compute.getImage({ * family: "debian-11", * project: "debian-cloud", * }); * const foobarInstanceTemplate = new gcp.compute.InstanceTemplate("foobar", { * name: "my-instance-template", * machineType: "e2-medium", * canIpForward: false, * tags: [ * "foo", * "bar", * ], * disks: [{ * sourceImage: debian9.then(debian9 => debian9.id), * }], * networkInterfaces: [{ * network: "default", * }], * metadata: { * foo: "bar", * }, * serviceAccount: { * scopes: [ * "userinfo-email", * "compute-ro", * "storage-ro", * ], * }, * }); * const foobarTargetPool = new gcp.compute.TargetPool("foobar", {name: "my-target-pool"}); * const foobarInstanceGroupManager = new gcp.compute.InstanceGroupManager("foobar", { * name: "my-igm", * zone: "us-central1-f", * versions: [{ * instanceTemplate: foobarInstanceTemplate.id, * name: "primary", * }], * targetPools: [foobarTargetPool.id], * baseInstanceName: "foobar", * }); * const foobar = new gcp.compute.Autoscaler("foobar", { * name: "my-autoscaler", * zone: "us-central1-f", * target: foobarInstanceGroupManager.id, * autoscalingPolicy: { * maxReplicas: 5, * minReplicas: 1, * cooldownPeriod: 60, * stabilizationPeriod: 300, * cpuUtilization: { * target: 0.5, * }, * }, * }); * ``` * * ## Import * * Autoscaler can be imported using any of these accepted formats: * * * `projects/{{project}}/zones/{{zone}}/autoscalers/{{name}}` * * `{{project}}/{{zone}}/{{name}}` * * `{{zone}}/{{name}}` * * `{{name}}` * * When using the `pulumi import` command, Autoscaler can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/autoscaler:Autoscaler default projects/{{project}}/zones/{{zone}}/autoscalers/{{name}} * $ pulumi import gcp:compute/autoscaler:Autoscaler default {{project}}/{{zone}}/{{name}} * $ pulumi import gcp:compute/autoscaler:Autoscaler default {{zone}}/{{name}} * $ pulumi import gcp:compute/autoscaler:Autoscaler default {{name}} * ``` */ class Autoscaler extends pulumi.CustomResource { /** * Get an existing Autoscaler resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Autoscaler(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:compute/autoscaler:Autoscaler'; /** * Returns true if the given object is an instance of Autoscaler. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Autoscaler.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["autoscalingPolicy"] = state?.autoscalingPolicy; resourceInputs["creationTimestamp"] = state?.creationTimestamp; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["description"] = state?.description; resourceInputs["name"] = state?.name; resourceInputs["project"] = state?.project; resourceInputs["selfLink"] = state?.selfLink; resourceInputs["target"] = state?.target; resourceInputs["zone"] = state?.zone; } else { const args = argsOrState; if (args?.autoscalingPolicy === undefined && !opts.urn) { throw new Error("Missing required property 'autoscalingPolicy'"); } if (args?.target === undefined && !opts.urn) { throw new Error("Missing required property 'target'"); } resourceInputs["autoscalingPolicy"] = args?.autoscalingPolicy; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["description"] = args?.description; resourceInputs["name"] = args?.name; resourceInputs["project"] = args?.project; resourceInputs["target"] = args?.target; resourceInputs["zone"] = args?.zone; resourceInputs["creationTimestamp"] = undefined /*out*/; resourceInputs["selfLink"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const aliasOpts = { aliases: [{ type: "gcp:compute/autoscalar:Autoscalar" }] }; opts = pulumi.mergeOptions(opts, aliasOpts); super(Autoscaler.__pulumiType, name, resourceInputs, opts); } } exports.Autoscaler = Autoscaler; //# sourceMappingURL=autoscaler.js.map