Show / Hide Table of Contents

Class ResourcePolicy

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

Example Usage - Resource Policy Basic

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
public MyStack()
{
    var foo = new Gcp.Compute.ResourcePolicy("foo", new Gcp.Compute.ResourcePolicyArgs
    {
        Region = "us-central1",
        SnapshotSchedulePolicy = new Gcp.Compute.Inputs.ResourcePolicySnapshotSchedulePolicyArgs
        {
            Schedule = new Gcp.Compute.Inputs.ResourcePolicySnapshotSchedulePolicyScheduleArgs
            {
                DailySchedule = new Gcp.Compute.Inputs.ResourcePolicySnapshotSchedulePolicyScheduleDailyScheduleArgs
                {
                    DaysInCycle = 1,
                    StartTime = "04:00",
                },
            },
        },
    });
}

}

Example Usage - Resource Policy Full

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
public MyStack()
{
    var bar = new Gcp.Compute.ResourcePolicy("bar", new Gcp.Compute.ResourcePolicyArgs
    {
        Region = "us-central1",
        SnapshotSchedulePolicy = new Gcp.Compute.Inputs.ResourcePolicySnapshotSchedulePolicyArgs
        {
            RetentionPolicy = new Gcp.Compute.Inputs.ResourcePolicySnapshotSchedulePolicyRetentionPolicyArgs
            {
                MaxRetentionDays = 10,
                OnSourceDiskDelete = "KEEP_AUTO_SNAPSHOTS",
            },
            Schedule = new Gcp.Compute.Inputs.ResourcePolicySnapshotSchedulePolicyScheduleArgs
            {
                HourlySchedule = new Gcp.Compute.Inputs.ResourcePolicySnapshotSchedulePolicyScheduleHourlyScheduleArgs
                {
                    HoursInCycle = 20,
                    StartTime = "23:00",
                },
            },
            SnapshotProperties = new Gcp.Compute.Inputs.ResourcePolicySnapshotSchedulePolicySnapshotPropertiesArgs
            {
                GuestFlush = true,
                Labels = 
                {
                    { "myLabel", "value" },
                },
                StorageLocations = "us",
            },
        },
    });
}

}

Example Usage - Resource Policy Placement Policy

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
public MyStack()
{
    var baz = new Gcp.Compute.ResourcePolicy("baz", new Gcp.Compute.ResourcePolicyArgs
    {
        GroupPlacementPolicy = new Gcp.Compute.Inputs.ResourcePolicyGroupPlacementPolicyArgs
        {
            Collocation = "COLLOCATED",
            VmCount = 2,
        },
        Region = "us-central1",
    });
}

}
Inheritance
System.Object
Resource
CustomResource
ResourcePolicy
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Gcp.Compute
Assembly: Pulumi.Gcp.dll
Syntax
public class ResourcePolicy : CustomResource

Constructors

View Source

ResourcePolicy(String, ResourcePolicyArgs, CustomResourceOptions)

Create a ResourcePolicy resource with the given unique name, arguments, and options.

Declaration
public ResourcePolicy(string name, ResourcePolicyArgs args = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

ResourcePolicyArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

GroupPlacementPolicy

Policy for creating snapshots of persistent disks. Structure is documented below.

Declaration
public Output<ResourcePolicyGroupPlacementPolicy> GroupPlacementPolicy { get; }
Property Value
Type Description
Output<ResourcePolicyGroupPlacementPolicy>
View Source

Name

The name of the resource, provided by the client when initially creating the resource. The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

Declaration
public Output<string> Name { get; }
Property Value
Type Description
Output<System.String>
View Source

Project

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Declaration
public Output<string> Project { get; }
Property Value
Type Description
Output<System.String>
View Source

Region

Region where resource policy resides.

Declaration
public Output<string> Region { get; }
Property Value
Type Description
Output<System.String>
View Source

SelfLink

The URI of the created resource.

Declaration
public Output<string> SelfLink { get; }
Property Value
Type Description
Output<System.String>
View Source

SnapshotSchedulePolicy

Policy for creating snapshots of persistent disks. Structure is documented below.

Declaration
public Output<ResourcePolicySnapshotSchedulePolicy> SnapshotSchedulePolicy { get; }
Property Value
Type Description
Output<ResourcePolicySnapshotSchedulePolicy>

Methods

View Source

Get(String, Input<String>, ResourcePolicyState, CustomResourceOptions)

Get an existing ResourcePolicy resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static ResourcePolicy Get(string name, Input<string> id, ResourcePolicyState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

ResourcePolicyState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
ResourcePolicy
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.