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

Update managed disk docs with correct sizes & add Ultra SSD type #2118

Merged
merged 1 commit into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
50 changes: 0 additions & 50 deletions azurerm/import_arm_managed_disk_test.go

This file was deleted.

5 changes: 4 additions & 1 deletion azurerm/resource_arm_managed_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package azurerm

import (
"fmt"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress"
"log"
"strings"

Expand All @@ -18,6 +19,7 @@ func resourceArmManagedDisk() *schema.Resource {
Read: resourceArmManagedDiskRead,
Update: resourceArmManagedDiskCreate,
Delete: resourceArmManagedDiskDelete,

Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Expand All @@ -42,8 +44,9 @@ func resourceArmManagedDisk() *schema.Resource {
string(compute.StandardLRS),
string(compute.PremiumLRS),
string(compute.StandardSSDLRS),
string(compute.UltraSSDLRS),
}, true),
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
DiffSuppressFunc: suppress.CaseDifference,
},

"create_option": {
Expand Down
105 changes: 69 additions & 36 deletions azurerm/resource_arm_managed_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,65 @@ import (
)

func TestAccAzureRMManagedDisk_empty(t *testing.T) {
var d compute.Disk
resourceName := "azurerm_managed_disk.test"
ri := acctest.RandInt()
config := testAccAzureRMManagedDisk_empty(ri, testLocation())
var d compute.Disk

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMManagedDiskDestroy,
Steps: []resource.TestStep{
{
Config: config,
Config: testAccAzureRMManagedDisk_empty(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
testCheckAzureRMManagedDiskExists(resourceName, &d, true),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAzureRMManagedDisk_zeroGbFromPlatformImage(t *testing.T) {
var d compute.Disk
resourceName := "azurerm_managed_disk.test"
ri := acctest.RandInt()
config := testAccAzureRMManagedDisk_zeroGbFromPlatformImage(ri, testLocation())
var d compute.Disk

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMManagedDiskDestroy,
Steps: []resource.TestStep{
{
Config: config,
Config: testAccAzureRMManagedDisk_zeroGbFromPlatformImage(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
testCheckAzureRMManagedDiskExists(resourceName, &d, true),
),
},
},
})
}

func TestAccAzureRMManagedDisk_import(t *testing.T) {
var d compute.Disk
var vm compute.VirtualMachine
ri := acctest.RandInt()
resourceName := "azurerm_managed_disk.test"
location := testLocation()
vmConfig := testAccAzureRMVirtualMachine_basicLinuxMachine(ri, location)
config := testAccAzureRMManagedDisk_import(ri, location)
ri := acctest.RandInt()
var vm compute.VirtualMachine
var d compute.Disk

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMManagedDiskDestroy,
Steps: []resource.TestStep{
{
//need to create a vm and then delete it so we can use the vhd to test import
Config: vmConfig,
Config: testAccAzureRMVirtualMachine_basicLinuxMachine(ri, location),
Destroy: false,
ExpectNonEmptyPlan: true,
Check: resource.ComposeTestCheckFunc(
Expand All @@ -72,67 +79,67 @@ func TestAccAzureRMManagedDisk_import(t *testing.T) {
),
},
{
Config: config,
Config: testAccAzureRMManagedDisk_import(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
testCheckAzureRMManagedDiskExists(resourceName, &d, true),
),
},
},
})
}

func TestAccAzureRMManagedDisk_copy(t *testing.T) {
var d compute.Disk
resourceName := "azurerm_managed_disk.test"
ri := acctest.RandInt()
config := testAccAzureRMManagedDisk_copy(ri, testLocation())
var d compute.Disk

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMManagedDiskDestroy,
Steps: []resource.TestStep{
{
Config: config,
Config: testAccAzureRMManagedDisk_copy(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
testCheckAzureRMManagedDiskExists(resourceName, &d, true),
),
},
},
})
}

