AttachedDisk
Persistent disks can be attached to a compute instance using the attached_disk
section within the compute instance configuration.
However there may be situations where managing the attached disks via the compute
instance config isn’t preferable or possible, such as attaching dynamic
numbers of disks using the count variable.
To get more information about attaching disks, see:
- API documentation
- How-to Guides
Note: When using gcp.compute.AttachedDisk you must use lifecycle.ignore_changes = ["attached_disk"] on the gcp.compute.Instance resource that has the disks attached. Otherwise the two resources will fight for control of the attached disk block.
Create a AttachedDisk Resource
new AttachedDisk(name: string, args: AttachedDiskArgs, opts?: CustomResourceOptions);def AttachedDisk(resource_name, opts=None, device_name=None, disk=None, instance=None, mode=None, project=None, zone=None, __props__=None);func NewAttachedDisk(ctx *Context, name string, args AttachedDiskArgs, opts ...ResourceOption) (*AttachedDisk, error)public AttachedDisk(string name, AttachedDiskArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args AttachedDiskArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args AttachedDiskArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args AttachedDiskArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
AttachedDisk Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The AttachedDisk resource accepts the following input properties:
- Disk string
nameorself_linkof the disk that will be attached.- Instance string
nameorself_linkof the compute instance that the disk will be attached to. If theself_linkis provided thenzoneandprojectare extracted from the self link. If only the name is used thenzoneandprojectmust be defined as properties on the resource or provider.- Device
Name string Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance.
- Mode string
The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.
- Project string
The project that the referenced compute instance is a part of. If
instanceis referenced by itsself_linkthe project defined in the link will take precedence.- Zone string
The zone that the referenced compute instance is located within. If
instanceis referenced by itsself_linkthe zone defined in the link will take precedence.
- Disk string
nameorself_linkof the disk that will be attached.- Instance string
nameorself_linkof the compute instance that the disk will be attached to. If theself_linkis provided thenzoneandprojectare extracted from the self link. If only the name is used thenzoneandprojectmust be defined as properties on the resource or provider.- Device
Name string Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance.
- Mode string
The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.
- Project string
The project that the referenced compute instance is a part of. If
instanceis referenced by itsself_linkthe project defined in the link will take precedence.- Zone string
The zone that the referenced compute instance is located within. If
instanceis referenced by itsself_linkthe zone defined in the link will take precedence.
- disk string
nameorself_linkof the disk that will be attached.- instance string
nameorself_linkof the compute instance that the disk will be attached to. If theself_linkis provided thenzoneandprojectare extracted from the self link. If only the name is used thenzoneandprojectmust be defined as properties on the resource or provider.- device
Name string Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance.
- mode string
The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.
- project string
The project that the referenced compute instance is a part of. If
instanceis referenced by itsself_linkthe project defined in the link will take precedence.- zone string
The zone that the referenced compute instance is located within. If
instanceis referenced by itsself_linkthe zone defined in the link will take precedence.
- disk str
nameorself_linkof the disk that will be attached.- instance str
nameorself_linkof the compute instance that the disk will be attached to. If theself_linkis provided thenzoneandprojectare extracted from the self link. If only the name is used thenzoneandprojectmust be defined as properties on the resource or provider.- device_
name str Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance.
- mode str
The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.
- project str
The project that the referenced compute instance is a part of. If
instanceis referenced by itsself_linkthe project defined in the link will take precedence.- zone str
The zone that the referenced compute instance is located within. If
instanceis referenced by itsself_linkthe zone defined in the link will take precedence.
Outputs
All input properties are implicitly available as output properties. Additionally, the AttachedDisk resource produces the following output properties:
Look up an Existing AttachedDisk Resource
Get an existing AttachedDisk 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?: AttachedDiskState, opts?: CustomResourceOptions): AttachedDiskstatic get(resource_name, id, opts=None, device_name=None, disk=None, instance=None, mode=None, project=None, zone=None, __props__=None);func GetAttachedDisk(ctx *Context, name string, id IDInput, state *AttachedDiskState, opts ...ResourceOption) (*AttachedDisk, error)public static AttachedDisk Get(string name, Input<string> id, AttachedDiskState? state, CustomResourceOptions? opts = null)- 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.
The following state arguments are supported:
- Device
Name string Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance.
- Disk string
nameorself_linkof the disk that will be attached.- Instance string
nameorself_linkof the compute instance that the disk will be attached to. If theself_linkis provided thenzoneandprojectare extracted from the self link. If only the name is used thenzoneandprojectmust be defined as properties on the resource or provider.- Mode string
The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.
- Project string
The project that the referenced compute instance is a part of. If
instanceis referenced by itsself_linkthe project defined in the link will take precedence.- Zone string
The zone that the referenced compute instance is located within. If
instanceis referenced by itsself_linkthe zone defined in the link will take precedence.
- Device
Name string Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance.
- Disk string
nameorself_linkof the disk that will be attached.- Instance string
nameorself_linkof the compute instance that the disk will be attached to. If theself_linkis provided thenzoneandprojectare extracted from the self link. If only the name is used thenzoneandprojectmust be defined as properties on the resource or provider.- Mode string
The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.
- Project string
The project that the referenced compute instance is a part of. If
instanceis referenced by itsself_linkthe project defined in the link will take precedence.- Zone string
The zone that the referenced compute instance is located within. If
instanceis referenced by itsself_linkthe zone defined in the link will take precedence.
- device
Name string Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance.
- disk string
nameorself_linkof the disk that will be attached.- instance string
nameorself_linkof the compute instance that the disk will be attached to. If theself_linkis provided thenzoneandprojectare extracted from the self link. If only the name is used thenzoneandprojectmust be defined as properties on the resource or provider.- mode string
The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.
- project string
The project that the referenced compute instance is a part of. If
instanceis referenced by itsself_linkthe project defined in the link will take precedence.- zone string
The zone that the referenced compute instance is located within. If
instanceis referenced by itsself_linkthe zone defined in the link will take precedence.
- device_
name str Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance.
- disk str
nameorself_linkof the disk that will be attached.- instance str
nameorself_linkof the compute instance that the disk will be attached to. If theself_linkis provided thenzoneandprojectare extracted from the self link. If only the name is used thenzoneandprojectmust be defined as properties on the resource or provider.- mode str
The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.
- project str
The project that the referenced compute instance is a part of. If
instanceis referenced by itsself_linkthe project defined in the link will take precedence.- zone str
The zone that the referenced compute instance is located within. If
instanceis referenced by itsself_linkthe zone defined in the link will take precedence.
Package Details
- Repository
- https://github.com/pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
google-betaTerraform Provider.