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
This commit is contained in:
parent
e43871ece8
commit
d265a6fee3
|
@ -156,6 +156,12 @@ func resourceArmVirtualMachine() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"disk_size_gb": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
ValidateFunc: validateDiskSizeGB,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Set: resourceArmVirtualMachineStorageOsDiskHash,
|
Set: resourceArmVirtualMachineStorageOsDiskHash,
|
||||||
|
@ -188,16 +194,9 @@ func resourceArmVirtualMachine() *schema.Resource {
|
||||||
},
|
},
|
||||||
|
|
||||||
"disk_size_gb": {
|
"disk_size_gb": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
|
ValidateFunc: validateDiskSizeGB,
|
||||||
value := v.(int)
|
|
||||||
if value < 1 || value > 1023 {
|
|
||||||
errors = append(errors, fmt.Errorf(
|
|
||||||
"The `disk_size_gb` can only be between 1 and 1023"))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"lun": {
|
"lun": {
|
||||||
|
@ -429,6 +428,15 @@ func resourceArmVirtualMachine() *schema.Resource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func validateDiskSizeGB(v interface{}, k string) (ws []string, errors []error) {
|
||||||
|
value := v.(int)
|
||||||
|
if value < 1 || value > 1023 {
|
||||||
|
errors = append(errors, fmt.Errorf(
|
||||||
|
"The `disk_size_gb` can only be between 1 and 1023"))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func resourceArmVirtualMachineCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceArmVirtualMachineCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*ArmClient)
|
client := meta.(*ArmClient)
|
||||||
vmClient := client.vmClient
|
vmClient := client.vmClient
|
||||||
|
@ -924,6 +932,9 @@ func flattenAzureRmVirtualMachineOsDisk(disk *compute.OSDisk) []interface{} {
|
||||||
result["vhd_uri"] = *disk.Vhd.URI
|
result["vhd_uri"] = *disk.Vhd.URI
|
||||||
result["create_option"] = disk.CreateOption
|
result["create_option"] = disk.CreateOption
|
||||||
result["caching"] = disk.Caching
|
result["caching"] = disk.Caching
|
||||||
|
if disk.DiskSizeGB != nil {
|
||||||
|
result["disk_size_gb"] = *disk.DiskSizeGB
|
||||||
|
}
|
||||||
|
|
||||||
return []interface{}{result}
|
return []interface{}{result}
|
||||||
}
|
}
|
||||||
|
@ -1258,5 +1269,10 @@ func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk,
|
||||||
osDisk.Caching = compute.CachingTypes(v)
|
osDisk.Caching = compute.CachingTypes(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v := disk["disk_size_gb"].(int); v != 0 {
|
||||||
|
diskSize := int32(v)
|
||||||
|
osDisk.DiskSizeGB = &diskSize
|
||||||
|
}
|
||||||
|
|
||||||
return osDisk, nil
|
return osDisk, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -524,6 +524,7 @@ resource "azurerm_virtual_machine" "test" {
|
||||||
vhd_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
|
vhd_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
|
||||||
caching = "ReadWrite"
|
caching = "ReadWrite"
|
||||||
create_option = "FromImage"
|
create_option = "FromImage"
|
||||||
|
disk_size_gb = "45"
|
||||||
}
|
}
|
||||||
|
|
||||||
os_profile {
|
os_profile {
|
||||||
|
|
|
@ -249,6 +249,7 @@ For more information on the different example configurations, please check out t
|
||||||
* `caching` - (Optional) Specifies the caching requirements.
|
* `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.
|
* `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.
|
||||||
* `os_type` - (Optional) Specifies the operating system Type, valid values are windows, linux.
|
* `os_type` - (Optional) Specifies the operating system Type, valid values are windows, linux.
|
||||||
|
* `disk_size_gb` - (Optional) Specifies the size of the data disk in gigabytes.
|
||||||
|
|
||||||
`storage_data_disk` supports the following:
|
`storage_data_disk` supports the following:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue