UNPKG

@pulumi/gcp

Version:

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

138 lines 5.34 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.ResourcePolicyAttachment = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Adds existing resource policies to a compute instance. You can only add one policy * which will be applied to this instance for scheduling start/stop operations. * * This resource can be used instead of setting the resourcePolicy directly in the * compute instance resource to avoid dependency issues when using instance-level IAM * permissions. * * ## Example Usage * * ### Compute Resource Policy Attachment Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const instance = new gcp.compute.Instance("instance", { * networkInterfaces: [{ * accessConfigs: [{}], * network: "default", * }], * name: "my-instance", * machineType: "e2-medium", * zone: "us-central1-a", * bootDisk: { * initializeParams: { * image: "debian-cloud/debian-11", * }, * }, * }); * const policy = new gcp.compute.ResourcePolicy("policy", { * name: "my-resource-policy", * region: "us-central1", * instanceSchedulePolicy: { * vmStartSchedule: { * schedule: "0 8 * * *", * }, * vmStopSchedule: { * schedule: "0 18 * * *", * }, * timeZone: "America/New_York", * }, * }); * const attachment = new gcp.compute.ResourcePolicyAttachment("attachment", { * name: policy.name, * instance: instance.name, * zone: "us-central1-a", * }); * ``` * * ## Import * * ResourcePolicyAttachment can be imported using any of these accepted formats: * * * `projects/{{project}}/zones/{{zone}}/instances/{{instance}}/{{name}}` * * * `{{project}}/{{zone}}/{{instance}}/{{name}}` * * * `{{zone}}/{{instance}}/{{name}}` * * * `{{instance}}/{{name}}` * * When using the `pulumi import` command, ResourcePolicyAttachment can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/resourcePolicyAttachment:ResourcePolicyAttachment default projects/{{project}}/zones/{{zone}}/instances/{{instance}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/resourcePolicyAttachment:ResourcePolicyAttachment default {{project}}/{{zone}}/{{instance}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/resourcePolicyAttachment:ResourcePolicyAttachment default {{zone}}/{{instance}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/resourcePolicyAttachment:ResourcePolicyAttachment default {{instance}}/{{name}} * ``` */ class ResourcePolicyAttachment extends pulumi.CustomResource { /** * Get an existing ResourcePolicyAttachment 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 ResourcePolicyAttachment(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of ResourcePolicyAttachment. 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'] === ResourcePolicyAttachment.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["instance"] = state ? state.instance : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["zone"] = state ? state.zone : undefined; } else { const args = argsOrState; if ((!args || args.instance === undefined) && !opts.urn) { throw new Error("Missing required property 'instance'"); } resourceInputs["instance"] = args ? args.instance : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["zone"] = args ? args.zone : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(ResourcePolicyAttachment.__pulumiType, name, resourceInputs, opts); } } exports.ResourcePolicyAttachment = ResourcePolicyAttachment; /** @internal */ ResourcePolicyAttachment.__pulumiType = 'gcp:compute/resourcePolicyAttachment:ResourcePolicyAttachment'; //# sourceMappingURL=resourcePolicyAttachment.js.map