func TestAccAzureRMManagedDisk_fromPlatformImage(t *testing.T) {
var d compute.Disk
resourceName := "azurerm_managed_disk.test"
ri := acctest.RandInt()
config := testAccAzureRMManagedDisk_platformImage(ri, testLocation())
var d compute.Disk

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMManagedDiskDestroy,
Steps: []resource.TestStep{
{
Config: config,
Config: testAccAzureRMManagedDisk_platformImage(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
testCheckAzureRMManagedDiskExists(resourceName, &d, true),
),
},
},
})
}

func TestAccAzureRMManagedDisk_update(t *testing.T) {
var d compute.Disk

resourceName := "azurerm_managed_disk.test"
ri := acctest.RandInt()
preConfig := testAccAzureRMManagedDisk_empty(ri, testLocation())
postConfig := testAccAzureRMManagedDisk_empty_updated(ri, testLocation())
var d compute.Disk

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMManagedDiskDestroy,
Steps: []resource.TestStep{
{
Config: preConfig,
Config: testAccAzureRMManagedDisk_empty(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMManagedDiskExists(resourceName, &d, true),
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"),
Expand All @@ -143,7 +150,7 @@ func TestAccAzureRMManagedDisk_update(t *testing.T) {
),
},
{
Config: postConfig,
Config: testAccAzureRMManagedDisk_empty_updated(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMManagedDiskExists(resourceName, &d, true),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
Expand All @@ -157,19 +164,18 @@ func TestAccAzureRMManagedDisk_update(t *testing.T) {
}

func TestAccAzureRMManagedDisk_encryption(t *testing.T) {
var d compute.Disk

resourceName := "azurerm_managed_disk.test"
ri := acctest.RandInt()
rs := acctest.RandString(4)
preConfig := testAccAzureRMManagedDisk_encryption(ri, rs, testLocation())
var d compute.Disk

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMManagedDiskDestroy,
Steps: []resource.TestStep{
{
Config: preConfig,
Config: testAccAzureRMManagedDisk_encryption(ri, rs, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMManagedDiskExists(resourceName, &d, true),
resource.TestCheckResourceAttr(resourceName, "encryption_settings.#", "1"),
Expand All @@ -187,8 +193,10 @@ func TestAccAzureRMManagedDisk_encryption(t *testing.T) {
}

func TestAccAzureRMManagedDisk_NonStandardCasing(t *testing.T) {
var d compute.Disk
resourceName := "azurerm_managed_disk.test"
ri := acctest.RandInt()
var d compute.Disk

config := testAccAzureRMManagedDiskNonStandardCasing(ri, testLocation())
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -198,7 +206,7 @@ func TestAccAzureRMManagedDisk_NonStandardCasing(t *testing.T) {
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
testCheckAzureRMManagedDiskExists(resourceName, &d, true),
),
},
{
Expand All @@ -210,6 +218,31 @@ func TestAccAzureRMManagedDisk_NonStandardCasing(t *testing.T) {
})
}

func TestAccAzureRMManagedDisk_importEmpty_withZone(t *testing.T) {
resourceName := "azurerm_managed_disk.test"
ri := acctest.RandInt()
var d compute.Disk

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMManagedDiskDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMManagedDisk_empty_withZone(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMManagedDiskExists(resourceName, &d, true),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testCheckAzureRMManagedDiskExists(name string, d *compute.Disk, shouldExist bool) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[name]
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/managed_disk.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ The following arguments are supported:
Changing this forces a new resource to be created.

* `storage_account_type` - (Required) The type of storage to use for the managed disk.
Allowable values are `Standard_LRS` or `Premium_LRS`.
Allowable values are `Standard_LRS`, `Premium_LRS`, `StandardSSD_LRS` or `UltraSSD_LRS`.

* `create_option` - (Required) The method to use when creating the managed disk. Possible values include:
* `Import` - Import a VHD file in to the managed disk (VHD specified with `source_uri`).
Expand Down