@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
314 lines • 10.4 kB
JavaScript
"use strict";
// *** 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.ResourcePolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* A policy that can be attached to a resource to specify or schedule actions on that resource.
*
* To get more information about ResourcePolicy, see:
*
* * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/resourcePolicies)
*
* ## Example Usage
*
* ### Resource Policy Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const foo = new gcp.compute.ResourcePolicy("foo", {
* name: "gce-policy",
* region: "us-central1",
* snapshotSchedulePolicy: {
* schedule: {
* dailySchedule: {
* daysInCycle: 1,
* startTime: "04:00",
* },
* },
* },
* });
* ```
* ### Resource Policy Full
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const bar = new gcp.compute.ResourcePolicy("bar", {
* name: "gce-policy",
* region: "us-central1",
* snapshotSchedulePolicy: {
* schedule: {
* hourlySchedule: {
* hoursInCycle: 20,
* startTime: "23:00",
* },
* },
* retentionPolicy: {
* maxRetentionDays: 10,
* onSourceDiskDelete: "KEEP_AUTO_SNAPSHOTS",
* },
* snapshotProperties: {
* labels: {
* my_label: "value",
* },
* storageLocations: "us",
* guestFlush: true,
* },
* },
* });
* ```
* ### Resource Policy Placement Policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const baz = new gcp.compute.ResourcePolicy("baz", {
* name: "gce-policy",
* region: "us-central1",
* groupPlacementPolicy: {
* vmCount: 2,
* collocation: "COLLOCATED",
* },
* });
* ```
* ### Resource Policy Placement Policy Max Distance
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const baz = new gcp.compute.ResourcePolicy("baz", {
* name: "gce-policy",
* region: "us-central1",
* groupPlacementPolicy: {
* vmCount: 2,
* collocation: "COLLOCATED",
* maxDistance: 2,
* },
* });
* ```
* ### Resource Policy Instance Schedule Policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const hourly = new gcp.compute.ResourcePolicy("hourly", {
* name: "gce-policy",
* region: "us-central1",
* description: "Start and stop instances",
* instanceSchedulePolicy: {
* vmStartSchedule: {
* schedule: "0 * * * *",
* },
* vmStopSchedule: {
* schedule: "15 * * * *",
* },
* timeZone: "US/Central",
* },
* });
* ```
* ### Resource Policy Snapshot Schedule Chain Name
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const hourly = new gcp.compute.ResourcePolicy("hourly", {
* name: "gce-policy",
* region: "us-central1",
* description: "chain name snapshot",
* snapshotSchedulePolicy: {
* schedule: {
* hourlySchedule: {
* hoursInCycle: 20,
* startTime: "23:00",
* },
* },
* retentionPolicy: {
* maxRetentionDays: 14,
* onSourceDiskDelete: "KEEP_AUTO_SNAPSHOTS",
* },
* snapshotProperties: {
* labels: {
* my_label: "value",
* },
* storageLocations: "us",
* guestFlush: true,
* chainName: "test-schedule-chain-name",
* },
* },
* });
* ```
* ### Resource Policy Consistency Group
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const cgroup = new gcp.compute.ResourcePolicy("cgroup", {
* name: "gce-policy",
* region: "europe-west1",
* diskConsistencyGroupPolicy: {
* enabled: true,
* },
* });
* ```
* ### Resource Policy Workload Policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const bar = new gcp.compute.ResourcePolicy("bar", {
* name: "gce-policy",
* region: "europe-west1",
* workloadPolicy: {
* type: "HIGH_AVAILABILITY",
* },
* });
* ```
* ### Resource Policy Workload Policy Accelerator Topology
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const bar = new gcp.compute.ResourcePolicy("bar", {
* name: "gce-policy",
* region: "europe-west1",
* workloadPolicy: {
* type: "HIGH_THROUGHPUT",
* acceleratorTopology: "SOME NEW TOPOLOGY",
* },
* });
* ```
* ### Resource Policy Workload Policy Max Topology Distance
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const bar = new gcp.compute.ResourcePolicy("bar", {
* name: "gce-policy",
* region: "europe-west1",
* workloadPolicy: {
* type: "HIGH_THROUGHPUT",
* maxTopologyDistance: "BLOCK",
* },
* });
* ```
* ### Resource Policy Placement Policy Gpu Topology
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const baz = new gcp.compute.ResourcePolicy("baz", {
* name: "gce-policy",
* region: "europe-west9",
* groupPlacementPolicy: {
* vmCount: 2,
* collocation: "COLLOCATED",
* gpuTopology: "1x72",
* },
* });
* ```
*
* ## Import
*
* ResourcePolicy can be imported using any of these accepted formats:
*
* * `projects/{{project}}/regions/{{region}}/resourcePolicies/{{name}}`
*
* * `{{project}}/{{region}}/{{name}}`
*
* * `{{region}}/{{name}}`
*
* * `{{name}}`
*
* When using the `pulumi import` command, ResourcePolicy can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:compute/resourcePolicy:ResourcePolicy default projects/{{project}}/regions/{{region}}/resourcePolicies/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/resourcePolicy:ResourcePolicy default {{project}}/{{region}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/resourcePolicy:ResourcePolicy default {{region}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/resourcePolicy:ResourcePolicy default {{name}}
* ```
*/
class ResourcePolicy extends pulumi.CustomResource {
/**
* Get an existing ResourcePolicy 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 ResourcePolicy(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of ResourcePolicy. 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'] === ResourcePolicy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["diskConsistencyGroupPolicy"] = state ? state.diskConsistencyGroupPolicy : undefined;
resourceInputs["groupPlacementPolicy"] = state ? state.groupPlacementPolicy : undefined;
resourceInputs["instanceSchedulePolicy"] = state ? state.instanceSchedulePolicy : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["selfLink"] = state ? state.selfLink : undefined;
resourceInputs["snapshotSchedulePolicy"] = state ? state.snapshotSchedulePolicy : undefined;
resourceInputs["workloadPolicy"] = state ? state.workloadPolicy : undefined;
}
else {
const args = argsOrState;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["diskConsistencyGroupPolicy"] = args ? args.diskConsistencyGroupPolicy : undefined;
resourceInputs["groupPlacementPolicy"] = args ? args.groupPlacementPolicy : undefined;
resourceInputs["instanceSchedulePolicy"] = args ? args.instanceSchedulePolicy : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["snapshotSchedulePolicy"] = args ? args.snapshotSchedulePolicy : undefined;
resourceInputs["workloadPolicy"] = args ? args.workloadPolicy : undefined;
resourceInputs["selfLink"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ResourcePolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.ResourcePolicy = ResourcePolicy;
/** @internal */
ResourcePolicy.__pulumiType = 'gcp:compute/resourcePolicy:ResourcePolicy';
//# sourceMappingURL=resourcePolicy.js.map