Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MS] Fixes #127 Improve docs for delete_os_disk_on_termination #139

Merged
merged 6 commits into from
Jul 3, 2017
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 48 additions & 123 deletions website/docs/r/virtual_machine.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ description: |-

Create a virtual machine.

## Example Usage (Unmanaged Disks)
## Example Usage with Managed Disks (Recommended)

```hcl
resource "azurerm_resource_group" "test" {
name = "acctestrg"
location = "West US"
location = "West US 2"
}

resource "azurerm_virtual_network" "test" {
name = "acctvn"
address_space = ["10.0.0.0/16"]
location = "West US"
location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}

Expand All @@ -34,7 +34,7 @@ resource "azurerm_subnet" "test" {

resource "azurerm_network_interface" "test" {
name = "acctni"
location = "West US"
location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"

ip_configuration {
Expand All @@ -44,30 +44,27 @@ resource "azurerm_network_interface" "test" {
}
}

resource "azurerm_storage_account" "test" {
name = "accsa"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "westus"
account_type = "Standard_LRS"

tags {
environment = "staging"
}
}

resource "azurerm_storage_container" "test" {
name = "vhds"
resource_group_name = "${azurerm_resource_group.test.name}"
storage_account_name = "${azurerm_storage_account.test.name}"
container_access_type = "private"
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"
location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
vm_size = "Standard_A0"
vm_size = "Standard_DS1_v2"

// Uncomment this line to delete the OS disk automatically when deleting the VM
// delete_os_disk_on_termination = true

// Uncomment this line to delete the data disks automatically when deleting the VM
// delete_data_disks_on_termination = true

storage_image_reference {
publisher = "Canonical"
Expand All @@ -77,10 +74,27 @@ resource "azurerm_virtual_machine" "test" {
}

storage_os_disk {
name = "myosdisk1"
vhd_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
caching = "ReadWrite"
create_option = "FromImage"
name = "myosdisk1"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}

// Optional data disks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking our other examples we use # for comments in HCL rather than // - I'm going to push a commit to update this :)

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 {
Expand All @@ -99,7 +113,7 @@ resource "azurerm_virtual_machine" "test" {
}
```

## Example Usage With Additional Empty Data Disk (Unmanaged Disks)
## Example Usage with Unmanaged Disks

```hcl
resource "azurerm_resource_group" "test" {
Expand Down Expand Up @@ -158,6 +172,12 @@ resource "azurerm_virtual_machine" "test" {
network_interface_ids = ["${azurerm_network_interface.test.id}"]
vm_size = "Standard_A0"

// Uncomment this line to delete the OS disk automatically when deleting the VM
// delete_os_disk_on_termination = true

// Uncomment this line to delete the data disks automatically when deleting the VM
// delete_data_disks_on_termination = true

storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
Expand All @@ -172,6 +192,7 @@ resource "azurerm_virtual_machine" "test" {
create_option = "FromImage"
}

// Optional data disks
storage_data_disk {
name = "datadisk0"
vhd_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/datadisk0.vhd"
Expand All @@ -196,102 +217,6 @@ resource "azurerm_virtual_machine" "test" {
}
```

## Example Usage (Managed Disks)

```hcl
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:
Expand Down