Skip to content

Commit

Permalink
[azurerm] Add os_type and image_uri in azurerm_virtual_machine (hashi…
Browse files Browse the repository at this point in the history
  • Loading branch information
Erouan50 authored and cristicalin committed May 24, 2016
1 parent 0ed53e4 commit c70b492
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions builtin/providers/azurerm/resource_arm_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ func resourceArmVirtualMachine() *schema.Resource {
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"os_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},

"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Expand All @@ -128,6 +133,11 @@ func resourceArmVirtualMachine() *schema.Resource {
Required: true,
},

"image_uri": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},

"caching": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1082,6 +1092,7 @@ func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk,

name := disk["name"].(string)
vhdURI := disk["vhd_uri"].(string)
imageURI := disk["image_uri"].(string)
createOption := disk["create_option"].(string)

osDisk := &compute.OSDisk{
Expand All @@ -1092,6 +1103,22 @@ func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk,
CreateOption: compute.DiskCreateOptionTypes(createOption),
}

if v := disk["image_uri"].(string); v != "" {
osDisk.Image = &compute.VirtualHardDisk{
URI: &imageURI,
}
}

if v := disk["os_type"].(string); v != "" {
if v == "linux" {
osDisk.OsType = compute.Linux
} else if v == "windows" {
osDisk.OsType = compute.Windows
} else {
return nil, fmt.Errorf("[ERROR] os_type must be 'linux' or 'windows'")
}
}

if v := disk["caching"].(string); v != "" {
osDisk.Caching = compute.CachingTypes(v)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ For more information on the different example configurations, please check out t
* `vhd_uri` - (Required) Specifies the vhd uri.
* `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.
* `os_type` - (Optional) Specifies the operating system Type, valid values are windows, linux.

`storage_data_disk` supports the following:

Expand Down

0 comments on commit c70b492

Please sign in to comment.