@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
151 lines • 6.27 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! ***
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.ResourcePolicyAttachment = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(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}}
* $ pulumi import gcp:compute/resourcePolicyAttachment:ResourcePolicyAttachment default {{project}}/{{zone}}/{{instance}}/{{name}}
* $ pulumi import gcp:compute/resourcePolicyAttachment:ResourcePolicyAttachment default {{zone}}/{{instance}}/{{name}}
* $ 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, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:compute/resourcePolicyAttachment:ResourcePolicyAttachment';
/**
* 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["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["instance"] = state?.instance;
resourceInputs["name"] = state?.name;
resourceInputs["project"] = state?.project;
resourceInputs["zone"] = state?.zone;
}
else {
const args = argsOrState;
if (args?.instance === undefined && !opts.urn) {
throw new Error("Missing required property 'instance'");
}
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["instance"] = args?.instance;
resourceInputs["name"] = args?.name;
resourceInputs["project"] = args?.project;
resourceInputs["zone"] = args?.zone;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ResourcePolicyAttachment.__pulumiType, name, resourceInputs, opts);
}
}
exports.ResourcePolicyAttachment = ResourcePolicyAttachment;
//# sourceMappingURL=resourcePolicyAttachment.js.map