Google Cloud (GCP) Classic

Pulumi Official
Package maintained by Pulumi
v6.25.0 published on Wednesday, May 25, 2022 by Pulumi

DiskResourcePolicyAttachment

Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.

Note: This resource does not support regional disks (gcp.compute.RegionDisk). For regional disks, please refer to the gcp.compute.RegionDiskResourcePolicyAttachment resource.

Example Usage

Disk Resource Policy Attachment Basic

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
    public MyStack()
    {
        var myImage = Output.Create(Gcp.Compute.GetImage.InvokeAsync(new Gcp.Compute.GetImageArgs
        {
            Family = "debian-9",
            Project = "debian-cloud",
        }));
        var ssd = new Gcp.Compute.Disk("ssd", new Gcp.Compute.DiskArgs
        {
            Image = myImage.Apply(myImage => myImage.SelfLink),
            Size = 50,
            Type = "pd-ssd",
            Zone = "us-central1-a",
        });
        var attachment = new Gcp.Compute.DiskResourcePolicyAttachment("attachment", new Gcp.Compute.DiskResourcePolicyAttachmentArgs
        {
            Disk = ssd.Name,
            Zone = "us-central1-a",
        });
        var policy = new Gcp.Compute.ResourcePolicy("policy", 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",
                    },
                },
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myImage, err := compute.LookupImage(ctx, &compute.LookupImageArgs{
			Family:  pulumi.StringRef("debian-9"),
			Project: pulumi.StringRef("debian-cloud"),
		}, nil)
		if err != nil {
			return err
		}
		ssd, err := compute.NewDisk(ctx, "ssd", &compute.DiskArgs{
			Image: pulumi.String(myImage.SelfLink),
			Size:  pulumi.Int(50),
			Type:  pulumi.String("pd-ssd"),
			Zone:  pulumi.String("us-central1-a"),
		})
		if err != nil {
			return err
		}
		_, err = compute.NewDiskResourcePolicyAttachment(ctx, "attachment", &compute.DiskResourcePolicyAttachmentArgs{
			Disk: ssd.Name,
			Zone: pulumi.String("us-central1-a"),
		})
		if err != nil {
			return err
		}
		_, err = compute.NewResourcePolicy(ctx, "policy", &compute.ResourcePolicyArgs{
			Region: pulumi.String("us-central1"),
			SnapshotSchedulePolicy: &compute.ResourcePolicySnapshotSchedulePolicyArgs{
				Schedule: &compute.ResourcePolicySnapshotSchedulePolicyScheduleArgs{
					DailySchedule: &compute.ResourcePolicySnapshotSchedulePolicyScheduleDailyScheduleArgs{
						DaysInCycle: pulumi.Int(1),
						StartTime:   pulumi.String("04:00"),
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var myImage = Output.of(ComputeFunctions.getImage(GetImageArgs.builder()
            .family("debian-9")
            .project("debian-cloud")
            .build()));

        var ssd = new Disk("ssd", DiskArgs.builder()        
            .image(myImage.apply(getImageResult -> getImageResult.selfLink()))
            .size(50)
            .type("pd-ssd")
            .zone("us-central1-a")
            .build());

        var attachment = new DiskResourcePolicyAttachment("attachment", DiskResourcePolicyAttachmentArgs.builder()        
            .disk(ssd.name())
            .zone("us-central1-a")
            .build());

        var policy = new ResourcePolicy("policy", ResourcePolicyArgs.builder()        
            .region("us-central1")
            .snapshotSchedulePolicy(ResourcePolicySnapshotSchedulePolicyArgs.builder()
                .schedule(ResourcePolicySnapshotSchedulePolicyScheduleArgs.builder()
                    .dailySchedule(ResourcePolicySnapshotSchedulePolicyScheduleDailyScheduleArgs.builder()
                        .daysInCycle(1)
                        .startTime("04:00")
                        .build())
                    .build())
                .build())
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

my_image = gcp.compute.get_image(family="debian-9",
    project="debian-cloud")
ssd = gcp.compute.Disk("ssd",
    image=my_image.self_link,
    size=50,
    type="pd-ssd",
    zone="us-central1-a")
attachment = gcp.compute.DiskResourcePolicyAttachment("attachment",
    disk=ssd.name,
    zone="us-central1-a")
policy = gcp.compute.ResourcePolicy("policy",
    region="us-central1",
    snapshot_schedule_policy=gcp.compute.ResourcePolicySnapshotSchedulePolicyArgs(
        schedule=gcp.compute.ResourcePolicySnapshotSchedulePolicyScheduleArgs(
            daily_schedule=gcp.compute.ResourcePolicySnapshotSchedulePolicyScheduleDailyScheduleArgs(
                days_in_cycle=1,
                start_time="04:00",
            ),
        ),
    ))
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const myImage = gcp.compute.getImage({
    family: "debian-9",
    project: "debian-cloud",
});
const ssd = new gcp.compute.Disk("ssd", {
    image: myImage.then(myImage => myImage.selfLink),
    size: 50,
    type: "pd-ssd",
    zone: "us-central1-a",
});
const attachment = new gcp.compute.DiskResourcePolicyAttachment("attachment", {
    disk: ssd.name,
    zone: "us-central1-a",
});
const policy = new gcp.compute.ResourcePolicy("policy", {
    region: "us-central1",
    snapshotSchedulePolicy: {
        schedule: {
            dailySchedule: {
                daysInCycle: 1,
                startTime: "04:00",
            },
        },
    },
});
resources:
  attachment:
    type: gcp:compute:DiskResourcePolicyAttachment
    properties:
      disk: ${ssd.name}
      zone: us-central1-a
  ssd:
    type: gcp:compute:Disk
    properties:
      image: ${myImage.selfLink}
      size: 50
      type: pd-ssd
      zone: us-central1-a
  policy:
    type: gcp:compute:ResourcePolicy
    properties:
      region: us-central1
      snapshotSchedulePolicy:
        schedule:
          dailySchedule:
            daysInCycle: 1
            startTime: 04:00
variables:
  myImage:
    Fn::Invoke:
      Function: gcp:compute:getImage
      Arguments:
        family: debian-9
        project: debian-cloud

Create a DiskResourcePolicyAttachment Resource

new DiskResourcePolicyAttachment(name: string, args: DiskResourcePolicyAttachmentArgs, opts?: CustomResourceOptions);
@overload
def DiskResourcePolicyAttachment(resource_name: str,
                                 opts: Optional[ResourceOptions] = None,
                                 disk: Optional[str] = None,
                                 name: Optional[str] = None,
                                 project: Optional[str] = None,
                                 zone: Optional[str] = None)
@overload
def DiskResourcePolicyAttachment(resource_name: str,
                                 args: DiskResourcePolicyAttachmentArgs,
                                 opts: Optional[ResourceOptions] = None)
func NewDiskResourcePolicyAttachment(ctx *Context, name string, args DiskResourcePolicyAttachmentArgs, opts ...ResourceOption) (*DiskResourcePolicyAttachment, error)
public DiskResourcePolicyAttachment(string name, DiskResourcePolicyAttachmentArgs args, CustomResourceOptions? opts = null)
public DiskResourcePolicyAttachment(String name, DiskResourcePolicyAttachmentArgs args)
public DiskResourcePolicyAttachment(String name, DiskResourcePolicyAttachmentArgs args, CustomResourceOptions options)
type: gcp:compute:DiskResourcePolicyAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args DiskResourcePolicyAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args DiskResourcePolicyAttachmentArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args DiskResourcePolicyAttachmentArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args DiskResourcePolicyAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args DiskResourcePolicyAttachmentArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

DiskResourcePolicyAttachment Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The DiskResourcePolicyAttachment resource accepts the following input properties:

Disk string

The name of the disk in which the resource policies are attached to.

Name string

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

Project string

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

Zone string

A reference to the zone where the disk resides.

Disk string

The name of the disk in which the resource policies are attached to.

Name string

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

Project string

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

Zone string

A reference to the zone where the disk resides.

disk String

The name of the disk in which the resource policies are attached to.

name String

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

project String

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

zone String

A reference to the zone where the disk resides.

disk string

The name of the disk in which the resource policies are attached to.

name string

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

project string

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

zone string

A reference to the zone where the disk resides.

disk str

The name of the disk in which the resource policies are attached to.

name str

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

project str

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

zone str

A reference to the zone where the disk resides.

disk String

The name of the disk in which the resource policies are attached to.

name String

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

project String

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

zone String

A reference to the zone where the disk resides.

Outputs

All input properties are implicitly available as output properties. Additionally, the DiskResourcePolicyAttachment resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up an Existing DiskResourcePolicyAttachment Resource

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

public static get(name: string, id: Input<ID>, state?: DiskResourcePolicyAttachmentState, opts?: CustomResourceOptions): DiskResourcePolicyAttachment
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        disk: Optional[str] = None,
        name: Optional[str] = None,
        project: Optional[str] = None,
        zone: Optional[str] = None) -> DiskResourcePolicyAttachment
func GetDiskResourcePolicyAttachment(ctx *Context, name string, id IDInput, state *DiskResourcePolicyAttachmentState, opts ...ResourceOption) (*DiskResourcePolicyAttachment, error)
public static DiskResourcePolicyAttachment Get(string name, Input<string> id, DiskResourcePolicyAttachmentState? state, CustomResourceOptions? opts = null)
public static DiskResourcePolicyAttachment get(String name, Output<String> id, DiskResourcePolicyAttachmentState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Disk string

The name of the disk in which the resource policies are attached to.

Name string

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

Project string

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

Zone string

A reference to the zone where the disk resides.

Disk string

The name of the disk in which the resource policies are attached to.

Name string

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

Project string

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

Zone string

A reference to the zone where the disk resides.

disk String

The name of the disk in which the resource policies are attached to.

name String

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

project String

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

zone String

A reference to the zone where the disk resides.

disk string

The name of the disk in which the resource policies are attached to.

name string

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

project string

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

zone string

A reference to the zone where the disk resides.

disk str

The name of the disk in which the resource policies are attached to.

name str

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

project str

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

zone str

A reference to the zone where the disk resides.

disk String

The name of the disk in which the resource policies are attached to.

name String

The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

project String

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

zone String

A reference to the zone where the disk resides.

Import

DiskResourcePolicyAttachment can be imported using any of these accepted formats

 $ pulumi import gcp:compute/diskResourcePolicyAttachment:DiskResourcePolicyAttachment default projects/{{project}}/zones/{{zone}}/disks/{{disk}}/{{name}}
 $ pulumi import gcp:compute/diskResourcePolicyAttachment:DiskResourcePolicyAttachment default {{project}}/{{zone}}/{{disk}}/{{name}}
 $ pulumi import gcp:compute/diskResourcePolicyAttachment:DiskResourcePolicyAttachment default {{zone}}/{{disk}}/{{name}}
 $ pulumi import gcp:compute/diskResourcePolicyAttachment:DiskResourcePolicyAttachment default {{disk}}/{{name}}

Package Details

Repository
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes

This Pulumi package is based on the google-beta Terraform Provider.