» azurerm_managed_disk
Manage a managed disk.
» Example Usage with Create Empty
resource "azurerm_resource_group" "test" {
name = "acctestRG"
location = "West US 2"
}
resource "azurerm_managed_disk" "test" {
name = "acctestmd"
location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
storage_account_type = "Standard_LRS"
create_option = "Empty"
disk_size_gb = "1"
tags = {
environment = "staging"
}
}
» Example Usage with Create Copy
resource "azurerm_resource_group" "test" {
name = "acctestRG"
location = "West US 2"
}
resource "azurerm_managed_disk" "source" {
name = "acctestmd1"
location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
storage_account_type = "Standard_LRS"
create_option = "Empty"
disk_size_gb = "1"
tags = {
environment = "staging"
}
}
resource "azurerm_managed_disk" "copy" {
name = "acctestmd2"
location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
storage_account_type = "Standard_LRS"
create_option = "Copy"
source_resource_id = "${azurerm_managed_disk.source.id}"
disk_size_gb = "1"
tags = {
environment = "staging"
}
}
» Argument Reference
The following arguments are supported:
-
name
- (Required) Specifies the name of the managed disk. Changing this forces a new resource to be created. -
resource_group_name
- (Required) The name of the resource group in which to create the managed disk. -
location
- (Required) Specified the supported Azure location where the resource exists. Changing this forces a new resource to be created. -
storage_account_type
- (Required) The type of storage to use for the managed disk. Allowable values areStandard_LRS
,Premium_LRS
,StandardSSD_LRS
orUltraSSD_LRS
. -
create_option
- (Required) The method to use when creating the managed disk. Possible values include: -
source_uri
- (Optional) URI to a valid VHD file to be used whencreate_option
isImport
. -
source_resource_id
- (Optional) ID of an existing managed disk to copy whencreate_option
isCopy
. -
image_reference_id
- (Optional) ID of an existing platform/marketplace disk image to copy whencreate_option
isFromImage
. -
os_type
- (Optional) Specify a value when the source of anImport
orCopy
operation targets a source that contains an operating system. Valid values areLinux
orWindows
-
disk_size_gb
- (Optional, Required for a new managed disk) Specifies the size of the managed disk to create in gigabytes. Ifcreate_option
isCopy
orFromImage
, then the value must be equal to or greater than the source's size. -
encryption_settings
- (Optional) anencryption_settings
block as defined below. -
tags
- (Optional) A mapping of tags to assign to the resource. -
zones
- (Optional) A collection containing the availability zone to allocate the Managed Disk in.
Please Note: Availability Zones are only supported in several regions at this time.
For more information on managed disks, such as sizing options and pricing, please check out the azure documentation.
encryption_settings
supports:
-
enabled
- (Required) Is Encryption enabled on this Managed Disk? Changing this forces a new resource to be created. -
disk_encryption_key
- (Optional) Adisk_encryption_key
block as defined below. -
key_encryption_key
- (Optional) Akey_encryption_key
block as defined below.
disk_encryption_key
supports:
-
secret_url
- (Required) The URL to the Key Vault Secret used as the Disk Encryption Key. This can be found asid
on theazurerm_key_vault_secret
resource. -
source_vault_id
- (Required) The URL of the Key Vault. This can be found asvault_uri
on theazurerm_key_vault
resource.
key_encryption_key
supports:
-
key_url
- (Required) The URL to the Key Vault Key used as the Key Encryption Key. This can be found asid
on theazurerm_key_vault_secret
resource. -
source_vault_id
- (Required) The URL of the Key Vault. This can be found asvault_uri
on theazurerm_key_vault
resource.
» Attributes Reference
The following attributes are exported:
-
id
- The managed disk ID.
» Import
Managed Disks can be imported using the resource id
, e.g.
terraform import azurerm_managed_disk.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.compute/disks/manageddisk1