gcp.compute.RegionDiskResourcePolicyAttachment
Explore with Pulumi AI
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 thegcp.compute.DiskResourcePolicyAttachment
resource.
Example Usage
Region Disk Resource Policy Attachment Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const disk = new gcp.compute.Disk("disk", {
name: "my-base-disk",
image: "debian-cloud/debian-11",
size: 50,
type: "pd-ssd",
zone: "us-central1-a",
});
const snapdisk = new gcp.compute.Snapshot("snapdisk", {
name: "my-snapshot",
sourceDisk: disk.name,
zone: "us-central1-a",
});
const ssd = new gcp.compute.RegionDisk("ssd", {
name: "my-disk",
replicaZones: [
"us-central1-a",
"us-central1-f",
],
snapshot: snapdisk.id,
size: 50,
type: "pd-ssd",
region: "us-central1",
});
const policy = new gcp.compute.ResourcePolicy("policy", {
name: "my-resource-policy",
region: "us-central1",
snapshotSchedulePolicy: {
schedule: {
dailySchedule: {
daysInCycle: 1,
startTime: "04:00",
},
},
},
});
const attachment = new gcp.compute.RegionDiskResourcePolicyAttachment("attachment", {
name: policy.name,
disk: ssd.name,
region: "us-central1",
});
const myImage = gcp.compute.getImage({
family: "debian-11",
project: "debian-cloud",
});
import pulumi
import pulumi_gcp as gcp
disk = gcp.compute.Disk("disk",
name="my-base-disk",
image="debian-cloud/debian-11",
size=50,
type="pd-ssd",
zone="us-central1-a")
snapdisk = gcp.compute.Snapshot("snapdisk",
name="my-snapshot",
source_disk=disk.name,
zone="us-central1-a")
ssd = gcp.compute.RegionDisk("ssd",
name="my-disk",
replica_zones=[
"us-central1-a",
"us-central1-f",
],
snapshot=snapdisk.id,
size=50,
type="pd-ssd",
region="us-central1")
policy = gcp.compute.ResourcePolicy("policy",
name="my-resource-policy",
region="us-central1",
snapshot_schedule_policy={
"schedule": {
"daily_schedule": {
"days_in_cycle": 1,
"start_time": "04:00",
},
},
})
attachment = gcp.compute.RegionDiskResourcePolicyAttachment("attachment",
name=policy.name,
disk=ssd.name,
region="us-central1")
my_image = gcp.compute.get_image(family="debian-11",
project="debian-cloud")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/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{
Name: pulumi.String("my-base-disk"),
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{
Name: pulumi.String("my-snapshot"),
SourceDisk: disk.Name,
Zone: pulumi.String("us-central1-a"),
})
if err != nil {
return err
}
ssd, err := compute.NewRegionDisk(ctx, "ssd", &compute.RegionDiskArgs{
Name: pulumi.String("my-disk"),
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
}
policy, err := compute.NewResourcePolicy(ctx, "policy", &compute.ResourcePolicyArgs{
Name: pulumi.String("my-resource-policy"),
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.NewRegionDiskResourcePolicyAttachment(ctx, "attachment", &compute.RegionDiskResourcePolicyAttachmentArgs{
Name: policy.Name,
Disk: ssd.Name,
Region: pulumi.String("us-central1"),
})
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
})
}
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()
{
Name = "my-base-disk",
Image = "debian-cloud/debian-11",
Size = 50,
Type = "pd-ssd",
Zone = "us-central1-a",
});
var snapdisk = new Gcp.Compute.Snapshot("snapdisk", new()
{
Name = "my-snapshot",
SourceDisk = disk.Name,
Zone = "us-central1-a",
});
var ssd = new Gcp.Compute.RegionDisk("ssd", new()
{
Name = "my-disk",
ReplicaZones = new[]
{
"us-central1-a",
"us-central1-f",
},
Snapshot = snapdisk.Id,
Size = 50,
Type = "pd-ssd",
Region = "us-central1",
});
var policy = new Gcp.Compute.ResourcePolicy("policy", new()
{
Name = "my-resource-policy",
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 attachment = new Gcp.Compute.RegionDiskResourcePolicyAttachment("attachment", new()
{
Name = policy.Name,
Disk = ssd.Name,
Region = "us-central1",
});
var myImage = Gcp.Compute.GetImage.Invoke(new()
{
Family = "debian-11",
Project = "debian-cloud",
});
});
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.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.RegionDiskResourcePolicyAttachment;
import com.pulumi.gcp.compute.RegionDiskResourcePolicyAttachmentArgs;
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()
.name("my-base-disk")
.image("debian-cloud/debian-11")
.size(50)
.type("pd-ssd")
.zone("us-central1-a")
.build());
var snapdisk = new Snapshot("snapdisk", SnapshotArgs.builder()
.name("my-snapshot")
.sourceDisk(disk.name())
.zone("us-central1-a")
.build());
var ssd = new RegionDisk("ssd", RegionDiskArgs.builder()
.name("my-disk")
.replicaZones(
"us-central1-a",
"us-central1-f")
.snapshot(snapdisk.id())
.size(50)
.type("pd-ssd")
.region("us-central1")
.build());
var policy = new ResourcePolicy("policy", ResourcePolicyArgs.builder()
.name("my-resource-policy")
.region("us-central1")
.snapshotSchedulePolicy(ResourcePolicySnapshotSchedulePolicyArgs.builder()
.schedule(ResourcePolicySnapshotSchedulePolicyScheduleArgs.builder()
.dailySchedule(ResourcePolicySnapshotSchedulePolicyScheduleDailyScheduleArgs.builder()
.daysInCycle(1)
.startTime("04:00")
.build())
.build())
.build())
.build());
var attachment = new RegionDiskResourcePolicyAttachment("attachment", RegionDiskResourcePolicyAttachmentArgs.builder()
.name(policy.name())
.disk(ssd.name())
.region("us-central1")
.build());
final var myImage = ComputeFunctions.getImage(GetImageArgs.builder()
.family("debian-11")
.project("debian-cloud")
.build());
}
}
resources:
attachment:
type: gcp:compute:RegionDiskResourcePolicyAttachment
properties:
name: ${policy.name}
disk: ${ssd.name}
region: us-central1
disk:
type: gcp:compute:Disk
properties:
name: my-base-disk
image: debian-cloud/debian-11
size: 50
type: pd-ssd
zone: us-central1-a
snapdisk:
type: gcp:compute:Snapshot
properties:
name: my-snapshot
sourceDisk: ${disk.name}
zone: us-central1-a
ssd:
type: gcp:compute:RegionDisk
properties:
name: my-disk
replicaZones:
- us-central1-a
- us-central1-f
snapshot: ${snapdisk.id}
size: 50
type: pd-ssd
region: us-central1
policy:
type: gcp:compute:ResourcePolicy
properties:
name: my-resource-policy
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
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new RegionDiskResourcePolicyAttachment(name: string, args: RegionDiskResourcePolicyAttachmentArgs, opts?: CustomResourceOptions);
@overload
def RegionDiskResourcePolicyAttachment(resource_name: str,
args: RegionDiskResourcePolicyAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@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)
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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var regionDiskResourcePolicyAttachmentResource = new Gcp.Compute.RegionDiskResourcePolicyAttachment("regionDiskResourcePolicyAttachmentResource", new()
{
Disk = "string",
Name = "string",
Project = "string",
Region = "string",
});
example, err := compute.NewRegionDiskResourcePolicyAttachment(ctx, "regionDiskResourcePolicyAttachmentResource", &compute.RegionDiskResourcePolicyAttachmentArgs{
Disk: pulumi.String("string"),
Name: pulumi.String("string"),
Project: pulumi.String("string"),
Region: pulumi.String("string"),
})
var regionDiskResourcePolicyAttachmentResource = new RegionDiskResourcePolicyAttachment("regionDiskResourcePolicyAttachmentResource", RegionDiskResourcePolicyAttachmentArgs.builder()
.disk("string")
.name("string")
.project("string")
.region("string")
.build());
region_disk_resource_policy_attachment_resource = gcp.compute.RegionDiskResourcePolicyAttachment("regionDiskResourcePolicyAttachmentResource",
disk="string",
name="string",
project="string",
region="string")
const regionDiskResourcePolicyAttachmentResource = new gcp.compute.RegionDiskResourcePolicyAttachment("regionDiskResourcePolicyAttachmentResource", {
disk: "string",
name: "string",
project: "string",
region: "string",
});
type: gcp:compute:RegionDiskResourcePolicyAttachment
properties:
disk: string
name: string
project: string
region: string
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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
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.
- 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}}
When using the pulumi import
command, 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}}
To learn more about importing existing cloud resources, see Importing resources.
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.