updated/added documentation for managed disks

This commit is contained in:
Brandon Tosch 2017-03-05 23:42:44 -08:00
parent a17da26edb
commit eb2bef172f
3 changed files with 218 additions and 2 deletions

View File

@ -0,0 +1,107 @@
---
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_managed_disk"
sidebar_current: "docs-azurerm-resource-managed-disk"
description: |-
Create a Managed Disk.
---
# azurerm\_managed\_disk
Create 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 are `Standard_LRS` or `Premium_LRS`.
* `create_option` - (Required) The method to use when creating the managed disk.
* `Import` - Import a VHD file in to the managed disk (VHD specified with `source_uri`).
* `Empty` - Create an empty managed disk.
* `Copy` - Copy an existing managed disk or snapshot (specified with `source_resource_id`).
* `source_uri` - (Optional) URI to a valid VHD file to be used when `create_option` is `Import`.
* `source_resource_id` - (Optional) ID of an existing managed disk to copy when `create_option` is `Copy`.
* `os_type` - (Optional) Specify a value when the source of an `Import` or `Copy`
operation targets a source that contains an operating system. Valid values are `Linux` or `Windows`
* `disk_size_gb` - (Required) Specifies the size of the managed disk to create in gigabytes.
If `create_option` is `Copy`, then the value must be equal to or greater than the source's size.
* `tags` - (Optional) A mapping of tags to assign to the 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
```

View File

@ -196,6 +196,102 @@ resource "azurerm_virtual_machine" "test" {
}
```
## Example Usage with Managed Disks
```
resource "azurerm_resource_group" "test" {
name = "acctestrg"
location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn"
address_space = ["10.0.0.0/16"]
location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
resource "azurerm_subnet" "test" {
name = "acctsub"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.2.0/24"
}
resource "azurerm_network_interface" "test" {
name = "acctni"
location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.test.id}"
private_ip_address_allocation = "dynamic"
}
}
resource "azurerm_managed_disk" "test" {
name = "datadisk_existing"
location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
storage_account_type = "Standard_LRS"
create_option = "Empty"
disk_size_gb = "1023"
}
resource "azurerm_virtual_machine" "test" {
name = "acctvm"
location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
vm_size = "Standard_DS1_v2"
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "14.04.2-LTS"
version = "latest"
}
storage_os_disk {
name = "myosdisk1"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
storage_data_disk {
name = "datadisk_new"
managed_disk_type = "Standard_LRS"
create_option = "Empty"
lun = 0
disk_size_gb = "1023"
}
storage_data_disk {
name = "${azurerm_managed_disk.test.name}"
managed_disk_id = "${azurerm_managed_disk.test.id}"
create_option = "Attach"
lun = 1
disk_size_gb = "${azurerm_managed_disk.test.disk_size_gb}"
}
os_profile {
computer_name = "hostname"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_linux_config {
disable_password_authentication = false
}
tags {
environment = "staging"
}
}
```
## Argument Reference
The following arguments are supported:
@ -245,7 +341,9 @@ For more information on the different example configurations, please check out t
`storage_os_disk` supports the following:
* `name` - (Required) Specifies the disk name.
* `vhd_uri` - (Required) Specifies the vhd uri. Changing this forces a new resource to be created.
* `vhd_uri` - (Optional) Specifies the vhd uri. Changing this forces a new resource to be created. Cannot be used with managed disks.
* `managed_disk_type` - (Optional) Specifies the type of managed disk to create. Value you must be either `Standard_LRS` or `Premium_LRS`. Cannot be used when `vhd_uri` is specified.
* `managed_disk_id` - (Optional) Specifies an existing managed disk to use by id. Can only be used when `create_option` is `Attach`. Cannot be used when `vhd_uri` is specified.
* `create_option` - (Required) Specifies how the virtual machine should be created. Possible values are `attach` and `FromImage`.
* `caching` - (Optional) Specifies the caching requirements.
* `image_uri` - (Optional) Specifies the image_uri in the form publisherName:offer:skus:version. `image_uri` can also specify the [VHD uri](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-cli-deploy-templates/#create-a-custom-vm-image) of a custom VM image to clone. When cloning a custom disk image the `os_type` documented below becomes required.
@ -255,7 +353,9 @@ For more information on the different example configurations, please check out t
`storage_data_disk` supports the following:
* `name` - (Required) Specifies the name of the data disk.
* `vhd_uri` - (Required) Specifies the uri of the location in storage where the vhd for the virtual machine should be placed.
* `vhd_uri` - (Optional) Specifies the uri of the location in storage where the vhd for the virtual machine should be placed. Cannot be used with managed disks.
* `managed_disk_type` - (Optional) Specifies the type of managed disk to create. Value you must be either `Standard_LRS` or `Premium_LRS`. Cannot be used when `vhd_uri` is specified.
* `managed_disk_id` - (Optional) Specifies an existing managed disk to use by id. Can only be used when `create_option` is `Attach`. Cannot be used when `vhd_uri` is specified.
* `create_option` - (Required) Specifies how the data disk should be created.
* `disk_size_gb` - (Required) Specifies the size of the data disk in gigabytes.
* `caching` - (Optional) Specifies the caching requirements.

View File

@ -157,6 +157,15 @@
</ul>
</li>
<li<%= sidebar_current(/^docs-azurerm-resource-managed-disk/) %>>
<a href="#">Managed Disk Resources</a>
<ul class="nav nav-visible">
<li<%= sidebar_current("docs-azurerm-resource-managed-disk") %>>
<a href="/docs/providers/azurerm/r/managed_disk.html">azurerm_managed_disk</a>
</li>
</ul>
</li>
<li<%= sidebar_current(/^docs-azurerm-resource-network/) %>>
<a href="#">Network Resources</a>
<ul class="nav nav-visible">