2016-11-09 16:13:48 +01:00
|
|
|
package azurerm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"regexp"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAccAzureRMVirtualMachineExtension_basic(t *testing.T) {
|
|
|
|
ri := acctest.RandInt()
|
|
|
|
preConfig := fmt.Sprintf(testAccAzureRMVirtualMachineExtension_basic, ri, ri, ri, ri, ri, ri, ri, ri)
|
|
|
|
postConfig := fmt.Sprintf(testAccAzureRMVirtualMachineExtension_basicUpdate, ri, ri, ri, ri, ri, ri, ri, ri)
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testCheckAzureRMVirtualMachineExtensionDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: preConfig,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckAzureRMVirtualMachineExtensionExists("azurerm_virtual_machine_extension.test"),
|
|
|
|
resource.TestMatchResourceAttr("azurerm_virtual_machine_extension.test", "settings", regexp.MustCompile("hostname")),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
resource.TestStep{
|
|
|
|
Config: postConfig,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckAzureRMVirtualMachineExtensionExists("azurerm_virtual_machine_extension.test"),
|
|
|
|
resource.TestMatchResourceAttr("azurerm_virtual_machine_extension.test", "settings", regexp.MustCompile("whoami")),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAccAzureRMVirtualMachineExtension_concurrent(t *testing.T) {
|
|
|
|
ri := acctest.RandInt()
|
|
|
|
config := fmt.Sprintf(testAccAzureRMVirtualMachineExtension_concurrent, ri, ri, ri, ri, ri, ri, ri, ri, ri)
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testCheckAzureRMVirtualMachineExtensionDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: config,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckAzureRMVirtualMachineExtensionExists("azurerm_virtual_machine_extension.test"),
|
|
|
|
testCheckAzureRMVirtualMachineExtensionExists("azurerm_virtual_machine_extension.test2"),
|
|
|
|
resource.TestMatchResourceAttr("azurerm_virtual_machine_extension.test", "settings", regexp.MustCompile("hostname")),
|
|
|
|
resource.TestMatchResourceAttr("azurerm_virtual_machine_extension.test2", "settings", regexp.MustCompile("whoami")),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAccAzureRMVirtualMachineExtension_linuxDiagnostics(t *testing.T) {
|
|
|
|
ri := acctest.RandInt()
|
|
|
|
config := fmt.Sprintf(testAccAzureRMVirtualMachineExtension_linuxDiagnostics, ri, ri, ri, ri, ri, ri, ri, ri)
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testCheckAzureRMVirtualMachineExtensionDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: config,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckAzureRMVirtualMachineExtensionExists("azurerm_virtual_machine_extension.test"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func testCheckAzureRMVirtualMachineExtensionExists(name string) resource.TestCheckFunc {
|
|
|
|
return func(s *terraform.State) error {
|
|
|
|
// Ensure we have enough information in state to look up in API
|
|
|
|
rs, ok := s.RootModule().Resources[name]
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("Not found: %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
name := rs.Primary.Attributes["name"]
|
|
|
|
vmName := rs.Primary.Attributes["virtual_machine_name"]
|
|
|
|
resourceGroup := rs.Primary.Attributes["resource_group_name"]
|
|
|
|
|
|
|
|
conn := testAccProvider.Meta().(*ArmClient).vmExtensionClient
|
|
|
|
|
|
|
|
resp, err := conn.Get(resourceGroup, vmName, name, "")
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Bad: Get on vmExtensionClient: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if resp.StatusCode == http.StatusNotFound {
|
|
|
|
return fmt.Errorf("Bad: VirtualMachine Extension %q (resource group: %q) does not exist", name, resourceGroup)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testCheckAzureRMVirtualMachineExtensionDestroy(s *terraform.State) error {
|
|
|
|
conn := testAccProvider.Meta().(*ArmClient).vmExtensionClient
|
|
|
|
|
|
|
|
for _, rs := range s.RootModule().Resources {
|
|
|
|
if rs.Type != "azurerm_virtual_machine_extension" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
name := rs.Primary.Attributes["name"]
|
|
|
|
vmName := rs.Primary.Attributes["virtual_machine_name"]
|
|
|
|
resourceGroup := rs.Primary.Attributes["resource_group_name"]
|
|
|
|
|
|
|
|
resp, err := conn.Get(resourceGroup, vmName, name, "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if resp.StatusCode != http.StatusNotFound {
|
2016-12-06 09:39:47 +01:00
|
|
|
return fmt.Errorf("Virtual Machine Extension still exists:\n%#v", resp.VirtualMachineExtensionProperties)
|
2016-11-09 16:13:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var testAccAzureRMVirtualMachineExtension_basic = `
|
|
|
|
resource "azurerm_resource_group" "test" {
|
|
|
|
name = "acctestrg-%d"
|
|
|
|
location = "West US"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_network" "test" {
|
|
|
|
name = "acctvn-%d"
|
|
|
|
address_space = ["10.0.0.0/16"]
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_subnet" "test" {
|
|
|
|
name = "acctsub-%d"
|
|
|
|
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-%d"
|
|
|
|
location = "West US"
|
|
|
|
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_storage_account" "test" {
|
|
|
|
name = "accsa%d"
|
|
|
|
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_virtual_machine" "test" {
|
|
|
|
name = "acctvm-%d"
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
network_interface_ids = ["${azurerm_network_interface.test.id}"]
|
|
|
|
vm_size = "Standard_A0"
|
|
|
|
|
|
|
|
storage_image_reference {
|
|
|
|
publisher = "Canonical"
|
|
|
|
offer = "UbuntuServer"
|
|
|
|
sku = "14.04.2-LTS"
|
|
|
|
version = "latest"
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
|
|
|
os_profile {
|
|
|
|
computer_name = "hostname%d"
|
|
|
|
admin_username = "testadmin"
|
|
|
|
admin_password = "Password1234!"
|
|
|
|
}
|
|
|
|
|
|
|
|
os_profile_linux_config {
|
|
|
|
disable_password_authentication = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_machine_extension" "test" {
|
|
|
|
name = "acctvme-%d"
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
virtual_machine_name = "${azurerm_virtual_machine.test.name}"
|
|
|
|
publisher = "Microsoft.Azure.Extensions"
|
|
|
|
type = "CustomScript"
|
|
|
|
type_handler_version = "2.0"
|
|
|
|
|
|
|
|
settings = <<SETTINGS
|
|
|
|
{
|
|
|
|
"commandToExecute": "hostname"
|
|
|
|
}
|
|
|
|
SETTINGS
|
|
|
|
|
|
|
|
tags {
|
|
|
|
environment = "Production"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
var testAccAzureRMVirtualMachineExtension_basicUpdate = `
|
|
|
|
resource "azurerm_resource_group" "test" {
|
|
|
|
name = "acctestrg-%d"
|
|
|
|
location = "West US"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_network" "test" {
|
|
|
|
name = "acctvn-%d"
|
|
|
|
address_space = ["10.0.0.0/16"]
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_subnet" "test" {
|
|
|
|
name = "acctsub-%d"
|
|
|
|
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-%d"
|
|
|
|
location = "West US"
|
|
|
|
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_storage_account" "test" {
|
|
|
|
name = "accsa%d"
|
|
|
|
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_virtual_machine" "test" {
|
|
|
|
name = "acctvm-%d"
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
network_interface_ids = ["${azurerm_network_interface.test.id}"]
|
|
|
|
vm_size = "Standard_A0"
|
|
|
|
|
|
|
|
storage_image_reference {
|
|
|
|
publisher = "Canonical"
|
|
|
|
offer = "UbuntuServer"
|
|
|
|
sku = "14.04.2-LTS"
|
|
|
|
version = "latest"
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
|
|
|
os_profile {
|
|
|
|
computer_name = "hostname%d"
|
|
|
|
admin_username = "testadmin"
|
|
|
|
admin_password = "Password1234!"
|
|
|
|
}
|
|
|
|
|
|
|
|
os_profile_linux_config {
|
|
|
|
disable_password_authentication = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_machine_extension" "test" {
|
|
|
|
name = "acctvme-%d"
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
virtual_machine_name = "${azurerm_virtual_machine.test.name}"
|
|
|
|
publisher = "Microsoft.Azure.Extensions"
|
|
|
|
type = "CustomScript"
|
|
|
|
type_handler_version = "2.0"
|
|
|
|
|
|
|
|
settings = <<SETTINGS
|
|
|
|
{
|
|
|
|
"commandToExecute": "whoami"
|
|
|
|
}
|
|
|
|
SETTINGS
|
|
|
|
|
|
|
|
tags {
|
|
|
|
environment = "Production"
|
|
|
|
cost_center = "MSFT"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
var testAccAzureRMVirtualMachineExtension_concurrent = `
|
|
|
|
resource "azurerm_resource_group" "test" {
|
|
|
|
name = "acctestrg-%d"
|
|
|
|
location = "West US"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_network" "test" {
|
|
|
|
name = "acctvn-%d"
|
|
|
|
address_space = ["10.0.0.0/16"]
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_subnet" "test" {
|
|
|
|
name = "acctsub-%d"
|
|
|
|
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-%d"
|
|
|
|
location = "West US"
|
|
|
|
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_storage_account" "test" {
|
|
|
|
name = "accsa%d"
|
|
|
|
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_virtual_machine" "test" {
|
|
|
|
name = "acctvm-%d"
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
network_interface_ids = ["${azurerm_network_interface.test.id}"]
|
|
|
|
vm_size = "Standard_A0"
|
|
|
|
|
|
|
|
storage_image_reference {
|
|
|
|
publisher = "Canonical"
|
|
|
|
offer = "UbuntuServer"
|
|
|
|
sku = "14.04.2-LTS"
|
|
|
|
version = "latest"
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
|
|
|
os_profile {
|
|
|
|
computer_name = "hostname%d"
|
|
|
|
admin_username = "testadmin"
|
|
|
|
admin_password = "Password1234!"
|
|
|
|
}
|
|
|
|
|
|
|
|
os_profile_linux_config {
|
|
|
|
disable_password_authentication = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_machine_extension" "test" {
|
|
|
|
name = "acctvme-%d"
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
virtual_machine_name = "${azurerm_virtual_machine.test.name}"
|
|
|
|
publisher = "Microsoft.Azure.Extensions"
|
|
|
|
type = "CustomScript"
|
|
|
|
type_handler_version = "2.0"
|
|
|
|
|
|
|
|
settings = <<SETTINGS
|
|
|
|
{
|
|
|
|
"commandToExecute": "hostname"
|
|
|
|
}
|
|
|
|
SETTINGS
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_machine_extension" "test2" {
|
|
|
|
name = "acctvme-%d-2"
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
virtual_machine_name = "${azurerm_virtual_machine.test.name}"
|
|
|
|
publisher = "Microsoft.OSTCExtensions"
|
|
|
|
type = "CustomScriptForLinux"
|
|
|
|
type_handler_version = "1.5"
|
|
|
|
|
|
|
|
settings = <<SETTINGS
|
|
|
|
{
|
|
|
|
"commandToExecute": "whoami"
|
|
|
|
}
|
|
|
|
SETTINGS
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
var testAccAzureRMVirtualMachineExtension_linuxDiagnostics = `
|
|
|
|
resource "azurerm_resource_group" "test" {
|
|
|
|
name = "acctestrg-%d"
|
|
|
|
location = "West US"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_network" "test" {
|
|
|
|
name = "acctvn-%d"
|
|
|
|
address_space = ["10.0.0.0/16"]
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_subnet" "test" {
|
|
|
|
name = "acctsub-%d"
|
|
|
|
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-%d"
|
|
|
|
location = "West US"
|
|
|
|
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_storage_account" "test" {
|
|
|
|
name = "accsa%d"
|
|
|
|
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_virtual_machine" "test" {
|
|
|
|
name = "acctvm-%d"
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
network_interface_ids = ["${azurerm_network_interface.test.id}"]
|
|
|
|
vm_size = "Standard_A0"
|
|
|
|
|
|
|
|
storage_image_reference {
|
|
|
|
publisher = "Canonical"
|
|
|
|
offer = "UbuntuServer"
|
|
|
|
sku = "14.04.2-LTS"
|
|
|
|
version = "latest"
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
|
|
|
os_profile {
|
|
|
|
computer_name = "hostname%d"
|
|
|
|
admin_username = "testadmin"
|
|
|
|
admin_password = "Password1234!"
|
|
|
|
}
|
|
|
|
|
|
|
|
os_profile_linux_config {
|
|
|
|
disable_password_authentication = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_machine_extension" "test" {
|
|
|
|
name = "acctvme-%d"
|
|
|
|
location = "West US"
|
|
|
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
|
|
|
virtual_machine_name = "${azurerm_virtual_machine.test.name}"
|
|
|
|
publisher = "Microsoft.OSTCExtensions"
|
|
|
|
type = "LinuxDiagnostic"
|
|
|
|
type_handler_version = "2.3"
|
|
|
|
|
|
|
|
protected_settings = <<SETTINGS
|
|
|
|
{
|
|
|
|
"storageAccountName": "${azurerm_storage_account.test.name}",
|
|
|
|
"storageAccountKey": "${azurerm_storage_account.test.primary_access_key}"
|
|
|
|
}
|
|
|
|
SETTINGS
|
|
|
|
|
|
|
|
tags {
|
|
|
|
environment = "Production"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|