pulumi_wasm_providers_gcp_mini::compute

Module resource_policy

source
Expand description

A policy that can be attached to a resource to specify or schedule actions on that resource.

To get more information about ResourcePolicy, see:

§Example Usage

§Resource Policy Basic

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let foo = resource_policy::create(
        "foo",
        ResourcePolicyArgs::builder()
            .name("gce-policy")
            .region("us-central1")
            .snapshot_schedule_policy(
                ResourcePolicySnapshotSchedulePolicy::builder()
                    .schedule(
                        ResourcePolicySnapshotSchedulePolicySchedule::builder()
                            .dailySchedule(
                                ResourcePolicySnapshotSchedulePolicyScheduleDailySchedule::builder()
                                    .daysInCycle(1)
                                    .startTime("04:00")
                                    .build_struct(),
                            )
                            .build_struct(),
                    )
                    .build_struct(),
            )
            .build_struct(),
    );
}

§Resource Policy Full

resources:
  bar:
    type: gcp:compute:ResourcePolicy
    properties:
      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

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let baz = resource_policy::create(
        "baz",
        ResourcePolicyArgs::builder()
            .group_placement_policy(
                ResourcePolicyGroupPlacementPolicy::builder()
                    .collocation("COLLOCATED")
                    .vmCount(2)
                    .build_struct(),
            )
            .name("gce-policy")
            .region("us-central1")
            .build_struct(),
    );
}

§Resource Policy Placement Policy Max Distance

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let baz = resource_policy::create(
        "baz",
        ResourcePolicyArgs::builder()
            .group_placement_policy(
                ResourcePolicyGroupPlacementPolicy::builder()
                    .collocation("COLLOCATED")
                    .maxDistance(2)
                    .vmCount(2)
                    .build_struct(),
            )
            .name("gce-policy")
            .region("us-central1")
            .build_struct(),
    );
}

§Resource Policy Instance Schedule Policy

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let hourly = resource_policy::create(
        "hourly",
        ResourcePolicyArgs::builder()
            .description("Start and stop instances")
            .instance_schedule_policy(
                ResourcePolicyInstanceSchedulePolicy::builder()
                    .timeZone("US/Central")
                    .vmStartSchedule(
                        ResourcePolicyInstanceSchedulePolicyVmStartSchedule::builder()
                            .schedule("0 * * * *")
                            .build_struct(),
                    )
                    .vmStopSchedule(
                        ResourcePolicyInstanceSchedulePolicyVmStopSchedule::builder()
                            .schedule("15 * * * *")
                            .build_struct(),
                    )
                    .build_struct(),
            )
            .name("gce-policy")
            .region("us-central1")
            .build_struct(),
    );
}

§Resource Policy Snapshot Schedule Chain Name

resources:
  hourly:
    type: gcp:compute:ResourcePolicy
    properties:
      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

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let cgroup = resource_policy::create(
        "cgroup",
        ResourcePolicyArgs::builder()
            .disk_consistency_group_policy(
                ResourcePolicyDiskConsistencyGroupPolicy::builder()
                    .enabled(true)
                    .build_struct(),
            )
            .name("gce-policy")
            .region("europe-west1")
            .build_struct(),
    );
}

§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:

$ pulumi import gcp:compute/resourcePolicy:ResourcePolicy default projects/{{project}}/regions/{{region}}/resourcePolicies/{{name}}
$ pulumi import gcp:compute/resourcePolicy:ResourcePolicy default {{project}}/{{region}}/{{name}}
$ pulumi import gcp:compute/resourcePolicy:ResourcePolicy default {{region}}/{{name}}
$ pulumi import gcp:compute/resourcePolicy:ResourcePolicy default {{name}}

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments