1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. DiskResourcePolicyAttachment
Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 by Pulumi

gcp.compute.DiskResourcePolicyAttachment

Explore with Pulumi AI

gcp logo
Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 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 regional disks (gcp.compute.RegionDisk). For regional disks, please refer to the gcp.compute.RegionDiskResourcePolicyAttachment resource.

    Example Usage

    Disk Resource Policy Attachment Basic

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var myImage = Gcp.Compute.GetImage.Invoke(new()
        {
            Family = "debian-11",
            Project = "debian-cloud",
        });
    
        var ssd = new Gcp.Compute.Disk("ssd", new()
        {
            Image = myImage.Apply(getImageResult => getImageResult.SelfLink),
            Size = 50,
            Type = "pd-ssd",
            Zone = "us-central1-a",
        });
    
        var attachment = new Gcp.Compute.DiskResourcePolicyAttachment("attachment", new()
        {
            Disk = ssd.Name,
            Zone = "us-central1-a",
        });
    
        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",
                    },
                },
            },
        });
    
    });
    
    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-11"),
    			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 com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.compute.ComputeFunctions;
    import com.pulumi.gcp.compute.inputs.GetImageArgs;
    import com.pulumi.gcp.compute.Disk;
    import com.pulumi.gcp.compute.DiskArgs;
    import com.pulumi.gcp.compute.DiskResourcePolicyAttachment;
    import com.pulumi.gcp.compute.DiskResourcePolicyAttachmentArgs;
    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 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) {
            final var myImage = ComputeFunctions.getImage(GetImageArgs.builder()
                .family("debian-11")
                .project("debian-cloud")
                .build());
    
            var ssd = new Disk("ssd", DiskArgs.builder()        
                .image(myImage.applyValue(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-11",
        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-11",
        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-11
            project: debian-cloud
    

    Create 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 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
    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 v6.66.0 published on Monday, Sep 18, 2023 by Pulumi