@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
239 lines • 8.47 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Autoscaler = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = 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,
* 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,
* 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}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/autoscaler:Autoscaler default {{project}}/{{zone}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/autoscaler:Autoscaler default {{zone}}/{{name}}
* ```
*
* ```sh
* $ 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, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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 ? state.autoscalingPolicy : undefined;
resourceInputs["creationTimestamp"] = state ? state.creationTimestamp : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["selfLink"] = state ? state.selfLink : undefined;
resourceInputs["target"] = state ? state.target : undefined;
resourceInputs["zone"] = state ? state.zone : undefined;
}
else {
const args = argsOrState;
if ((!args || args.autoscalingPolicy === undefined) && !opts.urn) {
throw new Error("Missing required property 'autoscalingPolicy'");
}
if ((!args || args.target === undefined) && !opts.urn) {
throw new Error("Missing required property 'target'");
}
resourceInputs["autoscalingPolicy"] = args ? args.autoscalingPolicy : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["target"] = args ? args.target : undefined;
resourceInputs["zone"] = args ? args.zone : undefined;
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;
/** @internal */
Autoscaler.__pulumiType = 'gcp:compute/autoscaler:Autoscaler';
//# sourceMappingURL=autoscaler.js.map