Commit Graph

29 Commits

Author SHA1 Message Date
Andreas Kyrris 59d036202d provider/azurerm: Fix VHD deletion when VM and Storage account are in separate resource groups (#9631)
* Improve messaging when storage account isn't found.

* Add client for finding resources when you don't know it's resource group.

* Add function to find Storage Account resource group name.

* Use the storage account resource group, not the virtual machine's resource group when deleting VHDs.

* Add description of storage account ID for clarity.

* Improve VHD deletion test when storage account is in different resource group.

* Use common function for ID parsing of storage account.
2016-10-27 16:42:47 +01:00
Jonathan Rudenberg d265a6fee3 provider/azurerm: Add disk_size_gb param to VM storage_os_disk (#9200)
TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMVirtualMachine_basicLinuxMachine -timeout 120m
    === RUN   TestAccAzureRMVirtualMachine_basicLinuxMachine
    --- PASS: TestAccAzureRMVirtualMachine_basicLinuxMachine (540.83s)
    PASS
    ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	540.841s

    TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMVirtualMachine_withDataDisk -timeout 120m
    === RUN   TestAccAzureRMVirtualMachine_withDataDisk
    --- PASS: TestAccAzureRMVirtualMachine_withDataDisk (431.19s)
    PASS
    ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	431.203s
2016-10-25 17:54:55 +01:00
Paul Stack 89138fe22b Merge pull request #9122 from hashicorp/b-arm-vm-diagnostics
provider/azurerm: arm_virtual_machine diagnostics_profile was causing a panic on the Read func
2016-10-07 19:42:15 +01:00
stack72 dcfdc6ab30
provider/azurerm: arm_virtual_machine diagnostics_profile was causing a
panic on the Read func

Fixes #8995

The Diagnostics profile was a badly laid out resource. All we needed to
set was whether it was enabled and the storage account to save the logs
to. The old schema parameter was deprecated and replaced with a much
simplier structure

```
% make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMVirtualMachine_diagnosticsProfile'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/09/29 12:21:04 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/azurerm -v
-run=TestAccAzureRMVirtualMachine_diagnosticsProfile -timeout 120m
=== RUN   TestAccAzureRMVirtualMachine_diagnosticsProfile
--- PASS: TestAccAzureRMVirtualMachine_diagnosticsProfile (1066.76s)
PASS
ok
github.com/hashicorp/terraform/builtin/providers/azurerm1066.776s
```
2016-10-07 19:36:45 +01:00
Andreas Kyrris e5219ba56d Fixes behaviour when azurerm resources disappear.
Regressions were introduced when fixing
https://github.com/hashicorp/terraform/pull/8607 . Specifically when
resources in the statefile are deleted or missing in real life, then
terraform plan would exit with an error when it recieved a 404 not
found. The correct behaviour would be to show a plan with the offer to
create the missing resources.
2016-10-03 10:10:10 +01:00
stack72 971b08f320
Merge conflict resolution of virtual_machine.html.markdown in AzureRM 2016-09-12 11:13:24 +01:00
stack72 392f634ff4
provider/azurerm: Reordering the checks after an Azure API Get
We are receiving suggestions of a panic as follows:

```
2016/09/01 07:21:55 [DEBUG] plugin: terraform: panic: runtime error: invalid memory address or nil pointer dereference
2016/09/01 07:21:55 [DEBUG] plugin: terraform: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xa3170f]
2016/09/01 07:21:55 [DEBUG] plugin: terraform:
2016/09/01 07:21:55 [DEBUG] plugin: terraform: goroutine 114 [running]:
2016/09/01 07:21:55 [DEBUG] plugin: terraform: panic(0x27f4e60, 0xc4200100e0)
2016/09/01 07:21:55 [DEBUG] plugin: terraform: 	/opt/go/src/runtime/panic.go:500 +0x1a1
2016/09/01 07:21:55 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/azurerm.resourceArmVirtualMachineRead(0xc4206d8060, 0x2995620, 0xc4204d0000, 0x0, 0x17)
2016/09/01 07:21:55 [DEBUG] plugin: terraform: 	/opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/azurerm/resource_arm_virtual_machine.go:488 +0x1ff
2016/09/01 07:21:55 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc420017a40, 0xc42040c780, 0x2995620, 0xc4204d0000, 0xc42019c990, 0x1, 0x0)
```

This is because the code is as follows:

```
resp, err := client.Get(resGroup, vnetName, name)
if resp.StatusCode == http.StatusNotFound {
	d.SetId("")
	return nil
}
if err != nil {
	return fmt.Errorf("Error making Read request on Azure virtual network peering %s: %s", name, err)
}
```

When a request throws an error, the response object isn't valid. Therefore, we need to flip that code to check the error first

```
resp, err := client.Get(resGroup, vnetName, name)
if err != nil {
	return fmt.Errorf("Error making Read request on Azure virtual network peering %s: %s", name, err)
}
if resp.StatusCode == http.StatusNotFound {
	d.SetId("")
	return nil
}
```
2016-09-01 15:31:42 +01:00
Jeff Goldschrafe 08f2e6797b provider/azurerm: support Diagnostics Profile
Add support for a diagnostics profile, which allows boot diagnostics to
be enabled on a virtual machine.
2016-08-18 23:46:47 -04:00
Paul Stack 390e1acb3c provider/azurerm: Change of `availability_set_id` on (#7650)
`azurerm_virtual_machine` should ForceNew

Fixes #6873

```
make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMVirtualMachine_ChangeAvailbilitySet'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
TF_ACC=1 go test ./builtin/providers/azurerm -v
-run=TestAccAzureRMVirtualMachine_ChangeAvailbilitySet -timeout 120m
=== RUN   TestAccAzureRMVirtualMachine_ChangeAvailbilitySet
--- PASS: TestAccAzureRMVirtualMachine_ChangeAvailbilitySet (976.35s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm
976.367s
```
2016-07-27 22:39:03 +01:00
Peter McAtominey 1c13cc994b provider/azurerm: add option to delete VMs Data disks on termination (#7793)
```
TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMVirtualMachine_deleteVHD -timeout 120m
=== RUN   TestAccAzureRMVirtualMachine_deleteVHDOptOut
--- PASS: TestAccAzureRMVirtualMachine_deleteVHDOptOut (621.84s)
=== RUN   TestAccAzureRMVirtualMachine_deleteVHDOptIn
--- PASS: TestAccAzureRMVirtualMachine_deleteVHDOptIn (623.95s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	1245.930s
```
2016-07-25 17:57:02 +01:00
Paul Stack af4cc20ec0 provider/azurerm: `azurerm_virtual_machine` computer_name now Required (#7308)
Fixes #7299 where it was found that computer_name is not optional (as
the msdn documentation states)

```
make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMVirtualMachine_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMVirtualMachine_ -timeout 120m
=== RUN   TestAccAzureRMVirtualMachine_basicLinuxMachine
--- PASS: TestAccAzureRMVirtualMachine_basicLinuxMachine (403.53s)
=== RUN   TestAccAzureRMVirtualMachine_tags
--- PASS: TestAccAzureRMVirtualMachine_tags (488.46s)
=== RUN   TestAccAzureRMVirtualMachine_updateMachineSize
--- PASS: TestAccAzureRMVirtualMachine_updateMachineSize (601.82s)
=== RUN   TestAccAzureRMVirtualMachine_basicWindowsMachine
--- PASS: TestAccAzureRMVirtualMachine_basicWindowsMachine (646.75s)
=== RUN   TestAccAzureRMVirtualMachine_windowsUnattendedConfig
--- PASS: TestAccAzureRMVirtualMachine_windowsUnattendedConfig (891.42s)
=== RUN   TestAccAzureRMVirtualMachine_winRMConfig
--- PASS: TestAccAzureRMVirtualMachine_winRMConfig (768.73s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	3800.734s
```
2016-07-20 20:03:54 +01:00
Steven Eschinger 9c095d66e1 azurerm: fix vault_certificates in vm/scale_set (#7681)
When setting the certificate_url and certificate_store values in
os_profile_secrets / vault_certificates for a Windows VM in AzureRM, I
was getting the following error:

```
[DEBUG] Error setting Virtual Machine Storage OS Profile Secrets:
&errors.errorString{s:"Invalid address to set:
[]string{\"os_profile_secrets\", \"0\", \"vault_certificates\"}"}
```

This seems to resolve the issue.
2016-07-18 10:20:18 +01:00
stack72 33233be247
provider/azurerm: Change of `azurerm_virtual_machine` computer_name now
ForceNew

```
% make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMVirtualMachine_ChangeComputerName'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
TF_ACC=1 go test ./builtin/providers/azurerm -v
-run=TestAccAzureRMVirtualMachine_ChangeComputerName -timeout 120m
=== RUN   TestAccAzureRMVirtualMachine_ChangeComputerName
--- PASS: TestAccAzureRMVirtualMachine_ChangeComputerName (965.04s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm
965.051s
```
2016-07-14 15:48:41 +01:00
Peter McAtominey 37e3aa9d8c provider/azurerm: destroy azurerm_virtual_machine OS Disk VHD on deletion (#7584)
* provider/azurerm: destroy azurerm_virtual_machine OS Disk VHD on deletion

The OS Disk previously wasn't deleted with the VM, this causes subsequent
apply operations which recreate the VM to fail as the VHD blob already exists.

Fixes #6610

* provider/azurerm: add delete_os_disk_on_termination to azurerm_virtual_machine

delete_os_disk_on_termination is a bool which defaults to false to avoid making
a breaking change, and to follow the same flow as the Azure API
2016-07-13 23:52:20 +01:00
Paul Stack 421bda23b0 provider/azurerm: `azurerm_virtual_machine` panic at UnattendConfig (#7453)
Guarding against `invalid memory address` in AdditionalUnattendConfig

```
make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMVirtualMachine_windowsUnattendedConfig'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/azurerm -v
-run=TestAccAzureRMVirtualMachine_windowsUnattendedConfig -timeout 120m
=== RUN   TestAccAzureRMVirtualMachine_windowsUnattendedConfig
--- PASS: TestAccAzureRMVirtualMachine_windowsUnattendedConfig (943.28s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm
943.299s
```
2016-07-03 11:31:35 +01:00
stack72 e57ee0a067 provider/azurerm: Change `azurerm_virtual_machine` to use MaxItems
There were lots of hacky checks in the ARM VM resource to check for a
length of 1 param block

MaxItems was introduced so this PR updates to use MaxItems
2016-06-13 13:25:32 +02:00
Paul Stack ab721e2ffc provider/azurerm: Fix `azurerm_virtual_machine` windows_config (#7123)
When using winrm config block, we had an address issue. This is no
longer a set but a list (As a list fits it more approp)

    ```
    make testacc TEST=./builtin/providers/azurerm
    TESTARGS='-run=TestAccAzureRMVirtualMachine_'
    ==> Checking that code complies with gofmt requirements...
    go generate $(go list ./... | grep -v /vendor/)
    TF_ACC=1 go test ./builtin/providers/azurerm -v
    -run=TestAccAzureRMVirtualMachine_ -timeout 120m
    === RUN   TestAccAzureRMVirtualMachine_basicLinuxMachine
    --- PASS: TestAccAzureRMVirtualMachine_basicLinuxMachine (587.80s)
    === RUN   TestAccAzureRMVirtualMachine_tags
    --- PASS: TestAccAzureRMVirtualMachine_tags (554.53s)
    === RUN   TestAccAzureRMVirtualMachine_updateMachineSize
    --- PASS: TestAccAzureRMVirtualMachine_updateMachineSize (612.52s)
    === RUN   TestAccAzureRMVirtualMachine_basicWindowsMachine
    --- PASS: TestAccAzureRMVirtualMachine_basicWindowsMachine (765.90s)
    === RUN   TestAccAzureRMVirtualMachine_windowsUnattendedConfig
    --- PASS: TestAccAzureRMVirtualMachine_windowsUnattendedConfig
    (770.53s)
    === RUN   TestAccAzureRMVirtualMachine_winRMConfig
    --- PASS: TestAccAzureRMVirtualMachine_winRMConfig (827.90s)
    PASS
    ok      github.com/hashicorp/terraform/builtin/providers/azurerm
    4119.192s
    ```
2016-06-11 13:28:18 +02:00
stack72 155a47fa80 provider/azurerm: `azurerm_virtual_machine` Windows_config
Fixes #7053 where, when using `additional_unattend_config` in
`os_profile_windows_config` we got an error as follows:

```
azurerm_virtual_machine.test: [DEBUG] Error setting Virtual Machine
Storage OS Profile Windows Configuration: &errors.errorString{s:"Invalid
address to set: []string{\"os_profile_windows_config\", \"1534614206\",
\"additional_unattend_config\"}"}
```
2016-06-10 19:33:09 +01:00
James Nugent 738f4bd777 provider/azurerm: Fix azurerm_virtual_machine 2016-06-01 19:52:57 -05:00
James Nugent 0769674c54 provider/azurerm: Use new library configuration
Most resources are commented out at this stage, as they require surgery
to make them work with the new world of the Azure SDK.
2016-06-01 19:52:55 -05:00
Maxime Bury bd073c539e Fixes terraform crash when using SSH keys with Azure VMs (#6766) 2016-05-19 16:45:58 +01:00
Maxime Bury b33bd427e1 Normalizes availability_set_id to lowercase to avoid spurious diffs (#6768) 2016-05-19 16:44:29 +01:00
Antoine Rouaze a105de19c0 [azurerm] Add os_type and image_uri in azurerm_virtual_machine (#6553)
Fix #6372

Partial fix of #6526
2016-05-09 18:51:19 +01:00
Paul Stack d3939db0a1 provider/azurerm: Adding support for `tags` to `azurerm_virtual_machine` (#6556)
provider/azurerm: Adding support for `tags` to `azurerm_virtual_machine`
2016-05-09 18:14:02 +01:00
stack72 8dc47ac799 provider/azurerm: Error creating `azurerm_virtual_machine` data_disk
The `storage_data_disk` was trying to use vhd_url rather than vhd_uri.
This was causing an error on creating a new data_disk as part of a VM

Also added validation as data_disks can only be 1 - 1023 GB in size
2016-05-09 00:48:01 +01:00
stack72 712fc83a20 provider/azurerm: Fix an issue with `azurerm_virtual_machine` ssh_keys
ssh_keys were throwing an error similar to this:

```
* azurerm_virtual_machine.test: [DEBUG] Error setting Virtual Machine
* Storage OS Profile Linux Configuration: &errors.errorString{s:"Invalid
* address to set: []string{\"os_profile_linux_config\", \"0\",
* \"ssh_keys\"}"}
```

This was because of nesting of Set within a Set in the schema. By
changing this to a List within a Set, the schema works as expected. This
means we can now set SSH Keys on VMs. This has been tested using a
remote-exec and a connection block with the ssh key

```
azurerm_virtual_machine.test: Still creating... (2m10s elapsed)
azurerm_virtual_machine.test (remote-exec): Connected!
azurerm_virtual_machine.test (remote-exec): CONNECTED!
```
2016-05-08 22:51:51 +01:00
stack72 2e174ca3d4 provider/azurerm: Update `azurerm_virtual_machine` failed on
adminPassword

The Azure API never returns the AdminPAssword (as is correct) from the
Read API call. Therefore on Create, we do not set the AdminPassword of
the vm as part of the state. The Same func is used for Create & Update,
therefore when we changed anything on the VM, we were getting the
following error:

```
statusCode:Conflict
serviceRequestId:f498a6c8-6e7a-420f-9788-400f18078921
statusMessage:{"error":{"code":"PropertyChangeNotAllowed","target":"adminPassword","message":"Changing property 'adminPassword' is not allowed."}}
```

To fix this, we need to excldue the AdminPassword from the Update func
if it is empty
2016-05-06 23:44:03 +01:00
stack72 4db3242c53 provider/azurerm: Scaffolding the AzureRM Virtual Machine Test framework 2016-03-17 15:08:59 +00:00
stack72 cb109043f2 Scaffold the Azure RM Virtual Machine resource 2016-03-17 15:08:59 +00:00