1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. RegionDiskResourcePolicyAttachment
Google Cloud Classic v7.2.2 published on Monday, Jan 1, 0001 by Pulumi

gcp.compute.RegionDiskResourcePolicyAttachment

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.2.2 published on Monday, Jan 1, 0001 by Pulumi

    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 zonal disks (gcp.compute.Disk). For zonal disks, please refer to the gcp.compute.DiskResourcePolicyAttachment resource.

    Example Usage

    Region Disk Resource Policy Attachment Basic

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var disk = new Gcp.Compute.Disk("disk", new()
        {
            Image = "debian-cloud/debian-11",
            Size = 50,
            Type = "pd-ssd",
            Zone = "us-central1-a",
        });
    
        var snapdisk = new Gcp.Compute.Snapshot("snapdisk", new()
        {
            SourceDisk = disk.Name,
            Zone = "us-central1-a",
        });
    
        var ssd = new Gcp.Compute.RegionDisk("ssd", new()
        {
            ReplicaZones = new[]
            {
                "us-central1-a",
                "us-central1-f",
            },
            Snapshot = snapdisk.Id,
            Size = 50,
            Type = "pd-ssd",
            Region = "us-central1",
        });
    
        var attachment = new Gcp.Compute.RegionDiskResourcePolicyAttachment("attachment", new()
        {
            Disk = ssd.Name,
            Region = "us-central1",
        });
    
        var policy = new Gcp.Compute.ResourcePolicy("policy", new()
        {
            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",
                    },
                },
            },
        });
    
        var myImage = Gcp.Compute.GetImage.Invoke(new()
        {
            Family = "debian-11",
            Project = "debian-cloud",
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		disk, err := compute.NewDisk(ctx, "disk", &compute.DiskArgs{
    			Image: pulumi.String("debian-cloud/debian-11"),
    			Size:  pulumi.Int(50),
    			Type:  pulumi.String("pd-ssd"),
    			Zone:  pulumi.String("us-central1-a"),
    		})
    		if err != nil {
    			return err
    		}
    		snapdisk, err := compute.NewSnapshot(ctx, "snapdisk", &compute.SnapshotArgs{
    			SourceDisk: disk.Name,
    			Zone:       pulumi.String("us-central1-a"),
    		})
    		if err != nil {
    			return err
    		}
    		ssd, err := compute.NewRegionDisk(ctx, "ssd", &compute.RegionDiskArgs{
    			ReplicaZones: pulumi.StringArray{
    				pulumi.String("us-central1-a"),
    				pulumi.String("us-central1-f"),
    			},
    			Snapshot: snapdisk.ID(),
    			Size:     pulumi.Int(50),
    			Type:     pulumi.String("pd-ssd"),
    			Region:   pulumi.String("us-central1"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewRegionDiskResourcePolicyAttachment(ctx, "attachment", &compute.RegionDiskResourcePolicyAttachmentArgs{
    			Disk:   ssd.Name,
    			Region: pulumi.String("us-central1"),
    		})
    		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
    		}
    		_, err = compute.LookupImage(ctx, &compute.LookupImageArgs{
    			Family:  pulumi.StringRef("debian-11"),
    			Project: pulumi.StringRef("debian-cloud"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.compute.Disk;
    import com.pulumi.gcp.compute.DiskArgs;
    import com.pulumi.gcp.compute.Snapshot;
    import com.pulumi.gcp.compute.SnapshotArgs;
    import com.pulumi.gcp.compute.RegionDisk;
    import com.pulumi.gcp.compute.RegionDiskArgs;
    import com.pulumi.gcp.compute.RegionDiskResourcePolicyAttachment;
    import com.pulumi.gcp.compute.RegionDiskResourcePolicyAttachmentArgs;
    import com.pulumi.gcp.compute.ResourcePolicy;
    import com.pulumi.gcp.compute.ResourcePolicyArgs;
    import com.pulumi.gcp.compute.inputs.ResourcePolicySnapshotSchedulePolicyArgs;
    import com.pulumi.gcp.compute.inputs.ResourcePolicySnapshotSchedulePolicyScheduleArgs;
    import com.pulumi.gcp.compute.inputs.ResourcePolicySnapshotSchedulePolicyScheduleDailyScheduleArgs;
    import com.pulumi.gcp.compute.ComputeFunctions;
    import com.pulumi.gcp.compute.inputs.GetImageArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var disk = new Disk("disk", DiskArgs.builder()        
                .image("debian-cloud/debian-11")
                .size(50)
                .type("pd-ssd")
                .zone("us-central1-a")
                .build());
    
            var snapdisk = new Snapshot("snapdisk", SnapshotArgs.builder()        
                .sourceDisk(disk.name())
                .zone("us-central1-a")
                .build());
    
            var ssd = new RegionDisk("ssd", RegionDiskArgs.builder()        
                .replicaZones(            
                    "us-central1-a",
                    "us-central1-f")
                .snapshot(snapdisk.id())
                .size(50)
                .type("pd-ssd")
                .region("us-central1")
                .build());
    
            var attachment = new RegionDiskResourcePolicyAttachment("attachment", RegionDiskResourcePolicyAttachmentArgs.builder()        
                .disk(ssd.name())
                .region("us-central1")
                .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());
    
            final var myImage = ComputeFunctions.getImage(GetImageArgs.builder()
                .family("debian-11")
                .project("debian-cloud")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_gcp as gcp
    
    disk = gcp.compute.Disk("disk",
        image="debian-cloud/debian-11",
        size=50,
        type="pd-ssd",
        zone="us-central1-a")
    snapdisk = gcp.compute.Snapshot("snapdisk",
        source_disk=disk.name,
        zone="us-central1-a")
    ssd = gcp.compute.RegionDisk("ssd",
        replica_zones=[
            "us-central1-a",
            "us-central1-f",
        ],
        snapshot=snapdisk.id,
        size=50,
        type="pd-ssd",
        region="us-central1")
    attachment = gcp.compute.RegionDiskResourcePolicyAttachment("attachment",
        disk=ssd.name,
        region="us-central1")
    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",
                ),
            ),
        ))
    my_image = gcp.compute.get_image(family="debian-11",
        project="debian-cloud")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const disk = new gcp.compute.Disk("disk", {
        image: "debian-cloud/debian-11",
        size: 50,
        type: "pd-ssd",
        zone: "us-central1-a",
    });
    const snapdisk = new gcp.compute.Snapshot("snapdisk", {
        sourceDisk: disk.name,
        zone: "us-central1-a",
    });
    const ssd = new gcp.compute.RegionDisk("ssd", {
        replicaZones: [
            "us-central1-a",
            "us-central1-f",
        ],
        snapshot: snapdisk.id,
        size: 50,
        type: "pd-ssd",
        region: "us-central1",
    });
    const attachment = new gcp.compute.RegionDiskResourcePolicyAttachment("attachment", {
        disk: ssd.name,
        region: "us-central1",
    });
    const policy = new gcp.compute.ResourcePolicy("policy", {
        region: "us-central1",
        snapshotSchedulePolicy: {
            schedule: {
                dailySchedule: {
                    daysInCycle: 1,
                    startTime: "04:00",
                },
            },
        },
    });
    const myImage = gcp.compute.getImage({
        family: "debian-11",
        project: "debian-cloud",
    });
    
    resources:
      attachment:
        type: gcp:compute:RegionDiskResourcePolicyAttachment
        properties:
          disk: ${ssd.name}
          region: us-central1
      disk:
        type: gcp:compute:Disk
        properties:
          image: debian-cloud/debian-11
          size: 50
          type: pd-ssd
          zone: us-central1-a
      snapdisk:
        type: gcp:compute:Snapshot
        properties:
          sourceDisk: ${disk.name}
          zone: us-central1-a
      ssd:
        type: gcp:compute:RegionDisk
        properties:
          replicaZones:
            - us-central1-a
            - us-central1-f
          snapshot: ${snapdisk.id}
          size: 50
          type: pd-ssd
          region: us-central1
      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-11
            project: debian-cloud
    

    Create RegionDiskResourcePolicyAttachment Resource

    new RegionDiskResourcePolicyAttachment(name: string, args: RegionDiskResourcePolicyAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def RegionDiskResourcePolicyAttachment(resource_name: str,
                                           opts: Optional[ResourceOptions] = None,
                                           disk: Optional[str] = None,
                                           name: Optional[str] = None,
                                           project: Optional[str] = None,
                                           region: Optional[str] = None)
    @overload
    def RegionDiskResourcePolicyAttachment(resource_name: str,
                                           args: RegionDiskResourcePolicyAttachmentArgs,
                                           opts: Optional[ResourceOptions] = None)
    func NewRegionDiskResourcePolicyAttachment(ctx *Context, name string, args RegionDiskResourcePolicyAttachmentArgs, opts ...ResourceOption) (*RegionDiskResourcePolicyAttachment, error)
    public RegionDiskResourcePolicyAttachment(string name, RegionDiskResourcePolicyAttachmentArgs args, CustomResourceOptions? opts = null)
    public RegionDiskResourcePolicyAttachment(String name, RegionDiskResourcePolicyAttachmentArgs args)
    public RegionDiskResourcePolicyAttachment(String name, RegionDiskResourcePolicyAttachmentArgs args, CustomResourceOptions options)
    
    type: gcp:compute:RegionDiskResourcePolicyAttachment
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args RegionDiskResourcePolicyAttachmentArgs
    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 RegionDiskResourcePolicyAttachmentArgs
    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 RegionDiskResourcePolicyAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RegionDiskResourcePolicyAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RegionDiskResourcePolicyAttachmentArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    RegionDiskResourcePolicyAttachment 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 RegionDiskResourcePolicyAttachment resource accepts the following input properties:

    Disk string

    The name of the regional 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.

    Region string

    A reference to the region where the disk resides.

    Disk string

    The name of the regional 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.

    Region string

    A reference to the region where the disk resides.

    disk String

    The name of the regional 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.

    region String

    A reference to the region where the disk resides.

    disk string

    The name of the regional 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.

    region string

    A reference to the region where the disk resides.

    disk str

    The name of the regional 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.

    region str

    A reference to the region where the disk resides.

    disk String

    The name of the regional 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.

    region String

    A reference to the region where the disk resides.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the RegionDiskResourcePolicyAttachment 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 Existing RegionDiskResourcePolicyAttachment Resource

    Get an existing RegionDiskResourcePolicyAttachment 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?: RegionDiskResourcePolicyAttachmentState, opts?: CustomResourceOptions): RegionDiskResourcePolicyAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            disk: Optional[str] = None,
            name: Optional[str] = None,
            project: Optional[str] = None,
            region: Optional[str] = None) -> RegionDiskResourcePolicyAttachment
    func GetRegionDiskResourcePolicyAttachment(ctx *Context, name string, id IDInput, state *RegionDiskResourcePolicyAttachmentState, opts ...ResourceOption) (*RegionDiskResourcePolicyAttachment, error)
    public static RegionDiskResourcePolicyAttachment Get(string name, Input<string> id, RegionDiskResourcePolicyAttachmentState? state, CustomResourceOptions? opts = null)
    public static RegionDiskResourcePolicyAttachment get(String name, Output<String> id, RegionDiskResourcePolicyAttachmentState 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 regional 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.

    Region string

    A reference to the region where the disk resides.

    Disk string

    The name of the regional 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.

    Region string

    A reference to the region where the disk resides.

    disk String

    The name of the regional 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.

    region String

    A reference to the region where the disk resides.

    disk string

    The name of the regional 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.

    region string

    A reference to the region where the disk resides.

    disk str

    The name of the regional 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.

    region str

    A reference to the region where the disk resides.

    disk String

    The name of the regional 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.

    region String

    A reference to the region where the disk resides.

    Import

    RegionDiskResourcePolicyAttachment can be imported using any of these accepted formats* projects/{{project}}/regions/{{region}}/disks/{{disk}}/{{name}} * {{project}}/{{region}}/{{disk}}/{{name}} * {{region}}/{{disk}}/{{name}} * {{disk}}/{{name}} In Terraform v1.5.0 and later, use an import block to import RegionDiskResourcePolicyAttachment using one of the formats above. For exampletf import {

    id = “projects/{{project}}/regions/{{region}}/disks/{{disk}}/{{name}}”

    to = google_compute_region_disk_resource_policy_attachment.default }

     $ pulumi import gcp:compute/regionDiskResourcePolicyAttachment:RegionDiskResourcePolicyAttachment When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), RegionDiskResourcePolicyAttachment can be imported using one of the formats above. For example
    
     $ pulumi import gcp:compute/regionDiskResourcePolicyAttachment:RegionDiskResourcePolicyAttachment default projects/{{project}}/regions/{{region}}/disks/{{disk}}/{{name}}
    
     $ pulumi import gcp:compute/regionDiskResourcePolicyAttachment:RegionDiskResourcePolicyAttachment default {{project}}/{{region}}/{{disk}}/{{name}}
    
     $ pulumi import gcp:compute/regionDiskResourcePolicyAttachment:RegionDiskResourcePolicyAttachment default {{region}}/{{disk}}/{{name}}
    
     $ pulumi import gcp:compute/regionDiskResourcePolicyAttachment:RegionDiskResourcePolicyAttachment default {{disk}}/{{name}}
    

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes

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

    gcp logo
    Google Cloud Classic v7.2.2 published on Monday, Jan 1, 0001 by Pulumi