UNPKG

@pulumi/gcp

Version:

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

279 lines • 10.3 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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Reservation = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Represents a reservation resource. A reservation ensures that capacity is * held in a specific zone even if the reserved VMs are not running. * * Reservations apply only to Compute Engine, Cloud Dataproc, and Google * Kubernetes Engine VM usage.Reservations do not apply to `f1-micro` or * `g1-small` machine types, preemptible VMs, sole tenant nodes, or other * services not listed above * like Cloud SQL and Dataflow. * * To get more information about Reservation, see: * * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/reservations) * * How-to Guides * * [Reserving zonal resources](https://cloud.google.com/compute/docs/instances/reserving-zonal-resources) * * ## Example Usage * * ### Reservation Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const gceReservation = new gcp.compute.Reservation("gce_reservation", { * name: "gce-reservation", * zone: "us-central1-a", * specificReservation: { * count: 1, * instanceProperties: { * minCpuPlatform: "Intel Cascade Lake", * machineType: "n2-standard-2", * }, * }, * }); * ``` * ### Reservation Basic Beta * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const gceReservation = new gcp.compute.Reservation("gce_reservation", { * name: "gce-reservation", * zone: "us-central1-a", * specificReservation: { * count: 1, * instanceProperties: { * minCpuPlatform: "Intel Cascade Lake", * machineType: "n2-standard-2", * maintenanceInterval: "PERIODIC", * }, * }, * enableEmergentMaintenance: true, * }); * ``` * ### Reservation Source Instance Template * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myImage = gcp.compute.getImage({ * family: "debian-11", * project: "debian-cloud", * }); * const foobar = new gcp.compute.InstanceTemplate("foobar", { * name: "tf-test-instance-template", * machineType: "n2-standard-2", * canIpForward: false, * tags: [ * "foo", * "bar", * ], * disks: [{ * sourceImage: myImage.then(myImage => myImage.selfLink), * autoDelete: true, * boot: true, * }], * networkInterfaces: [{ * network: "default", * }], * scheduling: { * preemptible: false, * automaticRestart: true, * }, * metadata: { * foo: "bar", * }, * serviceAccount: { * scopes: [ * "userinfo-email", * "compute-ro", * "storage-ro", * ], * }, * labels: { * my_label: "foobar", * }, * }); * const gceReservationSourceInstanceTemplate = new gcp.compute.Reservation("gce_reservation_source_instance_template", { * name: "gce-reservation-source-instance-template", * zone: "us-central1-a", * specificReservation: { * count: 1, * sourceInstanceTemplate: foobar.selfLink, * }, * }); * ``` * ### Reservation Sharing Policy * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myImage = gcp.compute.getImage({ * family: "debian-11", * project: "debian-cloud", * }); * const foobar = new gcp.compute.InstanceTemplate("foobar", { * name: "tf-test-instance-template", * machineType: "g2-standard-4", * canIpForward: false, * tags: [ * "foo", * "bar", * ], * disks: [{ * sourceImage: myImage.then(myImage => myImage.selfLink), * autoDelete: true, * boot: true, * }], * networkInterfaces: [{ * network: "default", * }], * scheduling: { * preemptible: false, * automaticRestart: true, * }, * metadata: { * foo: "bar", * }, * serviceAccount: { * scopes: [ * "userinfo-email", * "compute-ro", * "storage-ro", * ], * }, * labels: { * my_label: "foobar", * }, * }); * const gceReservationSharingPolicy = new gcp.compute.Reservation("gce_reservation_sharing_policy", { * name: "gce-reservation-sharing-policy", * zone: "us-central1-b", * specificReservation: { * count: 2, * sourceInstanceTemplate: foobar.selfLink, * }, * reservationSharingPolicy: { * serviceShareType: "ALLOW_ALL", * }, * }); * ``` * * ## Import * * Reservation can be imported using any of these accepted formats: * * * `projects/{{project}}/zones/{{zone}}/reservations/{{name}}` * * * `{{project}}/{{zone}}/{{name}}` * * * `{{zone}}/{{name}}` * * * `{{name}}` * * When using the `pulumi import` command, Reservation can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/reservation:Reservation default projects/{{project}}/zones/{{zone}}/reservations/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/reservation:Reservation default {{project}}/{{zone}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/reservation:Reservation default {{zone}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/reservation:Reservation default {{name}} * ``` */ class Reservation extends pulumi.CustomResource { /** * Get an existing Reservation 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 Reservation(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Reservation. 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'] === Reservation.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["commitment"] = state ? state.commitment : undefined; resourceInputs["creationTimestamp"] = state ? state.creationTimestamp : undefined; resourceInputs["deleteAfterDuration"] = state ? state.deleteAfterDuration : undefined; resourceInputs["deleteAtTime"] = state ? state.deleteAtTime : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["enableEmergentMaintenance"] = state ? state.enableEmergentMaintenance : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["reservationSharingPolicy"] = state ? state.reservationSharingPolicy : undefined; resourceInputs["selfLink"] = state ? state.selfLink : undefined; resourceInputs["shareSettings"] = state ? state.shareSettings : undefined; resourceInputs["specificReservation"] = state ? state.specificReservation : undefined; resourceInputs["specificReservationRequired"] = state ? state.specificReservationRequired : undefined; resourceInputs["status"] = state ? state.status : undefined; resourceInputs["zone"] = state ? state.zone : undefined; } else { const args = argsOrState; if ((!args || args.specificReservation === undefined) && !opts.urn) { throw new Error("Missing required property 'specificReservation'"); } if ((!args || args.zone === undefined) && !opts.urn) { throw new Error("Missing required property 'zone'"); } resourceInputs["deleteAfterDuration"] = args ? args.deleteAfterDuration : undefined; resourceInputs["deleteAtTime"] = args ? args.deleteAtTime : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["enableEmergentMaintenance"] = args ? args.enableEmergentMaintenance : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["reservationSharingPolicy"] = args ? args.reservationSharingPolicy : undefined; resourceInputs["shareSettings"] = args ? args.shareSettings : undefined; resourceInputs["specificReservation"] = args ? args.specificReservation : undefined; resourceInputs["specificReservationRequired"] = args ? args.specificReservationRequired : undefined; resourceInputs["zone"] = args ? args.zone : undefined; resourceInputs["commitment"] = undefined /*out*/; resourceInputs["creationTimestamp"] = undefined /*out*/; resourceInputs["selfLink"] = undefined /*out*/; resourceInputs["status"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Reservation.__pulumiType, name, resourceInputs, opts); } } exports.Reservation = Reservation; /** @internal */ Reservation.__pulumiType = 'gcp:compute/reservation:Reservation'; //# sourceMappingURL=reservation.js.map