diff --git a/CHANGELOG.md b/CHANGELOG.md
index a20d1aefc..9be92c79e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ FEATURES:
* **New Resource:** `aws_lightsail_static_ip` [GH-13175]
* **New Resource:** `aws_lightsail_static_ip_attachment` [GH-13207]
* **New Resource:** `aws_ses_domain_identity` [GH-13098]
+ * **New Resource**: `azurerm_managed_disk` [GH-12455]
* **New Resource:** `kubernetes_secret` [GH-12960]
* **New Data Source:** `aws_iam_role` [GH-13213]
@@ -35,16 +36,18 @@ IMPROVEMENTS:
* provider/aws: Add support for treat_missing_data to cloudwatch_metric_alarm [GH-13358]
* provider/aws: Add support for evaluate_low_sample_count_percentiles to cloudwatch_metric_alarm [GH-13371]
* provider/aws: Fix `aws_s3_bucket` drift detection of logging options [GH-13281]
+ * provider/bitbucket: Improved error handling [GH-13390]
* provider/cloudstack: Do not force a new resource when updating `cloudstack_loadbalancer_rule` members [GH-11786]
* provider/github: Handle the case when issue labels already exist [GH-13182]
* provider/google: Mark `google_container_cluster`'s `client_key` & `password` inside `master_auth` as sensitive [GH-13148]
* provider/triton: Move to joyent/triton-go [GH-13225]
-
+
BUG FIXES:
* core: Escaped interpolation-like sequences (like `$${foo}`) now permitted in variable defaults [GH-13137]
* core: Fix strange issues with computed values in provider configuration that were worked around with `-input=false` [GH-11264], [GH-13264]
* core: Fix crash when providing nested maps as variable values in a `module` block [GH-13343]
+ * core: `connection` block attributes are now subject to basic validation of attribute names during validate walk [GH-13400]
* provider/aws: Add Support for maintenance_window and back_window to rds_cluster_instance [GH-13134]
* provider/aws: Increase timeout for AMI registration [GH-13159]
* provider/aws: Increase timeouts for ELB [GH-13161]
@@ -67,6 +70,7 @@ BUG FIXES:
* provider/aws: Fix KMS Key reading with Exists method [GH-13348]
* provider/azurerm: Network Security Group - ignoring protocol casing at Import time [GH-13153]
* provider/azurerm: Fix crash when importing Local Network Gateways [GH-13261]
+ * provider/bitbucket: Fixed issue where provider would fail with an "EOF" error on some operations [GH-13390]
* provider/openstack: Refresh volume_attachment from state if NotFound [GH-13342]
* provider/profitbricks: Changed output type of ips variable of ip_block ProfitBricks resource [GH-13290]
diff --git a/backend/remote-state/consul/client.go b/backend/remote-state/consul/client.go
index cd5971163..b11f31ba1 100644
--- a/backend/remote-state/consul/client.go
+++ b/backend/remote-state/consul/client.go
@@ -121,16 +121,15 @@ func (c *RemoteClient) Lock(info *state.LockInfo) (string, error) {
default:
if c.lockCh != nil {
// we have an active lock already
- return "", nil
+ return "", fmt.Errorf("state %q already locked", c.Path)
}
}
if c.consulLock == nil {
opts := &consulapi.LockOptions{
Key: c.Path + lockSuffix,
- // We currently don't procide any options to block terraform and
- // retry lock acquisition, but we can wait briefly in case the
- // lock is about to be freed.
+ // only wait briefly, so terraform has the choice to fail fast or
+ // retry as needed.
LockWaitTime: time.Second,
LockTryOnce: true,
}
@@ -191,6 +190,10 @@ func (c *RemoteClient) Unlock(id string) error {
err := c.consulLock.Unlock()
c.lockCh = nil
+ // This is only cleanup, and will fail if the lock was immediately taken by
+ // another client, so we don't report an error to the user here.
+ c.consulLock.Destroy()
+
kv := c.Client.KV()
_, delErr := kv.Delete(c.Path+lockInfoSuffix, nil)
if delErr != nil {
diff --git a/backend/remote-state/consul/client_test.go b/backend/remote-state/consul/client_test.go
index 57b7c452e..dc7988135 100644
--- a/backend/remote-state/consul/client_test.go
+++ b/backend/remote-state/consul/client_test.go
@@ -6,6 +6,7 @@ import (
"time"
"github.com/hashicorp/terraform/backend"
+ "github.com/hashicorp/terraform/state"
"github.com/hashicorp/terraform/state/remote"
)
@@ -98,3 +99,43 @@ func TestConsul_stateLock(t *testing.T) {
remote.TestRemoteLocks(t, sA.(*remote.State).Client, sB.(*remote.State).Client)
}
+
+func TestConsul_destroyLock(t *testing.T) {
+ srv := newConsulTestServer(t)
+ defer srv.Stop()
+
+ // Get the backend
+ b := backend.TestBackendConfig(t, New(), map[string]interface{}{
+ "address": srv.HTTPAddr,
+ "path": fmt.Sprintf("tf-unit/%s", time.Now().String()),
+ })
+
+ // Grab the client
+ s, err := b.State(backend.DefaultStateName)
+ if err != nil {
+ t.Fatalf("err: %s", err)
+ }
+
+ c := s.(*remote.State).Client.(*RemoteClient)
+
+ info := state.NewLockInfo()
+ id, err := c.Lock(info)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ lockPath := c.Path + lockSuffix
+
+ if err := c.Unlock(id); err != nil {
+ t.Fatal(err)
+ }
+
+ // get the lock val
+ pair, _, err := c.Client.KV().Get(lockPath, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if pair != nil {
+ t.Fatalf("lock key not cleaned up at: %s", pair.Key)
+ }
+}
diff --git a/builtin/providers/aws/data_source_aws_ecs_task_definition_test.go b/builtin/providers/aws/data_source_aws_ecs_task_definition_test.go
index 545da0714..6d6ffa35a 100644
--- a/builtin/providers/aws/data_source_aws_ecs_task_definition_test.go
+++ b/builtin/providers/aws/data_source_aws_ecs_task_definition_test.go
@@ -15,10 +15,10 @@ func TestAccAWSEcsDataSource_ecsTaskDefinition(t *testing.T) {
resource.TestStep{
Config: testAccCheckAwsEcsTaskDefinitionDataSourceConfig,
Check: resource.ComposeTestCheckFunc(
- resource.TestMatchResourceAttr("data.aws_ecs_task_definition.mongo", "id", regexp.MustCompile("^arn:aws:ecs:us-west-2:[0-9]{12}:task-definition/mongodb:[1-9]*[0-9]$")),
+ resource.TestMatchResourceAttr("data.aws_ecs_task_definition.mongo", "id", regexp.MustCompile("^arn:aws:ecs:us-west-2:[0-9]{12}:task-definition/mongodb:[1-9][0-9]*$")),
resource.TestCheckResourceAttr("data.aws_ecs_task_definition.mongo", "family", "mongodb"),
resource.TestCheckResourceAttr("data.aws_ecs_task_definition.mongo", "network_mode", "bridge"),
- resource.TestMatchResourceAttr("data.aws_ecs_task_definition.mongo", "revision", regexp.MustCompile("^[1-9]*[0-9]$")),
+ resource.TestMatchResourceAttr("data.aws_ecs_task_definition.mongo", "revision", regexp.MustCompile("^[1-9][0-9]*$")),
resource.TestCheckResourceAttr("data.aws_ecs_task_definition.mongo", "status", "ACTIVE"),
resource.TestMatchResourceAttr("data.aws_ecs_task_definition.mongo", "task_role_arn", regexp.MustCompile("^arn:aws:iam::[0-9]{12}:role/mongo_role$")),
),
diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go
index a5e10e034..ef21f2492 100644
--- a/builtin/providers/aws/resource_aws_autoscaling_group.go
+++ b/builtin/providers/aws/resource_aws_autoscaling_group.go
@@ -446,7 +446,6 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e
d.Set("health_check_type", g.HealthCheckType)
d.Set("launch_configuration", g.LaunchConfigurationName)
d.Set("load_balancers", flattenStringList(g.LoadBalancerNames))
- d.Set("target_group_arns", flattenStringList(g.TargetGroupARNs))
if err := d.Set("suspended_processes", flattenAsgSuspendedProcesses(g.SuspendedProcesses)); err != nil {
log.Printf("[WARN] Error setting suspended_processes for %q: %s", d.Id(), err)
diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go
index 1c310433f..ee17f8844 100644
--- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go
+++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go
@@ -445,15 +445,6 @@ func TestAccAWSAutoScalingGroup_ALB_TargetGroups(t *testing.T) {
"aws_autoscaling_group.bar", "target_group_arns.#", "1"),
),
},
-
- resource.TestStep{
- Config: testAccAWSAutoScalingGroupConfig_ALB_TargetGroup_pre,
- Check: resource.ComposeAggregateTestCheckFunc(
- testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group),
- resource.TestCheckResourceAttr(
- "aws_autoscaling_group.bar", "target_group_arns.#", "0"),
- ),
- },
},
})
}
diff --git a/builtin/providers/azurerm/config.go b/builtin/providers/azurerm/config.go
index bbf15712f..8535b67c7 100644
--- a/builtin/providers/azurerm/config.go
+++ b/builtin/providers/azurerm/config.go
@@ -11,6 +11,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/containerregistry"
"github.com/Azure/azure-sdk-for-go/arm/containerservice"
+ "github.com/Azure/azure-sdk-for-go/arm/disk"
"github.com/Azure/azure-sdk-for-go/arm/eventhub"
"github.com/Azure/azure-sdk-for-go/arm/keyvault"
"github.com/Azure/azure-sdk-for-go/arm/network"
@@ -47,6 +48,8 @@ type ArmClient struct {
vmImageClient compute.VirtualMachineImagesClient
vmClient compute.VirtualMachinesClient
+ diskClient disk.DisksClient
+
appGatewayClient network.ApplicationGatewaysClient
ifaceClient network.InterfacesClient
loadBalancerClient network.LoadBalancersClient
@@ -245,6 +248,12 @@ func (c *Config) getArmClient() (*ArmClient, error) {
csc.Sender = autorest.CreateSender(withRequestLogging())
client.containerServicesClient = csc
+ dkc := disk.NewDisksClientWithBaseURI(endpoint, c.SubscriptionID)
+ setUserAgent(&dkc.Client)
+ dkc.Authorizer = spt
+ dkc.Sender = autorest.CreateSender(withRequestLogging())
+ client.diskClient = dkc
+
ehc := eventhub.NewEventHubsClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&ehc.Client)
ehc.Authorizer = spt
diff --git a/builtin/providers/azurerm/import_arm_managed_disk_test.go b/builtin/providers/azurerm/import_arm_managed_disk_test.go
new file mode 100644
index 000000000..51eaa6abd
--- /dev/null
+++ b/builtin/providers/azurerm/import_arm_managed_disk_test.go
@@ -0,0 +1,30 @@
+package azurerm
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/acctest"
+ "github.com/hashicorp/terraform/helper/resource"
+)
+
+func TestAccAzureRMManagedDisk_importEmpty(t *testing.T) {
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMManagedDisk_empty, ri, ri)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMManagedDiskDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ },
+ {
+ ResourceName: "azurerm_managed_disk.test",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
diff --git a/builtin/providers/azurerm/import_arm_virtual_machine_test.go b/builtin/providers/azurerm/import_arm_virtual_machine_test.go
index 806d44987..f6b72e208 100644
--- a/builtin/providers/azurerm/import_arm_virtual_machine_test.go
+++ b/builtin/providers/azurerm/import_arm_virtual_machine_test.go
@@ -19,11 +19,39 @@ func TestAccAzureRMVirtualMachine_importBasic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
},
- resource.TestStep{
+ {
+ ResourceName: resourceName,
+ ImportState: true,
+ ImportStateVerify: true,
+ ImportStateVerifyIgnore: []string{
+ "delete_data_disks_on_termination",
+ "delete_os_disk_on_termination",
+ },
+ },
+ },
+ })
+}
+
+func TestAccAzureRMVirtualMachine_importBasic_managedDisk(t *testing.T) {
+ resourceName := "azurerm_virtual_machine.test"
+
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_explicit, ri, ri, ri, ri, ri, ri, ri)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ },
+
+ {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
diff --git a/builtin/providers/azurerm/provider.go b/builtin/providers/azurerm/provider.go
index 8364fe4cf..c57aae2c2 100644
--- a/builtin/providers/azurerm/provider.go
+++ b/builtin/providers/azurerm/provider.go
@@ -85,6 +85,8 @@ func Provider() terraform.ResourceProvider {
"azurerm_lb_probe": resourceArmLoadBalancerProbe(),
"azurerm_lb_rule": resourceArmLoadBalancerRule(),
+ "azurerm_managed_disk": resourceArmManagedDisk(),
+
"azurerm_key_vault": resourceArmKeyVault(),
"azurerm_local_network_gateway": resourceArmLocalNetworkGateway(),
"azurerm_network_interface": resourceArmNetworkInterface(),
diff --git a/builtin/providers/azurerm/resource_arm_managed_disk.go b/builtin/providers/azurerm/resource_arm_managed_disk.go
new file mode 100644
index 000000000..9f3fdc4c5
--- /dev/null
+++ b/builtin/providers/azurerm/resource_arm_managed_disk.go
@@ -0,0 +1,238 @@
+package azurerm
+
+import (
+ "fmt"
+ "github.com/Azure/azure-sdk-for-go/arm/disk"
+ "github.com/hashicorp/terraform/helper/schema"
+ "github.com/hashicorp/terraform/helper/validation"
+ "log"
+ "net/http"
+ "strings"
+)
+
+func resourceArmManagedDisk() *schema.Resource {
+ return &schema.Resource{
+ Create: resourceArmManagedDiskCreate,
+ Read: resourceArmManagedDiskRead,
+ Update: resourceArmManagedDiskCreate,
+ Delete: resourceArmManagedDiskDelete,
+ Importer: &schema.ResourceImporter{
+ State: schema.ImportStatePassthrough,
+ },
+
+ Schema: map[string]*schema.Schema{
+ "name": {
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+
+ "location": locationSchema(),
+
+ "resource_group_name": {
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+
+ "storage_account_type": {
+ Type: schema.TypeString,
+ Required: true,
+ ValidateFunc: validation.StringInSlice([]string{
+ string(disk.PremiumLRS),
+ string(disk.StandardLRS),
+ }, true),
+ },
+
+ "create_option": {
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ ValidateFunc: validation.StringInSlice([]string{
+ string(disk.Import),
+ string(disk.Empty),
+ string(disk.Copy),
+ }, true),
+ },
+
+ "source_uri": {
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ForceNew: true,
+ },
+
+ "source_resource_id": {
+ Type: schema.TypeString,
+ Optional: true,
+ ForceNew: true,
+ },
+
+ "os_type": {
+ Type: schema.TypeString,
+ Optional: true,
+ ValidateFunc: validation.StringInSlice([]string{
+ string(disk.Windows),
+ string(disk.Linux),
+ }, true),
+ },
+
+ "disk_size_gb": {
+ Type: schema.TypeInt,
+ Required: true,
+ ValidateFunc: validateDiskSizeGB,
+ },
+
+ "tags": tagsSchema(),
+ },
+ }
+}
+
+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 resourceArmManagedDiskCreate(d *schema.ResourceData, meta interface{}) error {
+ client := meta.(*ArmClient)
+ diskClient := client.diskClient
+
+ log.Printf("[INFO] preparing arguments for Azure ARM Managed Disk creation.")
+
+ name := d.Get("name").(string)
+ location := d.Get("location").(string)
+ resGroup := d.Get("resource_group_name").(string)
+ tags := d.Get("tags").(map[string]interface{})
+ expandedTags := expandTags(tags)
+
+ createDisk := disk.Model{
+ Name: &name,
+ Location: &location,
+ Tags: expandedTags,
+ }
+
+ storageAccountType := d.Get("storage_account_type").(string)
+ osType := d.Get("os_type").(string)
+
+ createDisk.Properties = &disk.Properties{
+ AccountType: disk.StorageAccountTypes(storageAccountType),
+ OsType: disk.OperatingSystemTypes(osType),
+ }
+
+ if v := d.Get("disk_size_gb"); v != 0 {
+ diskSize := int32(v.(int))
+ createDisk.Properties.DiskSizeGB = &diskSize
+ }
+ createOption := d.Get("create_option").(string)
+
+ creationData := &disk.CreationData{
+ CreateOption: disk.CreateOption(createOption),
+ }
+
+ if strings.EqualFold(createOption, string(disk.Import)) {
+ if sourceUri := d.Get("source_uri").(string); sourceUri != "" {
+ creationData.SourceURI = &sourceUri
+ } else {
+ return fmt.Errorf("[ERROR] source_uri must be specified when create_option is `%s`", disk.Import)
+ }
+ } else if strings.EqualFold(createOption, string(disk.Copy)) {
+ if sourceResourceId := d.Get("source_resource_id").(string); sourceResourceId != "" {
+ creationData.SourceResourceID = &sourceResourceId
+ } else {
+ return fmt.Errorf("[ERROR] source_resource_id must be specified when create_option is `%s`", disk.Copy)
+ }
+ }
+
+ createDisk.CreationData = creationData
+
+ _, diskErr := diskClient.CreateOrUpdate(resGroup, name, createDisk, make(chan struct{}))
+ if diskErr != nil {
+ return diskErr
+ }
+
+ read, err := diskClient.Get(resGroup, name)
+ if err != nil {
+ return err
+ }
+ if read.ID == nil {
+ return fmt.Errorf("[ERROR] Cannot read Managed Disk %s (resource group %s) ID", name, resGroup)
+ }
+
+ d.SetId(*read.ID)
+
+ return resourceArmManagedDiskRead(d, meta)
+}
+
+func resourceArmManagedDiskRead(d *schema.ResourceData, meta interface{}) error {
+ diskClient := meta.(*ArmClient).diskClient
+
+ id, err := parseAzureResourceID(d.Id())
+ if err != nil {
+ return err
+ }
+ resGroup := id.ResourceGroup
+ name := id.Path["disks"]
+
+ resp, err := diskClient.Get(resGroup, name)
+ if err != nil {
+ if resp.StatusCode == http.StatusNotFound {
+ d.SetId("")
+ return nil
+ }
+ return fmt.Errorf("[ERROR] Error making Read request on Azure Managed Disk %s (resource group %s): %s", name, resGroup, err)
+ }
+
+ d.Set("name", resp.Name)
+ d.Set("resource_group_name", resGroup)
+ d.Set("location", resp.Location)
+
+ if resp.Properties != nil {
+ flattenAzureRmManagedDiskProperties(d, resp.Properties)
+ }
+
+ if resp.CreationData != nil {
+ flattenAzureRmManagedDiskCreationData(d, resp.CreationData)
+ }
+
+ flattenAndSetTags(d, resp.Tags)
+
+ return nil
+}
+
+func resourceArmManagedDiskDelete(d *schema.ResourceData, meta interface{}) error {
+ diskClient := meta.(*ArmClient).diskClient
+
+ id, err := parseAzureResourceID(d.Id())
+ if err != nil {
+ return err
+ }
+ resGroup := id.ResourceGroup
+ name := id.Path["disks"]
+
+ if _, err = diskClient.Delete(resGroup, name, make(chan struct{})); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func flattenAzureRmManagedDiskProperties(d *schema.ResourceData, properties *disk.Properties) {
+ d.Set("storage_account_type", string(properties.AccountType))
+ if properties.DiskSizeGB != nil {
+ d.Set("disk_size_gb", *properties.DiskSizeGB)
+ }
+ if properties.OsType != "" {
+ d.Set("os_type", string(properties.OsType))
+ }
+}
+
+func flattenAzureRmManagedDiskCreationData(d *schema.ResourceData, creationData *disk.CreationData) {
+ d.Set("create_option", string(creationData.CreateOption))
+ if creationData.SourceURI != nil {
+ d.Set("source_uri", *creationData.SourceURI)
+ }
+}
diff --git a/builtin/providers/azurerm/resource_arm_managed_disk_test.go b/builtin/providers/azurerm/resource_arm_managed_disk_test.go
new file mode 100644
index 000000000..b7512e2a7
--- /dev/null
+++ b/builtin/providers/azurerm/resource_arm_managed_disk_test.go
@@ -0,0 +1,321 @@
+package azurerm
+
+import (
+ "fmt"
+ "net/http"
+ "testing"
+
+ "github.com/Azure/azure-sdk-for-go/arm/compute"
+ "github.com/Azure/azure-sdk-for-go/arm/disk"
+ "github.com/hashicorp/terraform/helper/acctest"
+ "github.com/hashicorp/terraform/helper/resource"
+ "github.com/hashicorp/terraform/terraform"
+)
+
+func TestAccAzureRMManagedDisk_empty(t *testing.T) {
+ var d disk.Model
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMManagedDisk_empty, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMManagedDiskDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
+ ),
+ },
+ },
+ })
+}
+
+func TestAccAzureRMManagedDisk_import(t *testing.T) {
+ var d disk.Model
+ var vm compute.VirtualMachine
+ ri := acctest.RandInt()
+ vmConfig := fmt.Sprintf(testAccAzureRMVirtualMachine_basicLinuxMachine, ri, ri, ri, ri, ri, ri, ri)
+ config := fmt.Sprintf(testAccAzureRMManagedDisk_import, ri, ri, ri)
+ 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,
+ Destroy: false,
+ ExpectNonEmptyPlan: true,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
+ testDeleteAzureRMVirtualMachine("azurerm_virtual_machine.test"),
+ ),
+ },
+ {
+ Config: config,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
+ ),
+ },
+ },
+ })
+}
+
+func TestAccAzureRMManagedDisk_copy(t *testing.T) {
+ var d disk.Model
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMManagedDisk_copy, ri, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMManagedDiskDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
+ ),
+ },
+ },
+ })
+}
+
+func TestAccAzureRMManagedDisk_update(t *testing.T) {
+ var d disk.Model
+
+ ri := acctest.RandInt()
+ preConfig := fmt.Sprintf(testAccAzureRMManagedDisk_empty, ri, ri)
+ postConfig := fmt.Sprintf(testAccAzureRMManagedDisk_empty_updated, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMManagedDiskDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: preConfig,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
+ resource.TestCheckResourceAttr(
+ "azurerm_managed_disk.test", "tags.%", "2"),
+ resource.TestCheckResourceAttr(
+ "azurerm_managed_disk.test", "tags.environment", "acctest"),
+ resource.TestCheckResourceAttr(
+ "azurerm_managed_disk.test", "tags.cost-center", "ops"),
+ resource.TestCheckResourceAttr(
+ "azurerm_managed_disk.test", "disk_size_gb", "1"),
+ resource.TestCheckResourceAttr(
+ "azurerm_managed_disk.test", "storage_account_type", string(disk.StandardLRS)),
+ ),
+ },
+ {
+ Config: postConfig,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d, true),
+ resource.TestCheckResourceAttr(
+ "azurerm_managed_disk.test", "tags.%", "1"),
+ resource.TestCheckResourceAttr(
+ "azurerm_managed_disk.test", "tags.environment", "acctest"),
+ resource.TestCheckResourceAttr(
+ "azurerm_managed_disk.test", "disk_size_gb", "2"),
+ resource.TestCheckResourceAttr(
+ "azurerm_managed_disk.test", "storage_account_type", string(disk.PremiumLRS)),
+ ),
+ },
+ },
+ })
+}
+
+func testCheckAzureRMManagedDiskExists(name string, d *disk.Model, shouldExist bool) resource.TestCheckFunc {
+ return func(s *terraform.State) error {
+ rs, ok := s.RootModule().Resources[name]
+ if !ok {
+ return fmt.Errorf("Not found: %s", name)
+ }
+
+ dName := rs.Primary.Attributes["name"]
+ resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
+ if !hasResourceGroup {
+ return fmt.Errorf("Bad: no resource group found in state for disk: %s", dName)
+ }
+
+ conn := testAccProvider.Meta().(*ArmClient).diskClient
+
+ resp, err := conn.Get(resourceGroup, dName)
+ if err != nil {
+ return fmt.Errorf("Bad: Get on diskClient: %s", err)
+ }
+
+ if resp.StatusCode == http.StatusNotFound && shouldExist {
+ return fmt.Errorf("Bad: ManagedDisk %q (resource group %q) does not exist", dName, resourceGroup)
+ }
+ if resp.StatusCode != http.StatusNotFound && !shouldExist {
+ return fmt.Errorf("Bad: ManagedDisk %q (resource group %q) still exists", dName, resourceGroup)
+ }
+
+ *d = resp
+
+ return nil
+ }
+}
+
+func testCheckAzureRMManagedDiskDestroy(s *terraform.State) error {
+ conn := testAccProvider.Meta().(*ArmClient).diskClient
+
+ for _, rs := range s.RootModule().Resources {
+ if rs.Type != "azurerm_managed_disk" {
+ continue
+ }
+
+ name := rs.Primary.Attributes["name"]
+ resourceGroup := rs.Primary.Attributes["resource_group_name"]
+
+ resp, err := conn.Get(resourceGroup, name)
+
+ if err != nil {
+ return nil
+ }
+
+ if resp.StatusCode != http.StatusNotFound {
+ return fmt.Errorf("Managed Disk still exists: \n%#v", resp.Properties)
+ }
+ }
+
+ return nil
+}
+
+func testDeleteAzureRMVirtualMachine(name string) resource.TestCheckFunc {
+ return func(s *terraform.State) error {
+ rs, ok := s.RootModule().Resources[name]
+ if !ok {
+ return fmt.Errorf("Not found: %s", name)
+ }
+
+ vmName := rs.Primary.Attributes["name"]
+ resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
+ if !hasResourceGroup {
+ return fmt.Errorf("Bad: no resource group found in state for virtual machine: %s", vmName)
+ }
+
+ conn := testAccProvider.Meta().(*ArmClient).vmClient
+
+ _, err := conn.Delete(resourceGroup, vmName, make(chan struct{}))
+ if err != nil {
+ return fmt.Errorf("Bad: Delete on vmClient: %s", err)
+ }
+
+ return nil
+ }
+}
+
+var testAccAzureRMManagedDisk_empty = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_managed_disk" "test" {
+ name = "acctestd-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ storage_account_type = "Standard_LRS"
+ create_option = "Empty"
+ disk_size_gb = "1"
+
+ tags {
+ environment = "acctest"
+ cost-center = "ops"
+ }
+}`
+
+var testAccAzureRMManagedDisk_import = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_storage_account" "test" {
+ name = "accsa%d"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ location = "West US 2"
+ 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_managed_disk" "test" {
+ name = "acctestd-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ storage_account_type = "Standard_LRS"
+ create_option = "Import"
+ source_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd"
+ disk_size_gb = "45"
+
+ tags {
+ environment = "acctest"
+ }
+}`
+
+var testAccAzureRMManagedDisk_copy = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_managed_disk" "source" {
+ name = "acctestd1-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ storage_account_type = "Standard_LRS"
+ create_option = "Empty"
+ disk_size_gb = "1"
+
+ tags {
+ environment = "acctest"
+ cost-center = "ops"
+ }
+}
+
+resource "azurerm_managed_disk" "test" {
+ name = "acctestd2-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ storage_account_type = "Standard_LRS"
+ create_option = "Copy"
+ source_resource_id = "${azurerm_managed_disk.source.id}"
+ disk_size_gb = "1"
+
+ tags {
+ environment = "acctest"
+ cost-center = "ops"
+ }
+}`
+
+var testAccAzureRMManagedDisk_empty_updated = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_managed_disk" "test" {
+ name = "acctestd-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ storage_account_type = "Premium_LRS"
+ create_option = "Empty"
+ disk_size_gb = "2"
+
+ tags {
+ environment = "acctest"
+ }
+}`
diff --git a/builtin/providers/azurerm/resource_arm_storage_account.go b/builtin/providers/azurerm/resource_arm_storage_account.go
index d47b089f4..721ab8097 100644
--- a/builtin/providers/azurerm/resource_arm_storage_account.go
+++ b/builtin/providers/azurerm/resource_arm_storage_account.go
@@ -1,7 +1,6 @@
package azurerm
import (
- "context"
"fmt"
"log"
"net/http"
@@ -188,10 +187,8 @@ func resourceArmStorageAccountCreate(d *schema.ResourceData, meta interface{}) e
}
// Create
- cancelCtx, cancelFunc := context.WithTimeout(client.StopContext, 1*time.Hour)
_, createErr := storageClient.Create(
- resourceGroupName, storageAccountName, opts, cancelCtx.Done())
- cancelFunc()
+ resourceGroupName, storageAccountName, opts, make(chan struct{}))
// The only way to get the ID back apparently is to read the resource again
read, err := storageClient.GetProperties(resourceGroupName, storageAccountName)
diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine.go b/builtin/providers/azurerm/resource_arm_virtual_machine.go
index 9a1607472..e3fe29808 100644
--- a/builtin/providers/azurerm/resource_arm_virtual_machine.go
+++ b/builtin/providers/azurerm/resource_arm_virtual_machine.go
@@ -11,6 +11,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
+ "github.com/hashicorp/terraform/helper/validation"
riviera "github.com/jen20/riviera/azure"
)
@@ -141,10 +142,29 @@ func resourceArmVirtualMachine() *schema.Resource {
"vhd_uri": {
Type: schema.TypeString,
- Required: true,
+ Optional: true,
ForceNew: true,
},
+ "managed_disk_id": {
+ Type: schema.TypeString,
+ Optional: true,
+ ForceNew: true,
+ Computed: true,
+ ConflictsWith: []string{"storage_os_disk.vhd_uri"},
+ },
+
+ "managed_disk_type": {
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ConflictsWith: []string{"storage_os_disk.vhd_uri"},
+ ValidateFunc: validation.StringInSlice([]string{
+ string(compute.PremiumLRS),
+ string(compute.StandardLRS),
+ }, true),
+ },
+
"image_uri": {
Type: schema.TypeString,
Optional: true,
@@ -189,7 +209,26 @@ func resourceArmVirtualMachine() *schema.Resource {
"vhd_uri": {
Type: schema.TypeString,
- Required: true,
+ Optional: true,
+ },
+
+ "managed_disk_id": {
+ Type: schema.TypeString,
+ Optional: true,
+ ForceNew: true,
+ Computed: true,
+ ConflictsWith: []string{"storage_data_disk.vhd_uri"},
+ },
+
+ "managed_disk_type": {
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ConflictsWith: []string{"storage_data_disk.vhd_uri"},
+ ValidateFunc: validation.StringInSlice([]string{
+ string(compute.PremiumLRS),
+ string(compute.StandardLRS),
+ }, true),
},
"create_option": {
@@ -204,9 +243,10 @@ func resourceArmVirtualMachine() *schema.Resource {
},
"disk_size_gb": {
- Type: schema.TypeInt,
- Optional: true,
- Computed: true,
+ Type: schema.TypeInt,
+ Optional: true,
+ Computed: true,
+ ValidateFunc: validateDiskSizeGB,
},
"lun": {
@@ -453,15 +493,6 @@ func validateLicenseType(v interface{}, k string) (ws []string, errors []error)
return
}
-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 {
client := meta.(*ArmClient)
vmClient := client.vmClient
@@ -685,21 +716,29 @@ func resourceArmVirtualMachineDelete(d *schema.ResourceData, meta interface{}) e
// delete OS Disk if opted in
if deleteOsDisk := d.Get("delete_os_disk_on_termination").(bool); deleteOsDisk {
- log.Printf("[INFO] delete_os_disk_on_termination is enabled, deleting")
+ log.Printf("[INFO] delete_os_disk_on_termination is enabled, deleting disk from %s", name)
osDisk, err := expandAzureRmVirtualMachineOsDisk(d)
if err != nil {
return fmt.Errorf("Error expanding OS Disk: %s", err)
}
- if err = resourceArmVirtualMachineDeleteVhd(*osDisk.Vhd.URI, meta); err != nil {
- return fmt.Errorf("Error deleting OS Disk VHD: %s", err)
+ if osDisk.Vhd != nil {
+ if err = resourceArmVirtualMachineDeleteVhd(*osDisk.Vhd.URI, meta); err != nil {
+ return fmt.Errorf("Error deleting OS Disk VHD: %s", err)
+ }
+ } else if osDisk.ManagedDisk != nil {
+ if err = resourceArmVirtualMachineDeleteManagedDisk(*osDisk.ManagedDisk.ID, meta); err != nil {
+ return fmt.Errorf("Error deleting OS Managed Disk: %s", err)
+ }
+ } else {
+ return fmt.Errorf("Unable to locate OS managed disk properties from %s", name)
}
}
// delete Data disks if opted in
if deleteDataDisks := d.Get("delete_data_disks_on_termination").(bool); deleteDataDisks {
- log.Printf("[INFO] delete_data_disks_on_termination is enabled, deleting each data disk")
+ log.Printf("[INFO] delete_data_disks_on_termination is enabled, deleting each data disk from %s", name)
disks, err := expandAzureRmVirtualMachineDataDisk(d)
if err != nil {
@@ -707,8 +746,16 @@ func resourceArmVirtualMachineDelete(d *schema.ResourceData, meta interface{}) e
}
for _, disk := range disks {
- if err = resourceArmVirtualMachineDeleteVhd(*disk.Vhd.URI, meta); err != nil {
- return fmt.Errorf("Error deleting Data Disk VHD: %s", err)
+ if disk.Vhd != nil {
+ if err = resourceArmVirtualMachineDeleteVhd(*disk.Vhd.URI, meta); err != nil {
+ return fmt.Errorf("Error deleting Data Disk VHD: %s", err)
+ }
+ } else if disk.ManagedDisk != nil {
+ if err = resourceArmVirtualMachineDeleteManagedDisk(*disk.ManagedDisk.ID, meta); err != nil {
+ return fmt.Errorf("Error deleting Data Managed Disk: %s", err)
+ }
+ } else {
+ return fmt.Errorf("Unable to locate data managed disk properties from %s", name)
}
}
}
@@ -752,6 +799,24 @@ func resourceArmVirtualMachineDeleteVhd(uri string, meta interface{}) error {
return nil
}
+func resourceArmVirtualMachineDeleteManagedDisk(managedDiskID string, meta interface{}) error {
+ diskClient := meta.(*ArmClient).diskClient
+
+ id, err := parseAzureResourceID(managedDiskID)
+ if err != nil {
+ return err
+ }
+ resGroup := id.ResourceGroup
+ name := id.Path["disks"]
+
+ _, err = diskClient.Delete(resGroup, name, make(chan struct{}))
+ if err != nil {
+ return fmt.Errorf("Error deleting Managed Disk (%s %s) %s", name, resGroup, err)
+ }
+
+ return nil
+}
+
func resourceArmVirtualMachinePlanHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
@@ -784,8 +849,9 @@ func resourceArmVirtualMachineStorageOsDiskHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["name"].(string)))
- buf.WriteString(fmt.Sprintf("%s-", m["vhd_uri"].(string)))
-
+ if m["vhd_uri"] != nil {
+ buf.WriteString(fmt.Sprintf("%s-", m["vhd_uri"].(string)))
+ }
return hashcode.String(buf.String())
}
@@ -883,7 +949,13 @@ func flattenAzureRmVirtualMachineDataDisk(disks *[]compute.DataDisk) interface{}
for i, disk := range *disks {
l := make(map[string]interface{})
l["name"] = *disk.Name
- l["vhd_uri"] = *disk.Vhd.URI
+ if disk.Vhd != nil {
+ l["vhd_uri"] = *disk.Vhd.URI
+ }
+ if disk.ManagedDisk != nil {
+ l["managed_disk_type"] = string(disk.ManagedDisk.StorageAccountType)
+ l["managed_disk_id"] = *disk.ManagedDisk.ID
+ }
l["create_option"] = disk.CreateOption
l["caching"] = string(disk.Caching)
if disk.DiskSizeGB != nil {
@@ -982,7 +1054,13 @@ func flattenAzureRmVirtualMachineOsProfileLinuxConfiguration(config *compute.Lin
func flattenAzureRmVirtualMachineOsDisk(disk *compute.OSDisk) []interface{} {
result := make(map[string]interface{})
result["name"] = *disk.Name
- result["vhd_uri"] = *disk.Vhd.URI
+ if disk.Vhd != nil {
+ result["vhd_uri"] = *disk.Vhd.URI
+ }
+ if disk.ManagedDisk != nil {
+ result["managed_disk_type"] = string(disk.ManagedDisk.StorageAccountType)
+ result["managed_disk_id"] = *disk.ManagedDisk.ID
+ }
result["create_option"] = disk.CreateOption
result["caching"] = disk.Caching
if disk.DiskSizeGB != nil {
@@ -1157,22 +1235,22 @@ func expandAzureRmVirtualMachineOsProfileWindowsConfig(d *schema.ResourceData) (
if v := osProfileConfig["winrm"]; v != nil {
winRm := v.([]interface{})
if len(winRm) > 0 {
- winRmListners := make([]compute.WinRMListener, 0, len(winRm))
+ winRmListeners := make([]compute.WinRMListener, 0, len(winRm))
for _, winRmConfig := range winRm {
config := winRmConfig.(map[string]interface{})
protocol := config["protocol"].(string)
- winRmListner := compute.WinRMListener{
+ winRmListener := compute.WinRMListener{
Protocol: compute.ProtocolTypes(protocol),
}
if v := config["certificate_url"].(string); v != "" {
- winRmListner.CertificateURL = &v
+ winRmListener.CertificateURL = &v
}
- winRmListners = append(winRmListners, winRmListner)
+ winRmListeners = append(winRmListeners, winRmListener)
}
config.WinRM = &compute.WinRMConfiguration{
- Listeners: &winRmListners,
+ Listeners: &winRmListeners,
}
}
}
@@ -1209,19 +1287,48 @@ func expandAzureRmVirtualMachineDataDisk(d *schema.ResourceData) ([]compute.Data
config := disk_config.(map[string]interface{})
name := config["name"].(string)
- vhd := config["vhd_uri"].(string)
createOption := config["create_option"].(string)
+ vhdURI := config["vhd_uri"].(string)
+ managedDiskType := config["managed_disk_type"].(string)
+ managedDiskID := config["managed_disk_id"].(string)
lun := int32(config["lun"].(int))
data_disk := compute.DataDisk{
- Name: &name,
- Vhd: &compute.VirtualHardDisk{
- URI: &vhd,
- },
+ Name: &name,
Lun: &lun,
CreateOption: compute.DiskCreateOptionTypes(createOption),
}
+ if vhdURI != "" {
+ data_disk.Vhd = &compute.VirtualHardDisk{
+ URI: &vhdURI,
+ }
+ }
+
+ managedDisk := &compute.ManagedDiskParameters{}
+
+ if managedDiskType != "" {
+ managedDisk.StorageAccountType = compute.StorageAccountTypes(managedDiskType)
+ data_disk.ManagedDisk = managedDisk
+ }
+
+ if managedDiskID != "" {
+ managedDisk.ID = &managedDiskID
+ data_disk.ManagedDisk = managedDisk
+ }
+
+ //BEGIN: code to be removed after GH-13016 is merged
+ if vhdURI != "" && managedDiskID != "" {
+ return nil, fmt.Errorf("[ERROR] Conflict between `vhd_uri` and `managed_disk_id` (only one or the other can be used)")
+ }
+ if vhdURI != "" && managedDiskType != "" {
+ return nil, fmt.Errorf("[ERROR] Conflict between `vhd_uri` and `managed_disk_type` (only one or the other can be used)")
+ }
+ //END: code to be removed after GH-13016 is merged
+ if managedDiskID == "" && strings.EqualFold(string(data_disk.CreateOption), string(compute.Attach)) {
+ return nil, fmt.Errorf("[ERROR] Must specify which disk to attach")
+ }
+
if v := config["caching"].(string); v != "" {
data_disk.Caching = compute.CachingTypes(v)
}
@@ -1303,28 +1410,57 @@ func expandAzureRmVirtualMachineNetworkProfile(d *schema.ResourceData) compute.N
func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk, error) {
disks := d.Get("storage_os_disk").(*schema.Set).List()
- disk := disks[0].(map[string]interface{})
+ config := disks[0].(map[string]interface{})
- name := disk["name"].(string)
- vhdURI := disk["vhd_uri"].(string)
- imageURI := disk["image_uri"].(string)
- createOption := disk["create_option"].(string)
+ name := config["name"].(string)
+ imageURI := config["image_uri"].(string)
+ createOption := config["create_option"].(string)
+ vhdURI := config["vhd_uri"].(string)
+ managedDiskType := config["managed_disk_type"].(string)
+ managedDiskID := config["managed_disk_id"].(string)
osDisk := &compute.OSDisk{
- Name: &name,
- Vhd: &compute.VirtualHardDisk{
- URI: &vhdURI,
- },
+ Name: &name,
CreateOption: compute.DiskCreateOptionTypes(createOption),
}
- if v := disk["image_uri"].(string); v != "" {
+ if vhdURI != "" {
+ osDisk.Vhd = &compute.VirtualHardDisk{
+ URI: &vhdURI,
+ }
+ }
+
+ managedDisk := &compute.ManagedDiskParameters{}
+
+ if managedDiskType != "" {
+ managedDisk.StorageAccountType = compute.StorageAccountTypes(managedDiskType)
+ osDisk.ManagedDisk = managedDisk
+ }
+
+ if managedDiskID != "" {
+ managedDisk.ID = &managedDiskID
+ osDisk.ManagedDisk = managedDisk
+ }
+
+ //BEGIN: code to be removed after GH-13016 is merged
+ if vhdURI != "" && managedDiskID != "" {
+ return nil, fmt.Errorf("[ERROR] Conflict between `vhd_uri` and `managed_disk_id` (only one or the other can be used)")
+ }
+ if vhdURI != "" && managedDiskType != "" {
+ return nil, fmt.Errorf("[ERROR] Conflict between `vhd_uri` and `managed_disk_type` (only one or the other can be used)")
+ }
+ //END: code to be removed after GH-13016 is merged
+ if managedDiskID == "" && strings.EqualFold(string(osDisk.CreateOption), string(compute.Attach)) {
+ return nil, fmt.Errorf("[ERROR] Must specify which disk to attach")
+ }
+
+ if v := config["image_uri"].(string); v != "" {
osDisk.Image = &compute.VirtualHardDisk{
URI: &imageURI,
}
}
- if v := disk["os_type"].(string); v != "" {
+ if v := config["os_type"].(string); v != "" {
if v == "linux" {
osDisk.OsType = compute.Linux
} else if v == "windows" {
@@ -1334,11 +1470,11 @@ func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk,
}
}
- if v := disk["caching"].(string); v != "" {
+ if v := config["caching"].(string); v != "" {
osDisk.Caching = compute.CachingTypes(v)
}
- if v := disk["disk_size_gb"].(int); v != 0 {
+ if v := config["disk_size_gb"].(int); v != 0 {
diskSize := int32(v)
osDisk.DiskSizeGB = &diskSize
}
diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine_test.go b/builtin/providers/azurerm/resource_arm_virtual_machine_test.go
index b3a42728a..71552b8cf 100644
--- a/builtin/providers/azurerm/resource_arm_virtual_machine_test.go
+++ b/builtin/providers/azurerm/resource_arm_virtual_machine_test.go
@@ -7,9 +7,11 @@ import (
"testing"
"github.com/Azure/azure-sdk-for-go/arm/compute"
+ "github.com/Azure/azure-sdk-for-go/arm/disk"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
+ "regexp"
)
func TestAccAzureRMVirtualMachine_basicLinuxMachine(t *testing.T) {
@@ -31,6 +33,63 @@ func TestAccAzureRMVirtualMachine_basicLinuxMachine(t *testing.T) {
})
}
+func TestAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_explicit(t *testing.T) {
+ var vm compute.VirtualMachine
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_explicit, ri, ri, ri, ri, ri, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
+ ),
+ },
+ },
+ })
+}
+
+func TestAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_implicit(t *testing.T) {
+ var vm compute.VirtualMachine
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_implicit, ri, ri, ri, ri, ri, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
+ ),
+ },
+ },
+ })
+}
+
+func TestAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_attach(t *testing.T) {
+ var vm compute.VirtualMachine
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_attach, ri, ri, ri, ri, ri, ri, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
+ ),
+ },
+ },
+ })
+}
+
func TestAccAzureRMVirtualMachine_basicLinuxMachine_disappears(t *testing.T) {
var vm compute.VirtualMachine
ri := acctest.RandInt()
@@ -44,7 +103,7 @@ func TestAccAzureRMVirtualMachine_basicLinuxMachine_disappears(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
- testCheckAzureRMVirtualMachineDisappears("azurerm_virtual_machine.test", &vm),
+ testCheckAzureRMVirtualMachineDisappears("azurerm_virtual_machine.test"),
),
ExpectNonEmptyPlan: true,
},
@@ -72,6 +131,46 @@ func TestAccAzureRMVirtualMachine_withDataDisk(t *testing.T) {
})
}
+func TestAccAzureRMVirtualMachine_withDataDisk_managedDisk_explicit(t *testing.T) {
+ var vm compute.VirtualMachine
+
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMVirtualMachine_withDataDisk_managedDisk_explicit, ri, ri, ri, ri, ri, ri, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
+ ),
+ },
+ },
+ })
+}
+
+func TestAccAzureRMVirtualMachine_withDataDisk_managedDisk_implicit(t *testing.T) {
+ var vm compute.VirtualMachine
+
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMVirtualMachine_withDataDisk_managedDisk_implicit, ri, ri, ri, ri, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
+ ),
+ },
+ },
+ })
+}
+
func TestAccAzureRMVirtualMachine_tags(t *testing.T) {
var vm compute.VirtualMachine
@@ -128,7 +227,7 @@ func TestAccAzureRMVirtualMachine_updateMachineSize(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
resource.TestCheckResourceAttr(
- "azurerm_virtual_machine.test", "vm_size", "Standard_A0"),
+ "azurerm_virtual_machine.test", "vm_size", "Standard_D1_v2"),
),
},
{
@@ -136,7 +235,7 @@ func TestAccAzureRMVirtualMachine_updateMachineSize(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
resource.TestCheckResourceAttr(
- "azurerm_virtual_machine.test", "vm_size", "Standard_A1"),
+ "azurerm_virtual_machine.test", "vm_size", "Standard_D2_v2"),
),
},
},
@@ -238,8 +337,40 @@ func TestAccAzureRMVirtualMachine_deleteVHDOptOut(t *testing.T) {
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
- testCheckAzureRMVirtualMachineVHDExistance("myosdisk1.vhd", true),
- testCheckAzureRMVirtualMachineVHDExistance("mydatadisk1.vhd", true),
+ testCheckAzureRMVirtualMachineVHDExistence("myosdisk1.vhd", true),
+ testCheckAzureRMVirtualMachineVHDExistence("mydatadisk1.vhd", true),
+ ),
+ },
+ },
+ })
+}
+
+func TestAccAzureRMVirtualMachine_deleteManagedDiskOptOut(t *testing.T) {
+ var vm compute.VirtualMachine
+ var osd string
+ var dtd string
+ ri := acctest.RandInt()
+ preConfig := fmt.Sprintf(testAccAzureRMVirtualMachine_withDataDisk_managedDisk_implicit, ri, ri, ri, ri, ri, ri)
+ postConfig := fmt.Sprintf(testAccAzureRMVirtualMachine_basicLinuxMachineDeleteVM_managedDisk, ri, ri, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
+ Steps: []resource.TestStep{
+ {
+ Destroy: false,
+ Config: preConfig,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
+ testLookupAzureRMVirtualMachineManagedDiskID(&vm, "myosdisk1", &osd),
+ testLookupAzureRMVirtualMachineManagedDiskID(&vm, "mydatadisk1", &dtd),
+ ),
+ },
+ {
+ Config: postConfig,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMVirtualMachineManagedDiskExists(&osd, true),
+ testCheckAzureRMVirtualMachineManagedDiskExists(&dtd, true),
),
},
},
@@ -265,8 +396,40 @@ func TestAccAzureRMVirtualMachine_deleteVHDOptIn(t *testing.T) {
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
- testCheckAzureRMVirtualMachineVHDExistance("myosdisk1.vhd", false),
- testCheckAzureRMVirtualMachineVHDExistance("mydatadisk1.vhd", false),
+ testCheckAzureRMVirtualMachineVHDExistence("myosdisk1.vhd", false),
+ testCheckAzureRMVirtualMachineVHDExistence("mydatadisk1.vhd", false),
+ ),
+ },
+ },
+ })
+}
+
+func TestAccAzureRMVirtualMachine_deleteManagedDiskOptIn(t *testing.T) {
+ var vm compute.VirtualMachine
+ var osd string
+ var dtd string
+ ri := acctest.RandInt()
+ preConfig := fmt.Sprintf(testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_DestroyDisksBefore, ri, ri, ri, ri, ri, ri)
+ postConfig := fmt.Sprintf(testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_DestroyDisksAfter, ri, ri, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
+ Steps: []resource.TestStep{
+ {
+ Destroy: false,
+ Config: preConfig,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
+ testLookupAzureRMVirtualMachineManagedDiskID(&vm, "myosdisk1", &osd),
+ testLookupAzureRMVirtualMachineManagedDiskID(&vm, "mydatadisk1", &dtd),
+ ),
+ },
+ {
+ Config: postConfig,
+ Check: resource.ComposeTestCheckFunc(
+ testCheckAzureRMVirtualMachineManagedDiskExists(&osd, false),
+ testCheckAzureRMVirtualMachineManagedDiskExists(&dtd, false),
),
},
},
@@ -284,14 +447,14 @@ func TestAccAzureRMVirtualMachine_ChangeComputerName(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &afterCreate),
),
},
- resource.TestStep{
+ {
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &afterUpdate),
@@ -303,7 +466,7 @@ func TestAccAzureRMVirtualMachine_ChangeComputerName(t *testing.T) {
})
}
-func TestAccAzureRMVirtualMachine_ChangeAvailbilitySet(t *testing.T) {
+func TestAccAzureRMVirtualMachine_ChangeAvailabilitySet(t *testing.T) {
var afterCreate, afterUpdate compute.VirtualMachine
ri := acctest.RandInt()
@@ -314,14 +477,14 @@ func TestAccAzureRMVirtualMachine_ChangeAvailbilitySet(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &afterCreate),
),
},
- resource.TestStep{
+ {
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &afterUpdate),
@@ -344,14 +507,14 @@ func TestAccAzureRMVirtualMachine_changeStorageImageReference(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &afterCreate),
),
},
- resource.TestStep{
+ {
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &afterUpdate),
@@ -374,14 +537,14 @@ func TestAccAzureRMVirtualMachine_changeOSDiskVhdUri(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &afterCreate),
),
},
- resource.TestStep{
+ {
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &afterUpdate),
@@ -438,6 +601,42 @@ func TestAccAzureRMVirtualMachine_changeSSHKey(t *testing.T) {
})
}
+func TestAccAzureRMVirtualMachine_osDiskTypeConflict(t *testing.T) {
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMVirtualMachine_osDiskTypeConflict, ri, ri, ri, ri, ri, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ ExpectError: regexp.MustCompile("Conflict between `vhd_uri`"),
+ //Use below code instead once GH-13019 has been merged
+ //ExpectError: regexp.MustCompile("conflicts with storage_os_disk.0.vhd_uri"),
+ },
+ },
+ })
+}
+
+func TestAccAzureRMVirtualMachine_dataDiskTypeConflict(t *testing.T) {
+ ri := acctest.RandInt()
+ config := fmt.Sprintf(testAccAzureRMVirtualMachine_dataDiskTypeConflict, ri, ri, ri, ri, ri, ri, ri)
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
+ Steps: []resource.TestStep{
+ {
+ Config: config,
+ ExpectError: regexp.MustCompile("Conflict between `vhd_uri`"),
+ //Use below code instead once GH-13019 has been merged
+ //ExpectError: regexp.MustCompile("conflicts with storage_data_disk.1.vhd_uri"),
+ },
+ },
+ })
+}
+
func testCheckAzureRMVirtualMachineExists(name string, vm *compute.VirtualMachine) resource.TestCheckFunc {
return func(s *terraform.State) error {
// Ensure we have enough information in state to look up in API
@@ -469,6 +668,23 @@ func testCheckAzureRMVirtualMachineExists(name string, vm *compute.VirtualMachin
}
}
+func testCheckAzureRMVirtualMachineManagedDiskExists(managedDiskID *string, shouldExist bool) resource.TestCheckFunc {
+ return func(s *terraform.State) error {
+ d, err := testGetAzureRMVirtualMachineManagedDisk(managedDiskID)
+ if err != nil {
+ return fmt.Errorf("Error trying to retrieve Managed Disk %s, %s", *managedDiskID, err)
+ }
+ if d.StatusCode == http.StatusNotFound && shouldExist {
+ return fmt.Errorf("Unable to find Managed Disk %s", *managedDiskID)
+ }
+ if d.StatusCode != http.StatusNotFound && !shouldExist {
+ return fmt.Errorf("Found unexpected Managed Disk %s", *managedDiskID)
+ }
+
+ return nil
+ }
+}
+
func testAccCheckVirtualMachineRecreated(t *testing.T,
before, after *compute.VirtualMachine) resource.TestCheckFunc {
return func(s *terraform.State) error {
@@ -504,7 +720,7 @@ func testCheckAzureRMVirtualMachineDestroy(s *terraform.State) error {
return nil
}
-func testCheckAzureRMVirtualMachineVHDExistance(name string, shouldExist bool) resource.TestCheckFunc {
+func testCheckAzureRMVirtualMachineVHDExistence(name string, shouldExist bool) resource.TestCheckFunc {
return func(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
if rs.Type != "azurerm_storage_container" {
@@ -526,9 +742,9 @@ func testCheckAzureRMVirtualMachineVHDExistance(name string, shouldExist bool) r
}
if exists && !shouldExist {
- return fmt.Errorf("Disk VHD Blob still exists")
+ return fmt.Errorf("Disk VHD Blob still exists %s %s", containerName, name)
} else if !exists && shouldExist {
- return fmt.Errorf("Disk VHD Blob should exist")
+ return fmt.Errorf("Disk VHD Blob should exist %s %s", containerName, name)
}
}
@@ -536,7 +752,7 @@ func testCheckAzureRMVirtualMachineVHDExistance(name string, shouldExist bool) r
}
}
-func testCheckAzureRMVirtualMachineDisappears(name string, vm *compute.VirtualMachine) resource.TestCheckFunc {
+func testCheckAzureRMVirtualMachineDisappears(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]
@@ -599,16 +815,76 @@ func TestAccAzureRMVirtualMachine_primaryNetworkInterfaceId(t *testing.T) {
})
}
+func testLookupAzureRMVirtualMachineManagedDiskID(vm *compute.VirtualMachine, diskName string, managedDiskID *string) resource.TestCheckFunc {
+ return func(s *terraform.State) error {
+ if osd := vm.StorageProfile.OsDisk; osd != nil {
+ if strings.EqualFold(*osd.Name, diskName) {
+ if osd.ManagedDisk != nil {
+ id, err := findAzureRMVirtualMachineManagedDiskID(osd.ManagedDisk)
+ if err != nil {
+ return fmt.Errorf("Unable to parse Managed Disk ID for OS Disk %s, %s", diskName, err)
+ }
+ *managedDiskID = id
+ return nil
+ }
+ }
+ }
+
+ for _, dataDisk := range *vm.StorageProfile.DataDisks {
+ if strings.EqualFold(*dataDisk.Name, diskName) {
+ if dataDisk.ManagedDisk != nil {
+ id, err := findAzureRMVirtualMachineManagedDiskID(dataDisk.ManagedDisk)
+ if err != nil {
+ return fmt.Errorf("Unable to parse Managed Disk ID for Data Disk %s, %s", diskName, err)
+ }
+ *managedDiskID = id
+ return nil
+ }
+ }
+ }
+
+ return fmt.Errorf("Unable to locate disk %s on vm %s", diskName, *vm.Name)
+ }
+}
+
+func findAzureRMVirtualMachineManagedDiskID(md *compute.ManagedDiskParameters) (string, error) {
+ _, err := parseAzureResourceID(*md.ID)
+ if err != nil {
+ return "", err
+ }
+ return *md.ID, nil
+}
+
+func testGetAzureRMVirtualMachineManagedDisk(managedDiskID *string) (*disk.Model, error) {
+ armID, err := parseAzureResourceID(*managedDiskID)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to parse Managed Disk ID %s, %s", *managedDiskID, err)
+ }
+ name := armID.Path["disks"]
+ resourceGroup := armID.ResourceGroup
+ conn := testAccProvider.Meta().(*ArmClient).diskClient
+ d, err := conn.Get(resourceGroup, name)
+ //check status first since sdk client returns error if not 200
+ if d.Response.StatusCode == http.StatusNotFound {
+ return &d, nil
+ }
+ if err != nil {
+ return nil, err
+ }
+
+ return &d, nil
+}
+
var testAccAzureRMVirtualMachine_basicLinuxMachine = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -621,7 +897,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -634,7 +910,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -651,10 +927,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "Canonical"
@@ -672,7 +948,236 @@ resource "azurerm_virtual_machine" "test" {
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
+ admin_username = "testadmin"
+ admin_password = "Password1234!"
+ }
+
+ os_profile_linux_config {
+ disable_password_authentication = false
+ }
+
+ tags {
+ environment = "Production"
+ cost-center = "Ops"
+ }
+}
+`
+
+var testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_explicit = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn-%d"
+ address_space = ["10.0.0.0/16"]
+ location = "West US 2"
+ 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 2"
+ 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_virtual_machine" "test" {
+ name = "acctvm-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ network_interface_ids = ["${azurerm_network_interface.test.id}"]
+ vm_size = "Standard_D1_v2"
+
+ storage_image_reference {
+ publisher = "Canonical"
+ offer = "UbuntuServer"
+ sku = "14.04.2-LTS"
+ version = "latest"
+ }
+
+ storage_os_disk {
+ name = "osd-%d"
+ caching = "ReadWrite"
+ create_option = "FromImage"
+ disk_size_gb = "10"
+ managed_disk_type = "Standard_LRS"
+ }
+
+ os_profile {
+ computer_name = "hn%d"
+ admin_username = "testadmin"
+ admin_password = "Password1234!"
+ }
+
+ os_profile_linux_config {
+ disable_password_authentication = false
+ }
+
+ tags {
+ environment = "Production"
+ cost-center = "Ops"
+ }
+}
+`
+
+var testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_implicit = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn-%d"
+ address_space = ["10.0.0.0/16"]
+ location = "West US 2"
+ 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 2"
+ 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_virtual_machine" "test" {
+ name = "acctvm-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ network_interface_ids = ["${azurerm_network_interface.test.id}"]
+ vm_size = "Standard_D1_v2"
+
+ storage_image_reference {
+ publisher = "Canonical"
+ offer = "UbuntuServer"
+ sku = "14.04.2-LTS"
+ version = "latest"
+ }
+
+ storage_os_disk {
+ name = "osd-%d"
+ caching = "ReadWrite"
+ create_option = "FromImage"
+ disk_size_gb = "10"
+ }
+
+ os_profile {
+ computer_name = "hn%d"
+ admin_username = "testadmin"
+ admin_password = "Password1234!"
+ }
+
+ os_profile_linux_config {
+ disable_password_authentication = false
+ }
+
+ tags {
+ environment = "Production"
+ cost-center = "Ops"
+ }
+}
+`
+
+var testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_attach = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn-%d"
+ address_space = ["10.0.0.0/16"]
+ location = "West US 2"
+ 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 2"
+ 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_managed_disk" "test" {
+ name = "acctmd-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ storage_account_type = "Standard_LRS"
+ create_option = "Empty"
+ disk_size_gb = "1"
+}
+
+resource "azurerm_virtual_machine" "test" {
+ name = "acctvm-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ network_interface_ids = ["${azurerm_network_interface.test.id}"]
+ vm_size = "Standard_D1_v2"
+
+ storage_image_reference {
+ publisher = "Canonical"
+ offer = "UbuntuServer"
+ sku = "14.04.2-LTS"
+ version = "latest"
+ }
+
+ storage_os_disk {
+ name = "osd-%d"
+ caching = "ReadWrite"
+ create_option = "FromImage"
+ disk_size_gb = "10"
+ managed_disk_type = "Standard_LRS"
+ }
+
+ storage_data_disk {
+ name = "${azurerm_managed_disk.test.name}"
+ create_option = "Attach"
+ disk_size_gb = "1"
+ lun = 0
+ managed_disk_id = "${azurerm_managed_disk.test.id}"
+ }
+
+ os_profile {
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -691,13 +1196,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_machineNameBeforeUpdate = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -710,7 +1215,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -723,7 +1228,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -740,10 +1245,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
delete_os_disk_on_termination = true
storage_image_reference {
@@ -761,7 +1266,7 @@ resource "azurerm_virtual_machine" "test" {
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -780,18 +1285,18 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_basicLinuxMachineDestroyDisksBefore = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_resource_group" "test-sa" {
name = "acctestRG-sa-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -804,7 +1309,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -817,7 +1322,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test-sa.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -834,10 +1339,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "Canonical"
@@ -858,7 +1363,7 @@ resource "azurerm_virtual_machine" "test" {
storage_data_disk {
name = "mydatadisk1"
vhd_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/mydatadisk1.vhd"
- disk_size_gb = "1023"
+ disk_size_gb = "1"
create_option = "Empty"
lun = 0
}
@@ -866,7 +1371,87 @@ resource "azurerm_virtual_machine" "test" {
delete_data_disks_on_termination = true
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
+ admin_username = "testadmin"
+ admin_password = "Password1234!"
+ }
+
+ os_profile_linux_config {
+ disable_password_authentication = false
+ }
+
+ tags {
+ environment = "Production"
+ cost-center = "Ops"
+ }
+}
+`
+
+var testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_DestroyDisksBefore = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn-%d"
+ address_space = ["10.0.0.0/16"]
+ location = "West US 2"
+ 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 2"
+ 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_virtual_machine" "test" {
+ name = "acctvm-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ network_interface_ids = ["${azurerm_network_interface.test.id}"]
+ vm_size = "Standard_D1_v2"
+
+ storage_image_reference {
+ publisher = "Canonical"
+ offer = "UbuntuServer"
+ sku = "14.04.2-LTS"
+ version = "latest"
+ }
+
+ storage_os_disk {
+ name = "myosdisk1"
+ caching = "ReadWrite"
+ create_option = "FromImage"
+ }
+
+ delete_os_disk_on_termination = true
+
+ storage_data_disk {
+ name = "mydatadisk1"
+ disk_size_gb = "1"
+ create_option = "Empty"
+ lun = 0
+ }
+
+ delete_data_disks_on_termination = true
+
+ os_profile {
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -885,18 +1470,18 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_basicLinuxMachineDestroyDisksAfter = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_resource_group" "test-sa" {
name = "acctestRG-sa-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -909,7 +1494,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -922,7 +1507,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test-sa.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -938,16 +1523,49 @@ resource "azurerm_storage_container" "test" {
}
`
+var testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_DestroyDisksAfter = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn-%d"
+ address_space = ["10.0.0.0/16"]
+ location = "West US 2"
+ 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 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+
+ ip_configuration {
+ name = "testconfiguration1"
+ subnet_id = "${azurerm_subnet.test.id}"
+ private_ip_address_allocation = "dynamic"
+ }
+}
+`
+
var testAccAzureRMVirtualMachine_basicLinuxMachineDeleteVM = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -960,7 +1578,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -973,7 +1591,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -989,16 +1607,16 @@ resource "azurerm_storage_container" "test" {
}
`
-var testAccAzureRMVirtualMachine_withDataDisk = `
+var testAccAzureRMVirtualMachine_basicLinuxMachineDeleteVM_managedDisk = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1011,7 +1629,40 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+
+ ip_configuration {
+ name = "testconfiguration1"
+ subnet_id = "${azurerm_subnet.test.id}"
+ private_ip_address_allocation = "dynamic"
+ }
+}
+`
+
+var testAccAzureRMVirtualMachine_withDataDisk = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn-%d"
+ address_space = ["10.0.0.0/16"]
+ location = "West US 2"
+ 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 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1024,7 +1675,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1041,10 +1692,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "Canonical"
@@ -1063,14 +1714,170 @@ resource "azurerm_virtual_machine" "test" {
storage_data_disk {
name = "mydatadisk1"
vhd_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/mydatadisk1.vhd"
- disk_size_gb = "1023"
+ disk_size_gb = "1"
create_option = "Empty"
caching = "ReadWrite"
lun = 0
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
+ admin_username = "testadmin"
+ admin_password = "Password1234!"
+ }
+
+ os_profile_linux_config {
+ disable_password_authentication = false
+ }
+
+ tags {
+ environment = "Production"
+ cost-center = "Ops"
+ }
+}
+`
+
+var testAccAzureRMVirtualMachine_withDataDisk_managedDisk_explicit = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn-%d"
+ address_space = ["10.0.0.0/16"]
+ location = "West US 2"
+ 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 2"
+ 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_virtual_machine" "test" {
+ name = "acctvm-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ network_interface_ids = ["${azurerm_network_interface.test.id}"]
+ vm_size = "Standard_D1_v2"
+
+ storage_image_reference {
+ publisher = "Canonical"
+ offer = "UbuntuServer"
+ sku = "14.04.2-LTS"
+ version = "latest"
+ }
+
+ storage_os_disk {
+ name = "osd-%d"
+ caching = "ReadWrite"
+ create_option = "FromImage"
+ managed_disk_type = "Standard_LRS"
+ }
+
+ storage_data_disk {
+ name = "dtd-%d"
+ disk_size_gb = "1"
+ create_option = "Empty"
+ caching = "ReadWrite"
+ lun = 0
+ managed_disk_type = "Standard_LRS"
+ }
+
+ os_profile {
+ computer_name = "hn%d"
+ admin_username = "testadmin"
+ admin_password = "Password1234!"
+ }
+
+ os_profile_linux_config {
+ disable_password_authentication = false
+ }
+
+ tags {
+ environment = "Production"
+ cost-center = "Ops"
+ }
+}
+`
+
+var testAccAzureRMVirtualMachine_withDataDisk_managedDisk_implicit = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn-%d"
+ address_space = ["10.0.0.0/16"]
+ location = "West US 2"
+ 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 2"
+ 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_virtual_machine" "test" {
+ name = "acctvm-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ network_interface_ids = ["${azurerm_network_interface.test.id}"]
+ vm_size = "Standard_D1_v2"
+
+ storage_image_reference {
+ publisher = "Canonical"
+ offer = "UbuntuServer"
+ sku = "14.04.2-LTS"
+ version = "latest"
+ }
+
+ storage_os_disk {
+ name = "myosdisk1"
+ caching = "ReadWrite"
+ create_option = "FromImage"
+ }
+
+ storage_data_disk {
+ name = "mydatadisk1"
+ disk_size_gb = "1"
+ create_option = "Empty"
+ caching = "ReadWrite"
+ lun = 0
+ }
+
+ os_profile {
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -1089,13 +1896,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_basicLinuxMachineUpdated = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1108,7 +1915,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1121,7 +1928,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1138,10 +1945,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "Canonical"
@@ -1158,7 +1965,7 @@ resource "azurerm_virtual_machine" "test" {
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -1176,13 +1983,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_updatedLinuxMachine = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1195,7 +2002,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1208,7 +2015,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1225,10 +2032,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A1"
+ vm_size = "Standard_D2_v2"
storage_image_reference {
publisher = "Canonical"
@@ -1245,7 +2052,7 @@ resource "azurerm_virtual_machine" "test" {
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -1259,13 +2066,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_basicWindowsMachine = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1278,7 +2085,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1291,7 +2098,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1308,10 +2115,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "MicrosoftWindowsServer"
@@ -1343,13 +2150,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_windowsUnattendedConfig = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1362,7 +2169,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1375,7 +2182,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1392,10 +2199,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "MicrosoftWindowsServer"
@@ -1433,13 +2240,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_diagnosticsProfile = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1452,7 +2259,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1465,7 +2272,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1482,10 +2289,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "MicrosoftWindowsServer"
@@ -1524,13 +2331,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_winRMConfig = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1543,7 +2350,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1556,7 +2363,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1573,10 +2380,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "MicrosoftWindowsServer"
@@ -1609,13 +2416,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_withAvailabilitySet = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1628,7 +2435,7 @@ var testAccAzureRMVirtualMachine_withAvailabilitySet = `
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1641,7 +2448,7 @@ var testAccAzureRMVirtualMachine_withAvailabilitySet = `
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1651,7 +2458,7 @@ var testAccAzureRMVirtualMachine_withAvailabilitySet = `
resource "azurerm_availability_set" "test" {
name = "availabilityset%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1664,10 +2471,10 @@ var testAccAzureRMVirtualMachine_withAvailabilitySet = `
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
availability_set_id = "${azurerm_availability_set.test.id}"
delete_os_disk_on_termination = true
@@ -1686,7 +2493,7 @@ var testAccAzureRMVirtualMachine_withAvailabilitySet = `
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -1700,13 +2507,13 @@ var testAccAzureRMVirtualMachine_withAvailabilitySet = `
var testAccAzureRMVirtualMachine_updateAvailabilitySet = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1719,7 +2526,7 @@ var testAccAzureRMVirtualMachine_updateAvailabilitySet = `
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1732,7 +2539,7 @@ var testAccAzureRMVirtualMachine_updateAvailabilitySet = `
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1742,7 +2549,7 @@ var testAccAzureRMVirtualMachine_updateAvailabilitySet = `
resource "azurerm_availability_set" "test" {
name = "updatedAvailabilitySet%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1755,10 +2562,10 @@ var testAccAzureRMVirtualMachine_updateAvailabilitySet = `
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
availability_set_id = "${azurerm_availability_set.test.id}"
delete_os_disk_on_termination = true
@@ -1777,7 +2584,7 @@ var testAccAzureRMVirtualMachine_updateAvailabilitySet = `
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -1791,13 +2598,13 @@ var testAccAzureRMVirtualMachine_updateAvailabilitySet = `
var testAccAzureRMVirtualMachine_updateMachineName = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1810,7 +2617,7 @@ var testAccAzureRMVirtualMachine_updateMachineName = `
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1823,7 +2630,7 @@ var testAccAzureRMVirtualMachine_updateMachineName = `
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1840,10 +2647,10 @@ var testAccAzureRMVirtualMachine_updateMachineName = `
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
delete_os_disk_on_termination = true
storage_image_reference {
@@ -1875,13 +2682,13 @@ var testAccAzureRMVirtualMachine_updateMachineName = `
var testAccAzureRMVirtualMachine_basicLinuxMachineStorageImageBefore = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1894,7 +2701,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1907,7 +2714,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -1924,10 +2731,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
delete_os_disk_on_termination = true
storage_image_reference {
@@ -1946,7 +2753,7 @@ resource "azurerm_virtual_machine" "test" {
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -1965,13 +2772,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_basicLinuxMachineStorageImageAfter = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -1984,7 +2791,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -1997,7 +2804,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -2014,10 +2821,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
delete_os_disk_on_termination = true
storage_image_reference {
@@ -2036,7 +2843,7 @@ resource "azurerm_virtual_machine" "test" {
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -2055,13 +2862,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_basicLinuxMachineWithOSDiskVhdUriChanged = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -2074,7 +2881,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -2087,7 +2894,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -2104,10 +2911,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "Canonical"
@@ -2125,7 +2932,7 @@ resource "azurerm_virtual_machine" "test" {
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -2144,13 +2951,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_windowsLicenseType = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -2163,7 +2970,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -2176,7 +2983,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -2193,10 +3000,10 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
license_type = "Windows_Server"
storage_image_reference {
@@ -2229,13 +3036,13 @@ resource "azurerm_virtual_machine" "test" {
var testAccAzureRMVirtualMachine_plan = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
- location = "West US"
+ location = "West US 2"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
}
@@ -2248,7 +3055,7 @@ resource "azurerm_subnet" "test" {
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
@@ -2261,7 +3068,7 @@ resource "azurerm_network_interface" "test" {
resource "azurerm_storage_account" "test" {
name = "accsa%d"
resource_group_name = "${azurerm_resource_group.test.name}"
- location = "westus"
+ location = "West US 2"
account_type = "Standard_LRS"
tags {
@@ -2278,7 +3085,7 @@ resource "azurerm_storage_container" "test" {
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
- location = "West US"
+ location = "West US 2"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
vm_size = "Standard_DS1_v2"
@@ -2299,7 +3106,7 @@ resource "azurerm_virtual_machine" "test" {
}
os_profile {
- computer_name = "hostname%d"
+ computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
@@ -2372,7 +3179,7 @@ resource "azurerm_virtual_machine" "test" {
location = "southcentralus"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "Canonical"
@@ -2456,7 +3263,7 @@ resource "azurerm_virtual_machine" "test" {
location = "southcentralus"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
- vm_size = "Standard_A0"
+ vm_size = "Standard_D1_v2"
storage_image_reference {
publisher = "Canonical"
@@ -2484,6 +3291,176 @@ resource "azurerm_virtual_machine" "test" {
}
}
`
+var testAccAzureRMVirtualMachine_osDiskTypeConflict = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn-%d"
+ address_space = ["10.0.0.0/16"]
+ location = "West US 2"
+ 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 2"
+ 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_virtual_machine" "test" {
+ name = "acctvm-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ network_interface_ids = ["${azurerm_network_interface.test.id}"]
+ vm_size = "Standard_D1_v2"
+
+ storage_image_reference {
+ publisher = "Canonical"
+ offer = "UbuntuServer"
+ sku = "14.04.2-LTS"
+ version = "latest"
+ }
+
+ storage_os_disk {
+ name = "osd-%d"
+ caching = "ReadWrite"
+ create_option = "FromImage"
+ disk_size_gb = "10"
+ managed_disk_type = "Standard_LRS"
+ vhd_uri = "should_cause_conflict"
+ }
+
+ storage_data_disk {
+ name = "mydatadisk1"
+ caching = "ReadWrite"
+ create_option = "Empty"
+ disk_size_gb = "45"
+ managed_disk_type = "Standard_LRS"
+ lun = "0"
+ }
+
+ os_profile {
+ computer_name = "hn%d"
+ admin_username = "testadmin"
+ admin_password = "Password1234!"
+ }
+
+ os_profile_linux_config {
+ disable_password_authentication = false
+ }
+
+ tags {
+ environment = "Production"
+ cost-center = "Ops"
+ }
+}
+`
+
+var testAccAzureRMVirtualMachine_dataDiskTypeConflict = `
+resource "azurerm_resource_group" "test" {
+ name = "acctestRG-%d"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn-%d"
+ address_space = ["10.0.0.0/16"]
+ location = "West US 2"
+ 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 2"
+ 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_virtual_machine" "test" {
+ name = "acctvm-%d"
+ location = "West US 2"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ network_interface_ids = ["${azurerm_network_interface.test.id}"]
+ vm_size = "Standard_D1_v2"
+
+ storage_image_reference {
+ publisher = "Canonical"
+ offer = "UbuntuServer"
+ sku = "14.04.2-LTS"
+ version = "latest"
+ }
+
+ storage_os_disk {
+ name = "osd-%d"
+ caching = "ReadWrite"
+ create_option = "FromImage"
+ disk_size_gb = "10"
+ managed_disk_type = "Standard_LRS"
+ }
+
+ storage_data_disk {
+ name = "mydatadisk1"
+ caching = "ReadWrite"
+ create_option = "Empty"
+ disk_size_gb = "45"
+ managed_disk_type = "Standard_LRS"
+ lun = "0"
+ }
+
+ storage_data_disk {
+ name = "mydatadisk1"
+ vhd_uri = "should_cause_conflict"
+ caching = "ReadWrite"
+ create_option = "Empty"
+ disk_size_gb = "45"
+ managed_disk_type = "Standard_LRS"
+ lun = "1"
+ }
+
+ os_profile {
+ computer_name = "hn%d"
+ admin_username = "testadmin"
+ admin_password = "Password1234!"
+ }
+
+ os_profile_linux_config {
+ disable_password_authentication = false
+ }
+
+ tags {
+ environment = "Production"
+ cost-center = "Ops"
+ }
+}
+`
var testAccAzureRMVirtualMachine_primaryNetworkInterfaceId = `
resource "azurerm_resource_group" "test" {
diff --git a/builtin/providers/bitbucket/client.go b/builtin/providers/bitbucket/client.go
index 02b9ed0db..bd2cebcce 100644
--- a/builtin/providers/bitbucket/client.go
+++ b/builtin/providers/bitbucket/client.go
@@ -2,64 +2,107 @@ package bitbucket
import (
"bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "log"
"net/http"
)
+// Error represents a error from the bitbucket api.
+type Error struct {
+ APIError struct {
+ Message string `json:"message,omitempty"`
+ } `json:"error,omitempty"`
+ Type string `json:"type,omitempty"`
+ StatusCode int
+ Endpoint string
+}
+
+func (e Error) Error() string {
+ return fmt.Sprintf("API Error: %d %s %s", e.StatusCode, e.Endpoint, e.APIError.Message)
+}
+
+const (
+ // BitbucketEndpoint is the fqdn used to talk to bitbucket
+ BitbucketEndpoint string = "https://api.bitbucket.org/"
+)
+
type BitbucketClient struct {
- Username string
- Password string
+ Username string
+ Password string
+ HTTPClient *http.Client
+}
+
+func (c *BitbucketClient) Do(method, endpoint string, payload *bytes.Buffer) (*http.Response, error) {
+
+ absoluteendpoint := BitbucketEndpoint + endpoint
+ log.Printf("[DEBUG] Sending request to %s %s", method, absoluteendpoint)
+
+ var bodyreader io.Reader
+
+ if payload != nil {
+ log.Printf("[DEBUG] With payload %s", payload.String())
+ bodyreader = payload
+ }
+
+ req, err := http.NewRequest(method, absoluteendpoint, bodyreader)
+ if err != nil {
+ return nil, err
+ }
+
+ req.SetBasicAuth(c.Username, c.Password)
+
+ if payload != nil {
+ // Can cause bad request when putting default reviews if set.
+ req.Header.Add("Content-Type", "application/json")
+ }
+
+ req.Close = true
+
+ resp, err := c.HTTPClient.Do(req)
+ log.Printf("[DEBUG] Resp: %v Err: %v", resp, err)
+ if resp.StatusCode >= 400 || resp.StatusCode < 200 {
+ apiError := Error{
+ StatusCode: resp.StatusCode,
+ Endpoint: endpoint,
+ }
+
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return nil, err
+ }
+
+ log.Printf("[DEBUG] Resp Body: %s", string(body))
+
+ err = json.Unmarshal(body, &apiError)
+ if err != nil {
+ apiError.APIError.Message = string(body)
+ }
+
+ return resp, error(apiError)
+
+ }
+ return resp, err
}
func (c *BitbucketClient) Get(endpoint string) (*http.Response, error) {
- client := &http.Client{}
- req, err := http.NewRequest("GET", "https://api.bitbucket.org/"+endpoint, nil)
- if err != nil {
- return nil, err
- }
-
- req.SetBasicAuth(c.Username, c.Password)
- return client.Do(req)
-
+ return c.Do("GET", endpoint, nil)
}
func (c *BitbucketClient) Post(endpoint string, jsonpayload *bytes.Buffer) (*http.Response, error) {
- client := &http.Client{}
- req, err := http.NewRequest("POST", "https://api.bitbucket.org/"+endpoint, jsonpayload)
- if err != nil {
- return nil, err
- }
- req.SetBasicAuth(c.Username, c.Password)
- req.Header.Add("content-type", "application/json")
- return client.Do(req)
+ return c.Do("POST", endpoint, jsonpayload)
}
func (c *BitbucketClient) Put(endpoint string, jsonpayload *bytes.Buffer) (*http.Response, error) {
- client := &http.Client{}
- req, err := http.NewRequest("PUT", "https://api.bitbucket.org/"+endpoint, jsonpayload)
- if err != nil {
- return nil, err
- }
- req.SetBasicAuth(c.Username, c.Password)
- req.Header.Add("content-type", "application/json")
- return client.Do(req)
+ return c.Do("PUT", endpoint, jsonpayload)
}
func (c *BitbucketClient) PutOnly(endpoint string) (*http.Response, error) {
- client := &http.Client{}
- req, err := http.NewRequest("PUT", "https://api.bitbucket.org/"+endpoint, nil)
- if err != nil {
- return nil, err
- }
- req.SetBasicAuth(c.Username, c.Password)
- return client.Do(req)
+ return c.Do("PUT", endpoint, nil)
}
func (c *BitbucketClient) Delete(endpoint string) (*http.Response, error) {
- client := &http.Client{}
- req, err := http.NewRequest("DELETE", "https://api.bitbucket.org/"+endpoint, nil)
- if err != nil {
- return nil, err
- }
- req.SetBasicAuth(c.Username, c.Password)
- return client.Do(req)
+ return c.Do("DELETE", endpoint, nil)
}
diff --git a/builtin/providers/bitbucket/provider.go b/builtin/providers/bitbucket/provider.go
index afeb71249..e50f9295f 100644
--- a/builtin/providers/bitbucket/provider.go
+++ b/builtin/providers/bitbucket/provider.go
@@ -1,6 +1,8 @@
package bitbucket
import (
+ "net/http"
+
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
@@ -30,8 +32,9 @@ func Provider() terraform.ResourceProvider {
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
client := &BitbucketClient{
- Username: d.Get("username").(string),
- Password: d.Get("password").(string),
+ Username: d.Get("username").(string),
+ Password: d.Get("password").(string),
+ HTTPClient: &http.Client{},
}
return client, nil
diff --git a/builtin/providers/bitbucket/resource_default_reviewers.go b/builtin/providers/bitbucket/resource_default_reviewers.go
index 37a0f5883..9fc5d1e0a 100644
--- a/builtin/providers/bitbucket/resource_default_reviewers.go
+++ b/builtin/providers/bitbucket/resource_default_reviewers.go
@@ -3,6 +3,7 @@ package bitbucket
import (
"encoding/json"
"fmt"
+
"github.com/hashicorp/terraform/helper/schema"
)
@@ -49,7 +50,7 @@ func resourceDefaultReviewersCreate(d *schema.ResourceData, m interface{}) error
client := m.(*BitbucketClient)
for _, user := range d.Get("reviewers").(*schema.Set).List() {
- reviewer_resp, err := client.PutOnly(fmt.Sprintf("2.0/repositories/%s/%s/default-reviewers/%s",
+ reviewerResp, err := client.PutOnly(fmt.Sprintf("2.0/repositories/%s/%s/default-reviewers/%s",
d.Get("owner").(string),
d.Get("repository").(string),
user,
@@ -59,11 +60,11 @@ func resourceDefaultReviewersCreate(d *schema.ResourceData, m interface{}) error
return err
}
- if reviewer_resp.StatusCode != 200 {
- return fmt.Errorf("Failed to create reviewer %s got code %d", user.(string), reviewer_resp.StatusCode)
+ if reviewerResp.StatusCode != 200 {
+ return fmt.Errorf("Failed to create reviewer %s got code %d", user.(string), reviewerResp.StatusCode)
}
- defer reviewer_resp.Body.Close()
+ defer reviewerResp.Body.Close()
}
d.SetId(fmt.Sprintf("%s/%s/reviewers", d.Get("owner").(string), d.Get("repository").(string)))
@@ -72,26 +73,26 @@ func resourceDefaultReviewersCreate(d *schema.ResourceData, m interface{}) error
func resourceDefaultReviewersRead(d *schema.ResourceData, m interface{}) error {
client := m.(*BitbucketClient)
- reviewers_response, err := client.Get(fmt.Sprintf("2.0/repositories/%s/%s/default-reviewers",
+ reviewersResponse, err := client.Get(fmt.Sprintf("2.0/repositories/%s/%s/default-reviewers",
d.Get("owner").(string),
d.Get("repository").(string),
))
var reviewers PaginatedReviewers
- decoder := json.NewDecoder(reviewers_response.Body)
+ decoder := json.NewDecoder(reviewersResponse.Body)
err = decoder.Decode(&reviewers)
if err != nil {
return err
}
- terraform_reviewers := make([]string, 0, len(reviewers.Values))
+ terraformReviewers := make([]string, 0, len(reviewers.Values))
for _, reviewer := range reviewers.Values {
- terraform_reviewers = append(terraform_reviewers, reviewer.Username)
+ terraformReviewers = append(terraformReviewers, reviewer.Username)
}
- d.Set("reviewers", terraform_reviewers)
+ d.Set("reviewers", terraformReviewers)
return nil
}
diff --git a/builtin/providers/bitbucket/resource_hook.go b/builtin/providers/bitbucket/resource_hook.go
index c93862798..745292ad1 100644
--- a/builtin/providers/bitbucket/resource_hook.go
+++ b/builtin/providers/bitbucket/resource_hook.go
@@ -4,6 +4,10 @@ import (
"bytes"
"encoding/json"
"fmt"
+ "io/ioutil"
+ "log"
+ "net/url"
+
"github.com/hashicorp/terraform/helper/schema"
)
@@ -81,86 +85,89 @@ func resourceHookCreate(d *schema.ResourceData, m interface{}) error {
client := m.(*BitbucketClient)
hook := createHook(d)
- var jsonbuffer []byte
-
- jsonpayload := bytes.NewBuffer(jsonbuffer)
- enc := json.NewEncoder(jsonpayload)
- enc.Encode(hook)
-
- hook_req, err := client.Post(fmt.Sprintf("2.0/repositories/%s/%s/hooks",
- d.Get("owner").(string),
- d.Get("repository").(string),
- ), jsonpayload)
-
- decoder := json.NewDecoder(hook_req.Body)
- err = decoder.Decode(&hook)
+ payload, err := json.Marshal(hook)
if err != nil {
return err
}
+ hook_req, err := client.Post(fmt.Sprintf("2.0/repositories/%s/%s/hooks",
+ d.Get("owner").(string),
+ d.Get("repository").(string),
+ ), bytes.NewBuffer(payload))
+
+ if err != nil {
+ return err
+ }
+
+ body, readerr := ioutil.ReadAll(hook_req.Body)
+ if readerr != nil {
+ return readerr
+ }
+
+ decodeerr := json.Unmarshal(body, &hook)
+ if decodeerr != nil {
+ return decodeerr
+ }
+
d.SetId(hook.Uuid)
- d.Set("uuid", hook.Uuid)
return resourceHookRead(d, m)
}
func resourceHookRead(d *schema.ResourceData, m interface{}) error {
client := m.(*BitbucketClient)
- hook_req, err := client.Get(fmt.Sprintf("2.0/repositories/%s/%s/hooks/%s",
+
+ hook_req, _ := client.Get(fmt.Sprintf("2.0/repositories/%s/%s/hooks/%s",
d.Get("owner").(string),
d.Get("repository").(string),
- d.Get("uuid").(string),
+ url.PathEscape(d.Id()),
))
- if err != nil {
- return err
+ log.Printf("ID: %s", url.PathEscape(d.Id()))
+
+ if hook_req.StatusCode == 200 {
+ var hook Hook
+
+ body, readerr := ioutil.ReadAll(hook_req.Body)
+ if readerr != nil {
+ return readerr
+ }
+
+ decodeerr := json.Unmarshal(body, &hook)
+ if decodeerr != nil {
+ return decodeerr
+ }
+
+ d.Set("uuid", hook.Uuid)
+ d.Set("description", hook.Description)
+ d.Set("active", hook.Active)
+ d.Set("url", hook.Url)
+
+ eventsList := make([]string, 0, len(hook.Events))
+
+ for _, event := range hook.Events {
+ eventsList = append(eventsList, event)
+ }
+
+ d.Set("events", eventsList)
}
- var hook Hook
-
- decoder := json.NewDecoder(hook_req.Body)
- err = decoder.Decode(&hook)
- if err != nil {
- return err
- }
-
- d.Set("uuid", hook.Uuid)
- d.Set("description", hook.Description)
- d.Set("active", hook.Active)
- d.Set("url", hook.Url)
-
- eventsList := make([]string, 0, len(hook.Events))
-
- for _, event := range hook.Events {
- eventsList = append(eventsList, event)
- }
-
- d.Set("events", eventsList)
-
return nil
}
func resourceHookUpdate(d *schema.ResourceData, m interface{}) error {
client := m.(*BitbucketClient)
hook := createHook(d)
-
- var jsonbuffer []byte
-
- jsonpayload := bytes.NewBuffer(jsonbuffer)
- enc := json.NewEncoder(jsonpayload)
- enc.Encode(hook)
-
- hook_req, err := client.Put(fmt.Sprintf("2.0/repositories/%s/%s/hooks/%s",
- d.Get("owner").(string),
- d.Get("repository").(string),
- d.Get("uuid").(string),
- ), jsonpayload)
-
+ payload, err := json.Marshal(hook)
if err != nil {
return err
}
- decoder := json.NewDecoder(hook_req.Body)
- err = decoder.Decode(&hook)
+ _, err = client.Put(fmt.Sprintf("2.0/repositories/%s/%s/hooks/%s",
+ d.Get("owner").(string),
+ d.Get("repository").(string),
+ url.PathEscape(d.Id()),
+ ), bytes.NewBuffer(payload))
+
if err != nil {
return err
}
@@ -174,7 +181,7 @@ func resourceHookExists(d *schema.ResourceData, m interface{}) (bool, error) {
hook_req, err := client.Get(fmt.Sprintf("2.0/repositories/%s/%s/hooks/%s",
d.Get("owner").(string),
d.Get("repository").(string),
- d.Get("uuid").(string),
+ url.PathEscape(d.Id()),
))
if err != nil {
@@ -182,15 +189,14 @@ func resourceHookExists(d *schema.ResourceData, m interface{}) (bool, error) {
}
if hook_req.StatusCode != 200 {
- d.SetId("")
- return false, nil
+ return false, err
}
return true, nil
- } else {
- return false, nil
}
+ return false, nil
+
}
func resourceHookDelete(d *schema.ResourceData, m interface{}) error {
@@ -198,11 +204,9 @@ func resourceHookDelete(d *schema.ResourceData, m interface{}) error {
_, err := client.Delete(fmt.Sprintf("2.0/repositories/%s/%s/hooks/%s",
d.Get("owner").(string),
d.Get("repository").(string),
- d.Get("uuid").(string),
+ url.PathEscape(d.Id()),
))
- if err != nil {
- return err
- }
- return nil
+ return err
+
}
diff --git a/builtin/providers/bitbucket/resource_hook_test.go b/builtin/providers/bitbucket/resource_hook_test.go
index 178ebf27b..59a719b87 100644
--- a/builtin/providers/bitbucket/resource_hook_test.go
+++ b/builtin/providers/bitbucket/resource_hook_test.go
@@ -2,6 +2,7 @@ package bitbucket
import (
"fmt"
+ "net/url"
"os"
"testing"
@@ -16,7 +17,7 @@ func TestAccBitbucketHook_basic(t *testing.T) {
testAccBitbucketHookConfig := fmt.Sprintf(`
resource "bitbucket_repository" "test_repo" {
owner = "%s"
- name = "test-repo"
+ name = "test-repo-for-webhook-test"
}
resource "bitbucket_hook" "test_repo_hook" {
owner = "%s"
@@ -51,10 +52,10 @@ func testAccCheckBitbucketHookDestroy(s *terraform.State) error {
return fmt.Errorf("Not found %s", "bitbucket_hook.test_repo_hook")
}
- response, err := client.Get(fmt.Sprintf("2.0/repositories/%s/%s/hooks/%s", rs.Primary.Attributes["owner"], rs.Primary.Attributes["repository"], rs.Primary.Attributes["uuid"]))
+ response, err := client.Get(fmt.Sprintf("2.0/repositories/%s/%s/hooks/%s", rs.Primary.Attributes["owner"], rs.Primary.Attributes["repository"], url.PathEscape(rs.Primary.Attributes["uuid"])))
- if err != nil {
- return err
+ if err == nil {
+ return fmt.Errorf("The resource was found should have errored")
}
if response.StatusCode != 404 {
diff --git a/builtin/providers/bitbucket/resource_repository.go b/builtin/providers/bitbucket/resource_repository.go
index 050ddd9b2..f57db3ea8 100644
--- a/builtin/providers/bitbucket/resource_repository.go
+++ b/builtin/providers/bitbucket/resource_repository.go
@@ -4,8 +4,9 @@ import (
"bytes"
"encoding/json"
"fmt"
+ "io/ioutil"
+
"github.com/hashicorp/terraform/helper/schema"
- "log"
)
type CloneUrl struct {
@@ -131,7 +132,7 @@ func resourceRepositoryUpdate(d *schema.ResourceData, m interface{}) error {
enc := json.NewEncoder(jsonpayload)
enc.Encode(repository)
- repository_response, err := client.Put(fmt.Sprintf("2.0/repositories/%s/%s",
+ _, err := client.Put(fmt.Sprintf("2.0/repositories/%s/%s",
d.Get("owner").(string),
d.Get("name").(string),
), jsonpayload)
@@ -140,16 +141,6 @@ func resourceRepositoryUpdate(d *schema.ResourceData, m interface{}) error {
return err
}
- if repository_response.StatusCode == 200 {
- decoder := json.NewDecoder(repository_response.Body)
- err = decoder.Decode(&repository)
- if err != nil {
- return err
- }
- } else {
- return fmt.Errorf("Failed to put: %d", repository_response.StatusCode)
- }
-
return resourceRepositoryRead(d, m)
}
@@ -157,29 +148,19 @@ func resourceRepositoryCreate(d *schema.ResourceData, m interface{}) error {
client := m.(*BitbucketClient)
repo := newRepositoryFromResource(d)
- var jsonbuffer []byte
+ bytedata, err := json.Marshal(repo)
- jsonpayload := bytes.NewBuffer(jsonbuffer)
- enc := json.NewEncoder(jsonpayload)
- enc.Encode(repo)
-
- log.Printf("Sending %s \n", jsonpayload)
-
- repo_req, err := client.Post(fmt.Sprintf("2.0/repositories/%s/%s",
- d.Get("owner").(string),
- d.Get("name").(string),
- ), jsonpayload)
-
- decoder := json.NewDecoder(repo_req.Body)
- err = decoder.Decode(&repo)
if err != nil {
return err
}
- log.Printf("Received %s \n", repo_req.Body)
+ _, err = client.Post(fmt.Sprintf("2.0/repositories/%s/%s",
+ d.Get("owner").(string),
+ d.Get("name").(string),
+ ), bytes.NewBuffer(bytedata))
- if repo_req.StatusCode != 200 {
- return fmt.Errorf("Failed to create repository got status code %d", repo_req.StatusCode)
+ if err != nil {
+ return err
}
d.SetId(string(fmt.Sprintf("%s/%s", d.Get("owner").(string), d.Get("name").(string))))
@@ -189,39 +170,42 @@ func resourceRepositoryCreate(d *schema.ResourceData, m interface{}) error {
func resourceRepositoryRead(d *schema.ResourceData, m interface{}) error {
client := m.(*BitbucketClient)
- repo_req, err := client.Get(fmt.Sprintf("2.0/repositories/%s/%s",
+ repo_req, _ := client.Get(fmt.Sprintf("2.0/repositories/%s/%s",
d.Get("owner").(string),
d.Get("name").(string),
))
- if err != nil {
- return err
- }
+ if repo_req.StatusCode == 200 {
- var repo Repository
+ var repo Repository
- decoder := json.NewDecoder(repo_req.Body)
- err = decoder.Decode(&repo)
- if err != nil {
- return err
- }
+ body, readerr := ioutil.ReadAll(repo_req.Body)
+ if readerr != nil {
+ return readerr
+ }
- d.Set("scm", repo.SCM)
- d.Set("is_private", repo.IsPrivate)
- d.Set("has_wiki", repo.HasWiki)
- d.Set("has_issues", repo.HasIssues)
- d.Set("name", repo.Name)
- d.Set("language", repo.Language)
- d.Set("fork_policy", repo.ForkPolicy)
- d.Set("website", repo.Website)
- d.Set("description", repo.Description)
- d.Set("project_key", repo.Project.Key)
+ decodeerr := json.Unmarshal(body, &repo)
+ if decodeerr != nil {
+ return decodeerr
+ }
- for _, clone_url := range repo.Links.Clone {
- if clone_url.Name == "https" {
- d.Set("clone_https", clone_url.Href)
- } else {
- d.Set("clone_ssh", clone_url.Href)
+ d.Set("scm", repo.SCM)
+ d.Set("is_private", repo.IsPrivate)
+ d.Set("has_wiki", repo.HasWiki)
+ d.Set("has_issues", repo.HasIssues)
+ d.Set("name", repo.Name)
+ d.Set("language", repo.Language)
+ d.Set("fork_policy", repo.ForkPolicy)
+ d.Set("website", repo.Website)
+ d.Set("description", repo.Description)
+ d.Set("project_key", repo.Project.Key)
+
+ for _, clone_url := range repo.Links.Clone {
+ if clone_url.Name == "https" {
+ d.Set("clone_https", clone_url.Href)
+ } else {
+ d.Set("clone_ssh", clone_url.Href)
+ }
}
}
@@ -230,18 +214,10 @@ func resourceRepositoryRead(d *schema.ResourceData, m interface{}) error {
func resourceRepositoryDelete(d *schema.ResourceData, m interface{}) error {
client := m.(*BitbucketClient)
- delete_response, err := client.Delete(fmt.Sprintf("2.0/repositories/%s/%s",
+ _, err := client.Delete(fmt.Sprintf("2.0/repositories/%s/%s",
d.Get("owner").(string),
d.Get("name").(string),
))
- if err != nil {
- return err
- }
-
- if delete_response.StatusCode != 204 {
- return fmt.Errorf("Failed to delete the repository got status code %d", delete_response.StatusCode)
- }
-
- return nil
+ return err
}
diff --git a/builtin/providers/bitbucket/resource_repository_test.go b/builtin/providers/bitbucket/resource_repository_test.go
index 47d4f4405..1fa47a71f 100644
--- a/builtin/providers/bitbucket/resource_repository_test.go
+++ b/builtin/providers/bitbucket/resource_repository_test.go
@@ -16,9 +16,9 @@ func TestAccBitbucketRepository_basic(t *testing.T) {
testAccBitbucketRepositoryConfig := fmt.Sprintf(`
resource "bitbucket_repository" "test_repo" {
owner = "%s"
- name = "%s"
+ name = "test-repo-for-repository-test"
}
- `, testUser, testRepo)
+ `, testUser)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@@ -42,11 +42,7 @@ func testAccCheckBitbucketRepositoryDestroy(s *terraform.State) error {
return fmt.Errorf("Not found %s", "bitbucket_repository.test_repo")
}
- response, err := client.Get(fmt.Sprintf("2.0/repositories/%s/%s", rs.Primary.Attributes["owner"], rs.Primary.Attributes["name"]))
-
- if err != nil {
- return err
- }
+ response, _ := client.Get(fmt.Sprintf("2.0/repositories/%s/%s", rs.Primary.Attributes["owner"], rs.Primary.Attributes["name"]))
if response.StatusCode != 404 {
return fmt.Errorf("Repository still exists")
diff --git a/helper/schema/schema.go b/helper/schema/schema.go
index f62c4d128..e3a7b1a44 100644
--- a/helper/schema/schema.go
+++ b/helper/schema/schema.go
@@ -62,10 +62,20 @@ type Schema struct {
DiffSuppressFunc SchemaDiffSuppressFunc
// If this is non-nil, then this will be a default value that is used
- // when this item is not set in the configuration/state.
+ // when this item is not set in the configuration.
//
- // DefaultFunc can be specified if you want a dynamic default value.
- // Only one of Default or DefaultFunc can be set.
+ // DefaultFunc can be specified to compute a dynamic default.
+ // Only one of Default or DefaultFunc can be set. If DefaultFunc is
+ // used then its return value should be stable to avoid generating
+ // confusing/perpetual diffs.
+ //
+ // Changing either Default or the return value of DefaultFunc can be
+ // a breaking change, especially if the attribute in question has
+ // ForceNew set. If a default needs to change to align with changing
+ // assumptions in an upstream API then it may be necessary to also use
+ // the MigrateState function on the resource to change the state to match,
+ // or have the Read function adjust the state value to align with the
+ // new default.
//
// If Required is true above, then Default cannot be set. DefaultFunc
// can be set with Required. If the DefaultFunc returns nil, then there
diff --git a/terraform/eval_validate.go b/terraform/eval_validate.go
index a2c122d6a..478aa6400 100644
--- a/terraform/eval_validate.go
+++ b/terraform/eval_validate.go
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/hashicorp/terraform/config"
+ "github.com/mitchellh/mapstructure"
)
// EvalValidateError is the error structure returned if there were
@@ -85,12 +86,31 @@ func (n *EvalValidateProvider) Eval(ctx EvalContext) (interface{}, error) {
type EvalValidateProvisioner struct {
Provisioner *ResourceProvisioner
Config **ResourceConfig
+ ConnConfig **ResourceConfig
}
func (n *EvalValidateProvisioner) Eval(ctx EvalContext) (interface{}, error) {
provisioner := *n.Provisioner
config := *n.Config
- warns, errs := provisioner.Validate(config)
+ var warns []string
+ var errs []error
+
+ {
+ // Validate the provisioner's own config first
+ w, e := provisioner.Validate(config)
+ warns = append(warns, w...)
+ errs = append(errs, e...)
+ }
+
+ {
+ // Now validate the connection config, which might either be from
+ // the provisioner block itself or inherited from the resource's
+ // shared connection info.
+ w, e := n.validateConnConfig(*n.ConnConfig)
+ warns = append(warns, w...)
+ errs = append(errs, e...)
+ }
+
if len(warns) == 0 && len(errs) == 0 {
return nil, nil
}
@@ -101,6 +121,64 @@ func (n *EvalValidateProvisioner) Eval(ctx EvalContext) (interface{}, error) {
}
}
+func (n *EvalValidateProvisioner) validateConnConfig(connConfig *ResourceConfig) (warns []string, errs []error) {
+ // We can't comprehensively validate the connection config since its
+ // final structure is decided by the communicator and we can't instantiate
+ // that until we have a complete instance state. However, we *can* catch
+ // configuration keys that are not valid for *any* communicator, catching
+ // typos early rather than waiting until we actually try to run one of
+ // the resource's provisioners.
+
+ type connConfigSuperset struct {
+ // All attribute types are interface{} here because at this point we
+ // may still have unresolved interpolation expressions, which will
+ // appear as strings regardless of the final goal type.
+
+ Type interface{} `mapstructure:"type"`
+ User interface{} `mapstructure:"user"`
+ Password interface{} `mapstructure:"password"`
+ Host interface{} `mapstructure:"host"`
+ Port interface{} `mapstructure:"port"`
+ Timeout interface{} `mapstructure:"timeout"`
+ ScriptPath interface{} `mapstructure:"script_path"`
+
+ // For type=ssh only (enforced in ssh communicator)
+ PrivateKey interface{} `mapstructure:"private_key"`
+ Agent interface{} `mapstructure:"agent"`
+ BastionHost interface{} `mapstructure:"bastion_host"`
+ BastionPort interface{} `mapstructure:"bastion_port"`
+ BastionUser interface{} `mapstructure:"bastion_user"`
+ BastionPassword interface{} `mapstructure:"bastion_password"`
+ BastionPrivateKey interface{} `mapstructure:"bastion_private_key"`
+
+ // For type=winrm only (enforced in winrm communicator)
+ HTTPS interface{} `mapstructure:"https"`
+ Insecure interface{} `mapstructure:"insecure"`
+ CACert interface{} `mapstructure:"cacert"`
+ }
+
+ var metadata mapstructure.Metadata
+ decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
+ Metadata: &metadata,
+ Result: &connConfigSuperset{}, // result is disregarded; we only care about unused keys
+ })
+ if err != nil {
+ // should never happen
+ errs = append(errs, err)
+ return
+ }
+
+ if err := decoder.Decode(connConfig.Config); err != nil {
+ errs = append(errs, err)
+ return
+ }
+
+ for _, attrName := range metadata.Unused {
+ errs = append(errs, fmt.Errorf("unknown 'connection' argument %q", attrName))
+ }
+ return
+}
+
// EvalValidateResource is an EvalNode implementation that validates
// the configuration of a resource.
type EvalValidateResource struct {
diff --git a/terraform/eval_validate_test.go b/terraform/eval_validate_test.go
index ac20f617c..0bde2a870 100644
--- a/terraform/eval_validate_test.go
+++ b/terraform/eval_validate_test.go
@@ -178,3 +178,117 @@ func TestEvalValidateResource_ignoreWarnings(t *testing.T) {
t.Fatalf("Expected no error, got: %s", err)
}
}
+
+func TestEvalValidateProvisioner_valid(t *testing.T) {
+ mp := &MockResourceProvisioner{}
+ var p ResourceProvisioner = mp
+ ctx := &MockEvalContext{}
+
+ cfg := &ResourceConfig{}
+ connInfo, err := config.NewRawConfig(map[string]interface{}{})
+ if err != nil {
+ t.Fatalf("failed to make connInfo: %s", err)
+ }
+ connConfig := NewResourceConfig(connInfo)
+
+ node := &EvalValidateProvisioner{
+ Provisioner: &p,
+ Config: &cfg,
+ ConnConfig: &connConfig,
+ }
+
+ result, err := node.Eval(ctx)
+ if err != nil {
+ t.Fatalf("node.Eval failed: %s", err)
+ }
+ if result != nil {
+ t.Errorf("node.Eval returned non-nil result")
+ }
+
+ if !mp.ValidateCalled {
+ t.Fatalf("p.Config not called")
+ }
+ if mp.ValidateConfig != cfg {
+ t.Errorf("p.Config called with wrong config")
+ }
+}
+
+func TestEvalValidateProvisioner_warning(t *testing.T) {
+ mp := &MockResourceProvisioner{}
+ var p ResourceProvisioner = mp
+ ctx := &MockEvalContext{}
+
+ cfg := &ResourceConfig{}
+ connInfo, err := config.NewRawConfig(map[string]interface{}{})
+ if err != nil {
+ t.Fatalf("failed to make connInfo: %s", err)
+ }
+ connConfig := NewResourceConfig(connInfo)
+
+ node := &EvalValidateProvisioner{
+ Provisioner: &p,
+ Config: &cfg,
+ ConnConfig: &connConfig,
+ }
+
+ mp.ValidateReturnWarns = []string{"foo is deprecated"}
+
+ _, err = node.Eval(ctx)
+ if err == nil {
+ t.Fatalf("node.Eval succeeded; want error")
+ }
+
+ valErr, ok := err.(*EvalValidateError)
+ if !ok {
+ t.Fatalf("node.Eval error is %#v; want *EvalValidateError", valErr)
+ }
+
+ warns := valErr.Warnings
+ if warns == nil || len(warns) != 1 {
+ t.Fatalf("wrong number of warnings in %#v; want one warning", warns)
+ }
+ if warns[0] != mp.ValidateReturnWarns[0] {
+ t.Fatalf("wrong warning %q; want %q", warns[0], mp.ValidateReturnWarns[0])
+ }
+}
+
+func TestEvalValidateProvisioner_connectionInvalid(t *testing.T) {
+ var p ResourceProvisioner = &MockResourceProvisioner{}
+ ctx := &MockEvalContext{}
+
+ cfg := &ResourceConfig{}
+ connInfo, err := config.NewRawConfig(map[string]interface{}{
+ "bananananananana": "foo",
+ "bazaz": "bar",
+ })
+ if err != nil {
+ t.Fatalf("failed to make connInfo: %s", err)
+ }
+ connConfig := NewResourceConfig(connInfo)
+
+ node := &EvalValidateProvisioner{
+ Provisioner: &p,
+ Config: &cfg,
+ ConnConfig: &connConfig,
+ }
+
+ _, err = node.Eval(ctx)
+ if err == nil {
+ t.Fatalf("node.Eval succeeded; want error")
+ }
+
+ valErr, ok := err.(*EvalValidateError)
+ if !ok {
+ t.Fatalf("node.Eval error is %#v; want *EvalValidateError", valErr)
+ }
+
+ errs := valErr.Errors
+ if errs == nil || len(errs) != 2 {
+ t.Fatalf("wrong number of errors in %#v; want two errors", errs)
+ }
+
+ errStr := errs[0].Error()
+ if !(strings.Contains(errStr, "bananananananana") || strings.Contains(errStr, "bazaz")) {
+ t.Fatalf("wrong first error %q; want something about our invalid connInfo keys", errStr)
+ }
+}
diff --git a/terraform/node_resource_validate.go b/terraform/node_resource_validate.go
index e01518de4..f528f24b1 100644
--- a/terraform/node_resource_validate.go
+++ b/terraform/node_resource_validate.go
@@ -129,17 +129,29 @@ func (n *NodeValidatableResourceInstance) EvalTree() EvalNode {
// Validate all the provisioners
for _, p := range n.Config.Provisioners {
var provisioner ResourceProvisioner
- seq.Nodes = append(seq.Nodes, &EvalGetProvisioner{
- Name: p.Type,
- Output: &provisioner,
- }, &EvalInterpolate{
- Config: p.RawConfig.Copy(),
- Resource: resource,
- Output: &config,
- }, &EvalValidateProvisioner{
- Provisioner: &provisioner,
- Config: &config,
- })
+ var connConfig *ResourceConfig
+ seq.Nodes = append(
+ seq.Nodes,
+ &EvalGetProvisioner{
+ Name: p.Type,
+ Output: &provisioner,
+ },
+ &EvalInterpolate{
+ Config: p.RawConfig.Copy(),
+ Resource: resource,
+ Output: &config,
+ },
+ &EvalInterpolate{
+ Config: p.ConnInfo.Copy(),
+ Resource: resource,
+ Output: &connConfig,
+ },
+ &EvalValidateProvisioner{
+ Provisioner: &provisioner,
+ Config: &config,
+ ConnConfig: &connConfig,
+ },
+ )
}
return seq
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/client.go
new file mode 100644
index 000000000..d64eb2287
--- /dev/null
+++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/client.go
@@ -0,0 +1,58 @@
+// Package disk implements the Azure ARM Disk service API version
+// 2016-04-30-preview.
+//
+// The Disk Resource Provider Client.
+package disk
+
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+import (
+ "github.com/Azure/go-autorest/autorest"
+)
+
+const (
+ // APIVersion is the version of the Disk
+ APIVersion = "2016-04-30-preview"
+
+ // DefaultBaseURI is the default URI used for the service Disk
+ DefaultBaseURI = "https://management.azure.com"
+)
+
+// ManagementClient is the base client for Disk.
+type ManagementClient struct {
+ autorest.Client
+ BaseURI string
+ APIVersion string
+ SubscriptionID string
+}
+
+// New creates an instance of the ManagementClient client.
+func New(subscriptionID string) ManagementClient {
+ return NewWithBaseURI(DefaultBaseURI, subscriptionID)
+}
+
+// NewWithBaseURI creates an instance of the ManagementClient client.
+func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
+ return ManagementClient{
+ Client: autorest.NewClientWithUserAgent(UserAgent()),
+ BaseURI: baseURI,
+ APIVersion: APIVersion,
+ SubscriptionID: subscriptionID,
+ }
+}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/disks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/disks.go
new file mode 100644
index 000000000..6fb03876f
--- /dev/null
+++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/disks.go
@@ -0,0 +1,638 @@
+package disk
+
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+import (
+ "github.com/Azure/go-autorest/autorest"
+ "github.com/Azure/go-autorest/autorest/azure"
+ "github.com/Azure/go-autorest/autorest/validation"
+ "net/http"
+)
+
+// DisksClient is the the Disk Resource Provider Client.
+type DisksClient struct {
+ ManagementClient
+}
+
+// NewDisksClient creates an instance of the DisksClient client.
+func NewDisksClient(subscriptionID string) DisksClient {
+ return NewDisksClientWithBaseURI(DefaultBaseURI, subscriptionID)
+}
+
+// NewDisksClientWithBaseURI creates an instance of the DisksClient client.
+func NewDisksClientWithBaseURI(baseURI string, subscriptionID string) DisksClient {
+ return DisksClient{NewWithBaseURI(baseURI, subscriptionID)}
+}
+
+// CreateOrUpdate creates or updates a disk. This method may poll for
+// completion. Polling can be canceled by passing the cancel channel argument.
+// The channel will be used to cancel polling and any outstanding HTTP
+// requests.
+//
+// resourceGroupName is the name of the resource group. diskName is the name of
+// the disk within the given subscription and resource group. diskParameter is
+// disk object supplied in the body of the Put disk operation.
+func (client DisksClient) CreateOrUpdate(resourceGroupName string, diskName string, diskParameter Model, cancel <-chan struct{}) (result autorest.Response, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: diskParameter,
+ Constraints: []validation.Constraint{{Target: "diskParameter.Properties", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "diskParameter.Properties.CreationData", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "diskParameter.Properties.CreationData.ImageReference", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "diskParameter.Properties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
+ }},
+ {Target: "diskParameter.Properties.EncryptionSettings", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "diskParameter.Properties.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "diskParameter.Properties.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "diskParameter.Properties.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ {Target: "diskParameter.Properties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "diskParameter.Properties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "diskParameter.Properties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ }},
+ }}}}}); err != nil {
+ return result, validation.NewErrorWithValidationError(err, "disk.DisksClient", "CreateOrUpdate")
+ }
+
+ req, err := client.CreateOrUpdatePreparer(resourceGroupName, diskName, diskParameter, cancel)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", nil, "Failure preparing request")
+ }
+
+ resp, err := client.CreateOrUpdateSender(req)
+ if err != nil {
+ result.Response = resp
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure sending request")
+ }
+
+ result, err = client.CreateOrUpdateResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
+func (client DisksClient) CreateOrUpdatePreparer(resourceGroupName string, diskName string, diskParameter Model, cancel <-chan struct{}) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsJSON(),
+ autorest.AsPut(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
+ autorest.WithJSON(diskParameter),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{Cancel: cancel})
+}
+
+// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client,
+ req,
+ azure.DoPollForAsynchronous(client.PollingDelay))
+}
+
+// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
+// closes the http.Response Body.
+func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Delete deletes a disk. This method may poll for completion. Polling can be
+// canceled by passing the cancel channel argument. The channel will be used to
+// cancel polling and any outstanding HTTP requests.
+//
+// resourceGroupName is the name of the resource group. diskName is the name of
+// the disk within the given subscription and resource group.
+func (client DisksClient) Delete(resourceGroupName string, diskName string, cancel <-chan struct{}) (result autorest.Response, err error) {
+ req, err := client.DeletePreparer(resourceGroupName, diskName, cancel)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", nil, "Failure preparing request")
+ }
+
+ resp, err := client.DeleteSender(req)
+ if err != nil {
+ result.Response = resp
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure sending request")
+ }
+
+ result, err = client.DeleteResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// DeletePreparer prepares the Delete request.
+func (client DisksClient) DeletePreparer(resourceGroupName string, diskName string, cancel <-chan struct{}) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsDelete(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{Cancel: cancel})
+}
+
+// DeleteSender sends the Delete request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) DeleteSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client,
+ req,
+ azure.DoPollForAsynchronous(client.PollingDelay))
+}
+
+// DeleteResponder handles the response to the Delete request. The method always
+// closes the http.Response Body.
+func (client DisksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Get gets information about a disk.
+//
+// resourceGroupName is the name of the resource group. diskName is the name of
+// the disk within the given subscription and resource group.
+func (client DisksClient) Get(resourceGroupName string, diskName string) (result Model, err error) {
+ req, err := client.GetPreparer(resourceGroupName, diskName)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Get", nil, "Failure preparing request")
+ }
+
+ resp, err := client.GetSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Get", resp, "Failure sending request")
+ }
+
+ result, err = client.GetResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.DisksClient", "Get", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// GetPreparer prepares the Get request.
+func (client DisksClient) GetPreparer(resourceGroupName string, diskName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{})
+}
+
+// GetSender sends the Get request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) GetSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req)
+}
+
+// GetResponder handles the response to the Get request. The method always
+// closes the http.Response Body.
+func (client DisksClient) GetResponder(resp *http.Response) (result Model, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// GrantAccess grants access to a disk. This method may poll for completion.
+// Polling can be canceled by passing the cancel channel argument. The channel
+// will be used to cancel polling and any outstanding HTTP requests.
+//
+// resourceGroupName is the name of the resource group. diskName is the name of
+// the disk within the given subscription and resource group. grantAccessData
+// is access data object supplied in the body of the get disk access operation.
+func (client DisksClient) GrantAccess(resourceGroupName string, diskName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (result autorest.Response, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: grantAccessData,
+ Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
+ return result, validation.NewErrorWithValidationError(err, "disk.DisksClient", "GrantAccess")
+ }
+
+ req, err := client.GrantAccessPreparer(resourceGroupName, diskName, grantAccessData, cancel)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", nil, "Failure preparing request")
+ }
+
+ resp, err := client.GrantAccessSender(req)
+ if err != nil {
+ result.Response = resp
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure sending request")
+ }
+
+ result, err = client.GrantAccessResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// GrantAccessPreparer prepares the GrantAccess request.
+func (client DisksClient) GrantAccessPreparer(resourceGroupName string, diskName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsJSON(),
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess", pathParameters),
+ autorest.WithJSON(grantAccessData),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{Cancel: cancel})
+}
+
+// GrantAccessSender sends the GrantAccess request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) GrantAccessSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client,
+ req,
+ azure.DoPollForAsynchronous(client.PollingDelay))
+}
+
+// GrantAccessResponder handles the response to the GrantAccess request. The method always
+// closes the http.Response Body.
+func (client DisksClient) GrantAccessResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// List lists all the disks under a subscription.
+func (client DisksClient) List() (result ListType, err error) {
+ req, err := client.ListPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "List", nil, "Failure preparing request")
+ }
+
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "List", resp, "Failure sending request")
+ }
+
+ result, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.DisksClient", "List", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListPreparer prepares the List request.
+func (client DisksClient) ListPreparer() (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{})
+}
+
+// ListSender sends the List request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) ListSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req)
+}
+
+// ListResponder handles the response to the List request. The method always
+// closes the http.Response Body.
+func (client DisksClient) ListResponder(resp *http.Response) (result ListType, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// ListNextResults retrieves the next set of results, if any.
+func (client DisksClient) ListNextResults(lastResults ListType) (result ListType, err error) {
+ req, err := lastResults.ListTypePreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "List", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "List", resp, "Failure sending next results request")
+ }
+
+ result, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.DisksClient", "List", resp, "Failure responding to next results request")
+ }
+
+ return
+}
+
+// ListByResourceGroup lists all the disks under a resource group.
+//
+// resourceGroupName is the name of the resource group.
+func (client DisksClient) ListByResourceGroup(resourceGroupName string) (result ListType, err error) {
+ req, err := client.ListByResourceGroupPreparer(resourceGroupName)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", nil, "Failure preparing request")
+ }
+
+ resp, err := client.ListByResourceGroupSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", resp, "Failure sending request")
+ }
+
+ result, err = client.ListByResourceGroupResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
+func (client DisksClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{})
+}
+
+// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req)
+}
+
+// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
+// closes the http.Response Body.
+func (client DisksClient) ListByResourceGroupResponder(resp *http.Response) (result ListType, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// ListByResourceGroupNextResults retrieves the next set of results, if any.
+func (client DisksClient) ListByResourceGroupNextResults(lastResults ListType) (result ListType, err error) {
+ req, err := lastResults.ListTypePreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+
+ resp, err := client.ListByResourceGroupSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", resp, "Failure sending next results request")
+ }
+
+ result, err = client.ListByResourceGroupResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", resp, "Failure responding to next results request")
+ }
+
+ return
+}
+
+// RevokeAccess revokes access to a disk. This method may poll for completion.
+// Polling can be canceled by passing the cancel channel argument. The channel
+// will be used to cancel polling and any outstanding HTTP requests.
+//
+// resourceGroupName is the name of the resource group. diskName is the name of
+// the disk within the given subscription and resource group.
+func (client DisksClient) RevokeAccess(resourceGroupName string, diskName string, cancel <-chan struct{}) (result autorest.Response, err error) {
+ req, err := client.RevokeAccessPreparer(resourceGroupName, diskName, cancel)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", nil, "Failure preparing request")
+ }
+
+ resp, err := client.RevokeAccessSender(req)
+ if err != nil {
+ result.Response = resp
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure sending request")
+ }
+
+ result, err = client.RevokeAccessResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// RevokeAccessPreparer prepares the RevokeAccess request.
+func (client DisksClient) RevokeAccessPreparer(resourceGroupName string, diskName string, cancel <-chan struct{}) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{Cancel: cancel})
+}
+
+// RevokeAccessSender sends the RevokeAccess request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) RevokeAccessSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client,
+ req,
+ azure.DoPollForAsynchronous(client.PollingDelay))
+}
+
+// RevokeAccessResponder handles the response to the RevokeAccess request. The method always
+// closes the http.Response Body.
+func (client DisksClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Update updates (patches) a disk. This method may poll for completion.
+// Polling can be canceled by passing the cancel channel argument. The channel
+// will be used to cancel polling and any outstanding HTTP requests.
+//
+// resourceGroupName is the name of the resource group. diskName is the name of
+// the disk within the given subscription and resource group. diskParameter is
+// disk object supplied in the body of the Patch disk operation.
+func (client DisksClient) Update(resourceGroupName string, diskName string, diskParameter UpdateType, cancel <-chan struct{}) (result autorest.Response, err error) {
+ req, err := client.UpdatePreparer(resourceGroupName, diskName, diskParameter, cancel)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Update", nil, "Failure preparing request")
+ }
+
+ resp, err := client.UpdateSender(req)
+ if err != nil {
+ result.Response = resp
+ return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure sending request")
+ }
+
+ result, err = client.UpdateResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// UpdatePreparer prepares the Update request.
+func (client DisksClient) UpdatePreparer(resourceGroupName string, diskName string, diskParameter UpdateType, cancel <-chan struct{}) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsJSON(),
+ autorest.AsPatch(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
+ autorest.WithJSON(diskParameter),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{Cancel: cancel})
+}
+
+// UpdateSender sends the Update request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) UpdateSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client,
+ req,
+ azure.DoPollForAsynchronous(client.PollingDelay))
+}
+
+// UpdateResponder handles the response to the Update request. The method always
+// closes the http.Response Body.
+func (client DisksClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/models.go
new file mode 100644
index 000000000..e8118696a
--- /dev/null
+++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/models.go
@@ -0,0 +1,278 @@
+package disk
+
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+import (
+ "github.com/Azure/go-autorest/autorest"
+ "github.com/Azure/go-autorest/autorest/date"
+ "github.com/Azure/go-autorest/autorest/to"
+ "net/http"
+)
+
+// AccessLevel enumerates the values for access level.
+type AccessLevel string
+
+const (
+ // None specifies the none state for access level.
+ None AccessLevel = "None"
+ // Read specifies the read state for access level.
+ Read AccessLevel = "Read"
+)
+
+// CreateOption enumerates the values for create option.
+type CreateOption string
+
+const (
+ // Attach specifies the attach state for create option.
+ Attach CreateOption = "Attach"
+ // Copy specifies the copy state for create option.
+ Copy CreateOption = "Copy"
+ // Empty specifies the empty state for create option.
+ Empty CreateOption = "Empty"
+ // FromImage specifies the from image state for create option.
+ FromImage CreateOption = "FromImage"
+ // Import specifies the import state for create option.
+ Import CreateOption = "Import"
+ // Restore specifies the restore state for create option.
+ Restore CreateOption = "Restore"
+)
+
+// OperatingSystemTypes enumerates the values for operating system types.
+type OperatingSystemTypes string
+
+const (
+ // Linux specifies the linux state for operating system types.
+ Linux OperatingSystemTypes = "Linux"
+ // Windows specifies the windows state for operating system types.
+ Windows OperatingSystemTypes = "Windows"
+)
+
+// StorageAccountTypes enumerates the values for storage account types.
+type StorageAccountTypes string
+
+const (
+ // PremiumLRS specifies the premium lrs state for storage account types.
+ PremiumLRS StorageAccountTypes = "Premium_LRS"
+ // StandardLRS specifies the standard lrs state for storage account types.
+ StandardLRS StorageAccountTypes = "Standard_LRS"
+)
+
+// AccessURI is a disk access SAS uri.
+type AccessURI struct {
+ autorest.Response `json:"-"`
+ *AccessURIOutput `json:"properties,omitempty"`
+}
+
+// AccessURIOutput is azure properties, including output.
+type AccessURIOutput struct {
+ *AccessURIRaw `json:"output,omitempty"`
+}
+
+// AccessURIRaw is this object gets 'bubbled up' through flattening.
+type AccessURIRaw struct {
+ AccessSAS *string `json:"accessSAS,omitempty"`
+}
+
+// APIError is api error.
+type APIError struct {
+ Details *[]APIErrorBase `json:"details,omitempty"`
+ Innererror *InnerError `json:"innererror,omitempty"`
+ Code *string `json:"code,omitempty"`
+ Target *string `json:"target,omitempty"`
+ Message *string `json:"message,omitempty"`
+}
+
+// APIErrorBase is api error base.
+type APIErrorBase struct {
+ Code *string `json:"code,omitempty"`
+ Target *string `json:"target,omitempty"`
+ Message *string `json:"message,omitempty"`
+}
+
+// CreationData is data used when creating a disk.
+type CreationData struct {
+ CreateOption CreateOption `json:"createOption,omitempty"`
+ StorageAccountID *string `json:"storageAccountId,omitempty"`
+ ImageReference *ImageDiskReference `json:"imageReference,omitempty"`
+ SourceURI *string `json:"sourceUri,omitempty"`
+ SourceResourceID *string `json:"sourceResourceId,omitempty"`
+}
+
+// EncryptionSettings is encryption settings for disk or snapshot
+type EncryptionSettings struct {
+ Enabled *bool `json:"enabled,omitempty"`
+ DiskEncryptionKey *KeyVaultAndSecretReference `json:"diskEncryptionKey,omitempty"`
+ KeyEncryptionKey *KeyVaultAndKeyReference `json:"keyEncryptionKey,omitempty"`
+}
+
+// GrantAccessData is data used for requesting a SAS.
+type GrantAccessData struct {
+ Access AccessLevel `json:"access,omitempty"`
+ DurationInSeconds *int32 `json:"durationInSeconds,omitempty"`
+}
+
+// ImageDiskReference is the source image used for creating the disk.
+type ImageDiskReference struct {
+ ID *string `json:"id,omitempty"`
+ Lun *int32 `json:"lun,omitempty"`
+}
+
+// InnerError is inner error details.
+type InnerError struct {
+ Exceptiontype *string `json:"exceptiontype,omitempty"`
+ Errordetail *string `json:"errordetail,omitempty"`
+}
+
+// KeyVaultAndKeyReference is key Vault Key Url and vault id of KeK, KeK is
+// optional and when provided is used to unwrap the encryptionKey
+type KeyVaultAndKeyReference struct {
+ SourceVault *SourceVault `json:"sourceVault,omitempty"`
+ KeyURL *string `json:"keyUrl,omitempty"`
+}
+
+// KeyVaultAndSecretReference is key Vault Secret Url and vault id of the
+// encryption key
+type KeyVaultAndSecretReference struct {
+ SourceVault *SourceVault `json:"sourceVault,omitempty"`
+ SecretURL *string `json:"secretUrl,omitempty"`
+}
+
+// ListType is the List Disks operation response.
+type ListType struct {
+ autorest.Response `json:"-"`
+ Value *[]Model `json:"value,omitempty"`
+ NextLink *string `json:"nextLink,omitempty"`
+}
+
+// ListTypePreparer prepares a request to retrieve the next set of results. It returns
+// nil if no more results exist.
+func (client ListType) ListTypePreparer() (*http.Request, error) {
+ if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
+ return nil, nil
+ }
+ return autorest.Prepare(&http.Request{},
+ autorest.AsJSON(),
+ autorest.AsGet(),
+ autorest.WithBaseURL(to.String(client.NextLink)))
+}
+
+// Model is disk resource.
+type Model struct {
+ autorest.Response `json:"-"`
+ ID *string `json:"id,omitempty"`
+ Name *string `json:"name,omitempty"`
+ Type *string `json:"type,omitempty"`
+ Location *string `json:"location,omitempty"`
+ Tags *map[string]*string `json:"tags,omitempty"`
+ *Properties `json:"properties,omitempty"`
+}
+
+// OperationStatusResponse is operation status response
+type OperationStatusResponse struct {
+ autorest.Response `json:"-"`
+ Name *string `json:"name,omitempty"`
+ Status *string `json:"status,omitempty"`
+ StartTime *date.Time `json:"startTime,omitempty"`
+ EndTime *date.Time `json:"endTime,omitempty"`
+ Error *APIError `json:"error,omitempty"`
+}
+
+// Properties is disk resource properties.
+type Properties struct {
+ AccountType StorageAccountTypes `json:"accountType,omitempty"`
+ TimeCreated *date.Time `json:"timeCreated,omitempty"`
+ OsType OperatingSystemTypes `json:"osType,omitempty"`
+ CreationData *CreationData `json:"creationData,omitempty"`
+ DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
+ EncryptionSettings *EncryptionSettings `json:"encryptionSettings,omitempty"`
+ OwnerID *string `json:"ownerId,omitempty"`
+ ProvisioningState *string `json:"provisioningState,omitempty"`
+}
+
+// Resource is the Resource model definition.
+type Resource struct {
+ ID *string `json:"id,omitempty"`
+ Name *string `json:"name,omitempty"`
+ Type *string `json:"type,omitempty"`
+ Location *string `json:"location,omitempty"`
+ Tags *map[string]*string `json:"tags,omitempty"`
+}
+
+// ResourceUpdate is the Resource model definition.
+type ResourceUpdate struct {
+ Tags *map[string]*string `json:"tags,omitempty"`
+}
+
+// Snapshot is snapshot resource.
+type Snapshot struct {
+ autorest.Response `json:"-"`
+ ID *string `json:"id,omitempty"`
+ Name *string `json:"name,omitempty"`
+ Type *string `json:"type,omitempty"`
+ Location *string `json:"location,omitempty"`
+ Tags *map[string]*string `json:"tags,omitempty"`
+ *Properties `json:"properties,omitempty"`
+}
+
+// SnapshotList is the List Snapshots operation response.
+type SnapshotList struct {
+ autorest.Response `json:"-"`
+ Value *[]Snapshot `json:"value,omitempty"`
+ NextLink *string `json:"nextLink,omitempty"`
+}
+
+// SnapshotListPreparer prepares a request to retrieve the next set of results. It returns
+// nil if no more results exist.
+func (client SnapshotList) SnapshotListPreparer() (*http.Request, error) {
+ if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
+ return nil, nil
+ }
+ return autorest.Prepare(&http.Request{},
+ autorest.AsJSON(),
+ autorest.AsGet(),
+ autorest.WithBaseURL(to.String(client.NextLink)))
+}
+
+// SnapshotUpdate is snapshot update resource.
+type SnapshotUpdate struct {
+ Tags *map[string]*string `json:"tags,omitempty"`
+ *UpdateProperties `json:"properties,omitempty"`
+}
+
+// SourceVault is the vault id is an Azure Resource Manager Resoure id in the
+// form
+// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}
+type SourceVault struct {
+ ID *string `json:"id,omitempty"`
+}
+
+// UpdateProperties is disk resource update properties.
+type UpdateProperties struct {
+ AccountType StorageAccountTypes `json:"accountType,omitempty"`
+ OsType OperatingSystemTypes `json:"osType,omitempty"`
+ CreationData *CreationData `json:"creationData,omitempty"`
+ DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
+ EncryptionSettings *EncryptionSettings `json:"encryptionSettings,omitempty"`
+}
+
+// UpdateType is disk update resource.
+type UpdateType struct {
+ Tags *map[string]*string `json:"tags,omitempty"`
+ *UpdateProperties `json:"properties,omitempty"`
+}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/snapshots.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/snapshots.go
new file mode 100644
index 000000000..20e6ec758
--- /dev/null
+++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/snapshots.go
@@ -0,0 +1,643 @@
+package disk
+
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+import (
+ "github.com/Azure/go-autorest/autorest"
+ "github.com/Azure/go-autorest/autorest/azure"
+ "github.com/Azure/go-autorest/autorest/validation"
+ "net/http"
+)
+
+// SnapshotsClient is the the Disk Resource Provider Client.
+type SnapshotsClient struct {
+ ManagementClient
+}
+
+// NewSnapshotsClient creates an instance of the SnapshotsClient client.
+func NewSnapshotsClient(subscriptionID string) SnapshotsClient {
+ return NewSnapshotsClientWithBaseURI(DefaultBaseURI, subscriptionID)
+}
+
+// NewSnapshotsClientWithBaseURI creates an instance of the SnapshotsClient
+// client.
+func NewSnapshotsClientWithBaseURI(baseURI string, subscriptionID string) SnapshotsClient {
+ return SnapshotsClient{NewWithBaseURI(baseURI, subscriptionID)}
+}
+
+// CreateOrUpdate creates or updates a snapshot. This method may poll for
+// completion. Polling can be canceled by passing the cancel channel argument.
+// The channel will be used to cancel polling and any outstanding HTTP
+// requests.
+//
+// resourceGroupName is the name of the resource group. snapshotName is the
+// name of the snapshot within the given subscription and resource group.
+// snapshot is snapshot object supplied in the body of the Put disk operation.
+func (client SnapshotsClient) CreateOrUpdate(resourceGroupName string, snapshotName string, snapshot Snapshot, cancel <-chan struct{}) (result autorest.Response, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: snapshot,
+ Constraints: []validation.Constraint{{Target: "snapshot.Properties", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "snapshot.Properties.CreationData", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "snapshot.Properties.CreationData.ImageReference", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "snapshot.Properties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
+ }},
+ {Target: "snapshot.Properties.EncryptionSettings", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "snapshot.Properties.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "snapshot.Properties.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "snapshot.Properties.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ {Target: "snapshot.Properties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "snapshot.Properties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "snapshot.Properties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ }},
+ }}}}}); err != nil {
+ return result, validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "CreateOrUpdate")
+ }
+
+ req, err := client.CreateOrUpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", nil, "Failure preparing request")
+ }
+
+ resp, err := client.CreateOrUpdateSender(req)
+ if err != nil {
+ result.Response = resp
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure sending request")
+ }
+
+ result, err = client.CreateOrUpdateResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
+func (client SnapshotsClient) CreateOrUpdatePreparer(resourceGroupName string, snapshotName string, snapshot Snapshot, cancel <-chan struct{}) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsJSON(),
+ autorest.AsPut(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
+ autorest.WithJSON(snapshot),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{Cancel: cancel})
+}
+
+// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client,
+ req,
+ azure.DoPollForAsynchronous(client.PollingDelay))
+}
+
+// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Delete deletes a snapshot. This method may poll for completion. Polling can
+// be canceled by passing the cancel channel argument. The channel will be used
+// to cancel polling and any outstanding HTTP requests.
+//
+// resourceGroupName is the name of the resource group. snapshotName is the
+// name of the snapshot within the given subscription and resource group.
+func (client SnapshotsClient) Delete(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (result autorest.Response, err error) {
+ req, err := client.DeletePreparer(resourceGroupName, snapshotName, cancel)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", nil, "Failure preparing request")
+ }
+
+ resp, err := client.DeleteSender(req)
+ if err != nil {
+ result.Response = resp
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure sending request")
+ }
+
+ result, err = client.DeleteResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// DeletePreparer prepares the Delete request.
+func (client SnapshotsClient) DeletePreparer(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsDelete(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{Cancel: cancel})
+}
+
+// DeleteSender sends the Delete request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) DeleteSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client,
+ req,
+ azure.DoPollForAsynchronous(client.PollingDelay))
+}
+
+// DeleteResponder handles the response to the Delete request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Get gets information about a snapshot.
+//
+// resourceGroupName is the name of the resource group. snapshotName is the
+// name of the snapshot within the given subscription and resource group.
+func (client SnapshotsClient) Get(resourceGroupName string, snapshotName string) (result Snapshot, err error) {
+ req, err := client.GetPreparer(resourceGroupName, snapshotName)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", nil, "Failure preparing request")
+ }
+
+ resp, err := client.GetSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", resp, "Failure sending request")
+ }
+
+ result, err = client.GetResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// GetPreparer prepares the Get request.
+func (client SnapshotsClient) GetPreparer(resourceGroupName string, snapshotName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{})
+}
+
+// GetSender sends the Get request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) GetSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req)
+}
+
+// GetResponder handles the response to the Get request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) GetResponder(resp *http.Response) (result Snapshot, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// GrantAccess grants access to a snapshot. This method may poll for
+// completion. Polling can be canceled by passing the cancel channel argument.
+// The channel will be used to cancel polling and any outstanding HTTP
+// requests.
+//
+// resourceGroupName is the name of the resource group. snapshotName is the
+// name of the snapshot within the given subscription and resource group.
+// grantAccessData is access data object supplied in the body of the get
+// snapshot access operation.
+func (client SnapshotsClient) GrantAccess(resourceGroupName string, snapshotName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (result autorest.Response, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: grantAccessData,
+ Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
+ return result, validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "GrantAccess")
+ }
+
+ req, err := client.GrantAccessPreparer(resourceGroupName, snapshotName, grantAccessData, cancel)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", nil, "Failure preparing request")
+ }
+
+ resp, err := client.GrantAccessSender(req)
+ if err != nil {
+ result.Response = resp
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure sending request")
+ }
+
+ result, err = client.GrantAccessResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// GrantAccessPreparer prepares the GrantAccess request.
+func (client SnapshotsClient) GrantAccessPreparer(resourceGroupName string, snapshotName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsJSON(),
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", pathParameters),
+ autorest.WithJSON(grantAccessData),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{Cancel: cancel})
+}
+
+// GrantAccessSender sends the GrantAccess request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) GrantAccessSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client,
+ req,
+ azure.DoPollForAsynchronous(client.PollingDelay))
+}
+
+// GrantAccessResponder handles the response to the GrantAccess request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// List lists snapshots under a subscription.
+func (client SnapshotsClient) List() (result SnapshotList, err error) {
+ req, err := client.ListPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", nil, "Failure preparing request")
+ }
+
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", resp, "Failure sending request")
+ }
+
+ result, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListPreparer prepares the List request.
+func (client SnapshotsClient) ListPreparer() (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{})
+}
+
+// ListSender sends the List request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) ListSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req)
+}
+
+// ListResponder handles the response to the List request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) ListResponder(resp *http.Response) (result SnapshotList, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// ListNextResults retrieves the next set of results, if any.
+func (client SnapshotsClient) ListNextResults(lastResults SnapshotList) (result SnapshotList, err error) {
+ req, err := lastResults.SnapshotListPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", resp, "Failure sending next results request")
+ }
+
+ result, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", resp, "Failure responding to next results request")
+ }
+
+ return
+}
+
+// ListByResourceGroup lists snapshots under a resource group.
+//
+// resourceGroupName is the name of the resource group.
+func (client SnapshotsClient) ListByResourceGroup(resourceGroupName string) (result SnapshotList, err error) {
+ req, err := client.ListByResourceGroupPreparer(resourceGroupName)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", nil, "Failure preparing request")
+ }
+
+ resp, err := client.ListByResourceGroupSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending request")
+ }
+
+ result, err = client.ListByResourceGroupResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
+func (client SnapshotsClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{})
+}
+
+// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req)
+}
+
+// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) ListByResourceGroupResponder(resp *http.Response) (result SnapshotList, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// ListByResourceGroupNextResults retrieves the next set of results, if any.
+func (client SnapshotsClient) ListByResourceGroupNextResults(lastResults SnapshotList) (result SnapshotList, err error) {
+ req, err := lastResults.SnapshotListPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+
+ resp, err := client.ListByResourceGroupSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending next results request")
+ }
+
+ result, err = client.ListByResourceGroupResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure responding to next results request")
+ }
+
+ return
+}
+
+// RevokeAccess revokes access to a snapshot. This method may poll for
+// completion. Polling can be canceled by passing the cancel channel argument.
+// The channel will be used to cancel polling and any outstanding HTTP
+// requests.
+//
+// resourceGroupName is the name of the resource group. snapshotName is the
+// name of the snapshot within the given subscription and resource group.
+func (client SnapshotsClient) RevokeAccess(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (result autorest.Response, err error) {
+ req, err := client.RevokeAccessPreparer(resourceGroupName, snapshotName, cancel)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", nil, "Failure preparing request")
+ }
+
+ resp, err := client.RevokeAccessSender(req)
+ if err != nil {
+ result.Response = resp
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure sending request")
+ }
+
+ result, err = client.RevokeAccessResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// RevokeAccessPreparer prepares the RevokeAccess request.
+func (client SnapshotsClient) RevokeAccessPreparer(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{Cancel: cancel})
+}
+
+// RevokeAccessSender sends the RevokeAccess request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) RevokeAccessSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client,
+ req,
+ azure.DoPollForAsynchronous(client.PollingDelay))
+}
+
+// RevokeAccessResponder handles the response to the RevokeAccess request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Update updates (patches) a snapshot. This method may poll for completion.
+// Polling can be canceled by passing the cancel channel argument. The channel
+// will be used to cancel polling and any outstanding HTTP requests.
+//
+// resourceGroupName is the name of the resource group. snapshotName is the
+// name of the snapshot within the given subscription and resource group.
+// snapshot is snapshot object supplied in the body of the Patch snapshot
+// operation.
+func (client SnapshotsClient) Update(resourceGroupName string, snapshotName string, snapshot SnapshotUpdate, cancel <-chan struct{}) (result autorest.Response, err error) {
+ req, err := client.UpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel)
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", nil, "Failure preparing request")
+ }
+
+ resp, err := client.UpdateSender(req)
+ if err != nil {
+ result.Response = resp
+ return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure sending request")
+ }
+
+ result, err = client.UpdateResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// UpdatePreparer prepares the Update request.
+func (client SnapshotsClient) UpdatePreparer(resourceGroupName string, snapshotName string, snapshot SnapshotUpdate, cancel <-chan struct{}) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ queryParameters := map[string]interface{}{
+ "api-version": client.APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsJSON(),
+ autorest.AsPatch(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
+ autorest.WithJSON(snapshot),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare(&http.Request{Cancel: cancel})
+}
+
+// UpdateSender sends the Update request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) UpdateSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client,
+ req,
+ azure.DoPollForAsynchronous(client.PollingDelay))
+}
+
+// UpdateResponder handles the response to the Update request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go
new file mode 100644
index 000000000..9b5497d54
--- /dev/null
+++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go
@@ -0,0 +1,60 @@
+package disk
+
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+import (
+ "bytes"
+ "fmt"
+ "strings"
+)
+
+const (
+ major = "8"
+ minor = "1"
+ patch = "0"
+ tag = "beta"
+ userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s"
+)
+
+// cached results of UserAgent and Version to prevent repeated operations.
+var (
+ userAgent string
+ version string
+)
+
+// UserAgent returns the UserAgent string to use when sending http.Requests.
+func UserAgent() string {
+ if userAgent == "" {
+ userAgent = fmt.Sprintf(userAgentFormat, Version(), "disk", "2016-04-30-preview")
+ }
+ return userAgent
+}
+
+// Version returns the semantic version (see http://semver.org) of the client.
+func Version() string {
+ if version == "" {
+ versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch))
+ if tag != "" {
+ versionBuilder.WriteRune('-')
+ versionBuilder.WriteString(strings.TrimPrefix(tag, "-"))
+ }
+ version = string(versionBuilder.Bytes())
+ }
+ return version
+}
diff --git a/vendor/vendor.json b/vendor/vendor.json
index ba7383b71..7b007d414 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -50,6 +50,14 @@
"version": "v8.1.0-beta",
"versionExact": "v8.1.0-beta"
},
+ {
+ "checksumSHA1": "iAZi+Mh1Tivk3bdBbAEz+bd5nPg=",
+ "path": "github.com/Azure/azure-sdk-for-go/arm/disk",
+ "revision": "ecf40e315d5ab0ca6d7b3b7f7fbb5c1577814813",
+ "revisionTime": "2017-03-02T00:14:02Z",
+ "version": "v8.1.0-beta",
+ "versionExact": "v8.1.0-beta"
+ },
{
"checksumSHA1": "ro1i9qoJcSgbWgV7D93wXhBwoL8=",
"comment": "v2.1.1-beta-8-gca4d906",
diff --git a/website/Gemfile b/website/Gemfile
index 08e6fe65e..405a8c992 100644
--- a/website/Gemfile
+++ b/website/Gemfile
@@ -1,3 +1,3 @@
source "https://rubygems.org"
-gem "middleman-hashicorp", "0.3.13"
+gem "middleman-hashicorp", "0.3.22"
diff --git a/website/Gemfile.lock b/website/Gemfile.lock
index 0811f6d62..229218ac9 100644
--- a/website/Gemfile.lock
+++ b/website/Gemfile.lock
@@ -6,7 +6,7 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
- autoprefixer-rails (6.7.6)
+ autoprefixer-rails (6.7.7.1)
execjs
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
@@ -77,7 +77,7 @@ GEM
rack (>= 1.4.5, < 2.0)
thor (>= 0.15.2, < 2.0)
tilt (~> 1.4.1, < 2.0)
- middleman-hashicorp (0.3.13)
+ middleman-hashicorp (0.3.22)
bootstrap-sass (~> 3.3)
builder (~> 3.2)
middleman (~> 3.4)
@@ -103,7 +103,7 @@ GEM
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
- nokogiri (1.7.0.1)
+ nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
padrino-helpers (0.12.8.1)
i18n (~> 0.6, >= 0.6.7)
@@ -138,7 +138,7 @@ GEM
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
- tzinfo (1.2.2)
+ tzinfo (1.2.3)
thread_safe (~> 0.1)
uber (0.0.15)
uglifier (2.7.2)
@@ -151,7 +151,7 @@ PLATFORMS
ruby
DEPENDENCIES
- middleman-hashicorp (= 0.3.13)
+ middleman-hashicorp (= 0.3.22)
BUNDLED WITH
1.14.6
diff --git a/website/Makefile b/website/Makefile
index 41fcf114e..d7620d1c2 100644
--- a/website/Makefile
+++ b/website/Makefile
@@ -1,14 +1,24 @@
-VERSION?="0.3.13"
+VERSION?="0.3.22"
+
+build:
+ @echo "==> Starting build in Docker..."
+ @docker run \
+ --interactive \
+ --rm \
+ --tty \
+ --volume "$(shell pwd):/website" \
+ hashicorp/middleman-hashicorp:${VERSION} \
+ bundle exec middleman build --verbose --clean
website:
@echo "==> Starting website in Docker..."
@docker run \
- --interactive \
- --rm \
+ --interactive \
+ --rm \
--tty \
--publish "4567:4567" \
--publish "35729:35729" \
--volume "$(shell pwd):/website" \
hashicorp/middleman-hashicorp:${VERSION}
-.PHONY: website
+.PHONY: build website
diff --git a/website/config.rb b/website/config.rb
index 6e2d25511..b58df71f0 100644
--- a/website/config.rb
+++ b/website/config.rb
@@ -7,6 +7,15 @@ activate :hashicorp do |h|
end
helpers do
+ # Returns the FQDN of the image URL.
+ #
+ # @param [String] path
+ #
+ # @return [String]
+ def image_url(path)
+ File.join(base_url, image_path(path))
+ end
+
# Get the title for the page.
#
# @param [Middleman::Page] page
@@ -26,17 +35,66 @@ helpers do
#
# @return [String]
def description_for(page)
- return escape_html(page.data.description || "")
+ description = (page.data.description || "")
+ .gsub('"', '')
+ .gsub(/\n+/, ' ')
+ .squeeze(' ')
+
+ return escape_html(description)
end
# This helps by setting the "active" class for sidebar nav elements
# if the YAML frontmatter matches the expected value.
def sidebar_current(expected)
current = current_page.data.sidebar_current || ""
- if current == expected or (expected.is_a?(Regexp) and expected.match(current))
+ if current.start_with?(expected)
return " class=\"active\""
else
return ""
end
end
+
+ # Returns the id for this page.
+ # @return [String]
+ def body_id_for(page)
+ if !(name = page.data.sidebar_current).blank?
+ return "page-#{name.strip}"
+ end
+ if page.url == "/" || page.url == "/index.html"
+ return "page-home"
+ end
+ if !(title = page.data.page_title).blank?
+ return title
+ .downcase
+ .gsub('"', '')
+ .gsub(/[^\w]+/, '-')
+ .gsub(/_+/, '-')
+ .squeeze('-')
+ .squeeze(' ')
+ end
+ return ""
+ end
+
+ # Returns the list of classes for this page.
+ # @return [String]
+ def body_classes_for(page)
+ classes = []
+
+ if !(layout = page.data.layout).blank?
+ classes << "layout-#{page.data.layout}"
+ end
+
+ if !(title = page.data.page_title).blank?
+ title = title
+ .downcase
+ .gsub('"', '')
+ .gsub(/[^\w]+/, '-')
+ .gsub(/_+/, '-')
+ .squeeze('-')
+ .squeeze(' ')
+ classes << "page-#{title}"
+ end
+
+ return classes.join(" ")
+ end
end
diff --git a/website/packer.json b/website/packer.json
index b51f63801..35de63232 100644
--- a/website/packer.json
+++ b/website/packer.json
@@ -8,7 +8,7 @@
"builders": [
{
"type": "docker",
- "image": "hashicorp/middleman-hashicorp:0.3.13",
+ "image": "hashicorp/middleman-hashicorp:0.3.22",
"discard": "true",
"run_command": ["-d", "-i", "-t", "{{ .Image }}", "/bin/sh"]
}
diff --git a/website/source/.gitignore b/website/source/.gitignore
deleted file mode 100644
index 67550a149..000000000
--- a/website/source/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Source folder
-node_modules/
diff --git a/website/source/404.html.erb b/website/source/404.html.erb
deleted file mode 100644
index f49742d5d..000000000
--- a/website/source/404.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
----
-layout: "inner"
-noindex: true
-page_title: "404"
----
-
-
Page not found
-
-
-Unfortunately, the page you requested can't be found.
-
diff --git a/website/source/404.html.md b/website/source/404.html.md
new file mode 100644
index 000000000..e99ce088b
--- /dev/null
+++ b/website/source/404.html.md
@@ -0,0 +1,14 @@
+---
+layout: "inner"
+page_title: "Not Found"
+noindex: true
+description: |-
+ Page not found!
+---
+
+# Page Not Found
+
+Sorry, the page you tried to visit does not exist. This could be our fault,
+and if so we will fix that up right away.
+
+Please go back, or go back to get back on track.
diff --git a/website/source/android-manifest.json.erb b/website/source/android-manifest.json.erb
new file mode 100644
index 000000000..224636a38
--- /dev/null
+++ b/website/source/android-manifest.json.erb
@@ -0,0 +1,18 @@
+{
+ "name": "HashiCorp Terraform",
+ "icons": [
+ {
+ "src": "<%= image_path('favicons/android-chrome-192x192.png') %>",
+ "sizes": "192x192",
+ "type": "image/png"
+ },
+ {
+ "src": "<%= image_path('favicons/android-chrome-512x512.png') %>",
+ "sizes": "512x512",
+ "type": "image/png"
+ }
+ ],
+ "theme_color": "#ffffff",
+ "background_color": "#ffffff",
+ "display": "standalone"
+}
diff --git a/website/source/assets/files/press-kit.zip b/website/source/assets/files/press-kit.zip
new file mode 100644
index 000000000..dde265f79
Binary files /dev/null and b/website/source/assets/files/press-kit.zip differ
diff --git a/website/source/assets/images/bg-galaxy.jpg b/website/source/assets/images/bg-galaxy.jpg
deleted file mode 100644
index 587004afa..000000000
Binary files a/website/source/assets/images/bg-galaxy.jpg and /dev/null differ
diff --git a/website/source/assets/images/bg-static.png b/website/source/assets/images/bg-static.png
deleted file mode 100644
index 7d6436172..000000000
Binary files a/website/source/assets/images/bg-static.png and /dev/null differ
diff --git a/website/source/assets/images/customer-logos/capital-one.svg b/website/source/assets/images/customer-logos/capital-one.svg
deleted file mode 100644
index a03474332..000000000
--- a/website/source/assets/images/customer-logos/capital-one.svg
+++ /dev/null
@@ -1,289 +0,0 @@
-
-
-
diff --git a/website/source/assets/images/customer-logos/hbo.svg b/website/source/assets/images/customer-logos/hbo.svg
deleted file mode 100644
index 784d540d0..000000000
--- a/website/source/assets/images/customer-logos/hbo.svg
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
diff --git a/website/source/assets/images/customer-logos/home-depot.svg b/website/source/assets/images/customer-logos/home-depot.svg
deleted file mode 100644
index 553b5ef97..000000000
--- a/website/source/assets/images/customer-logos/home-depot.svg
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
diff --git a/website/source/assets/images/customer-logos/hotels-dot-com.svg b/website/source/assets/images/customer-logos/hotels-dot-com.svg
deleted file mode 100644
index 1d84ec6e6..000000000
--- a/website/source/assets/images/customer-logos/hotels-dot-com.svg
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
diff --git a/website/source/assets/images/customer-logos/nike.svg b/website/source/assets/images/customer-logos/nike.svg
deleted file mode 100644
index 51fa23ceb..000000000
--- a/website/source/assets/images/customer-logos/nike.svg
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
diff --git a/website/source/assets/images/customer-logos/target.svg b/website/source/assets/images/customer-logos/target.svg
deleted file mode 100644
index 4d8094a6a..000000000
--- a/website/source/assets/images/customer-logos/target.svg
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
diff --git a/website/source/assets/images/docs/atlas-workflow.png b/website/source/assets/images/docs/atlas-workflow.png
deleted file mode 100644
index 144e2cedc..000000000
Binary files a/website/source/assets/images/docs/atlas-workflow.png and /dev/null differ
diff --git a/website/source/assets/images/graph-example.png b/website/source/assets/images/docs/graph-example.png
similarity index 100%
rename from website/source/assets/images/graph-example.png
rename to website/source/assets/images/docs/graph-example.png
diff --git a/website/source/assets/images/enterprise-callout-bg copy.svg b/website/source/assets/images/enterprise-callout-bg copy.svg
new file mode 100644
index 000000000..14a97072a
--- /dev/null
+++ b/website/source/assets/images/enterprise-callout-bg copy.svg
@@ -0,0 +1,18 @@
+
diff --git a/website/source/assets/images/enterprise-callout-bg.svg b/website/source/assets/images/enterprise-callout-bg.svg
index c7c2649f2..ee4ba0afc 100644
--- a/website/source/assets/images/enterprise-callout-bg.svg
+++ b/website/source/assets/images/enterprise-callout-bg.svg
@@ -1,21 +1,8 @@
-
-
-