From 32dad35f81c109f5b5c92be905b55a9ecdbc9bc0 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 5 Nov 2021 16:01:05 +0800 Subject: [PATCH 1/8] Add support for extendedLocation --- helpers/azure/extended_location.go | 15 ++++ .../kubernetes_cluster_other_resource_test.go | 63 +++++++++++++ .../containers/kubernetes_cluster_resource.go | 13 +++ .../validate/cassandra_cluster_id_test.go | 76 ++++++++++++++++ .../validate/cassandra_datacenter_id.go | 23 +++++ .../validate/cassandra_datacenter_id_test.go | 88 +++++++++++++++++++ .../loadbalancer/loadbalancer_resource.go | 13 +++ .../loadbalancer_resource_test.go | 40 +++++++++ .../network/network_interface_resource.go | 18 +++- .../network_interface_resource_test.go | 66 ++++++++++++++ .../services/network/public_ip_resource.go | 13 +++ .../network/public_ip_resource_test.go | 40 +++++++++ .../virtual_network_gateway_resource.go | 13 +++ .../virtual_network_gateway_resource_test.go | 65 ++++++++++++++ .../network/virtual_network_resource.go | 13 +++ .../network/virtual_network_resource_test.go | 43 +++++++++ .../storage/storage_account_resource.go | 12 +++ .../storage/storage_account_resource_test.go | 49 +++++++++++ .../docs/r/kubernetes_cluster.html.markdown | 2 + website/docs/r/lb.html.markdown | 1 + .../docs/r/network_interface.html.markdown | 2 + website/docs/r/public_ip.html.markdown | 2 + website/docs/r/storage_account.html.markdown | 2 + website/docs/r/virtual_network.html.markdown | 2 + .../r/virtual_network_gateway.html.markdown | 2 + 25 files changed, 674 insertions(+), 2 deletions(-) create mode 100644 helpers/azure/extended_location.go create mode 100644 internal/services/cosmos/validate/cassandra_cluster_id_test.go create mode 100644 internal/services/cosmos/validate/cassandra_datacenter_id.go create mode 100644 internal/services/cosmos/validate/cassandra_datacenter_id_test.go diff --git a/helpers/azure/extended_location.go b/helpers/azure/extended_location.go new file mode 100644 index 000000000000..a386b9794091 --- /dev/null +++ b/helpers/azure/extended_location.go @@ -0,0 +1,15 @@ +package azure + +import ( + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +func SchemaExtendedLocation() *pluginsdk.Schema { + return &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + } +} diff --git a/internal/services/containers/kubernetes_cluster_other_resource_test.go b/internal/services/containers/kubernetes_cluster_other_resource_test.go index 2f15af53e8a9..8e2116aa70aa 100644 --- a/internal/services/containers/kubernetes_cluster_other_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_other_resource_test.go @@ -15,6 +15,7 @@ var kubernetesOtherTests = map[string]func(t *testing.T){ "basicVMSS": testAccKubernetesCluster_basicVMSS, "requiresImport": testAccKubernetesCluster_requiresImport, "criticalAddonsTaint": testAccKubernetesCluster_criticalAddonsTaint, + "extendedLocation": testAccKubernetesCluster_extendedLocation, "kubeletAndLinuxOSConfig": testAccKubernetesCluster_kubeletAndLinuxOSConfig, "kubeletAndLinuxOSConfig_partial": testAccKubernetesCluster_kubeletAndLinuxOSConfigPartial, "linuxProfile": testAccKubernetesCluster_linuxProfile, @@ -811,6 +812,33 @@ func testAccKubernetesCluster_osSku(t *testing.T) { }) } +func TestAccKubernetesCluster_extendedLocation(t *testing.T) { + checkIfShouldRunTestsIndividually(t) + testAccKubernetesCluster_extendedLocation(t) +} + +func testAccKubernetesCluster_extendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") + r := KubernetesClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.extendedLocation(data, "Test1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.extendedLocation(data, "Test2"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (KubernetesClusterResource) basicAvailabilitySetConfig(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { @@ -2052,3 +2080,38 @@ resource "azurerm_kubernetes_cluster" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) } + +func (KubernetesClusterResource) extendedLocation(data acceptance.TestData, tag string) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-aks-%d" + location = "westus" +} + +resource "azurerm_kubernetes_cluster" "test" { + name = "acctestaks%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + dns_prefix = "acctestaks%d" + extended_location = "microsoftlosangeles1" + + default_node_pool { + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + } + + identity { + type = "SystemAssigned" + } + + tags = { + ENV = "%s" + } +} +`, data.RandomInteger, data.RandomInteger, data.RandomInteger, tag) +} diff --git a/internal/services/containers/kubernetes_cluster_resource.go b/internal/services/containers/kubernetes_cluster_resource.go index a74a367756ad..c69162683f91 100644 --- a/internal/services/containers/kubernetes_cluster_resource.go +++ b/internal/services/containers/kubernetes_cluster_resource.go @@ -83,6 +83,8 @@ func resourceKubernetesCluster() *pluginsdk.Resource { ExactlyOneOf: []string{"dns_prefix", "dns_prefix_private_cluster"}, }, + "extended_location": azure.SchemaExtendedLocation(), + "kubernetes_version": { Type: pluginsdk.TypeString, Optional: true, @@ -1080,6 +1082,13 @@ func resourceKubernetesClusterCreate(d *pluginsdk.ResourceData, meta interface{} Tags: tags.Expand(t), } + if v, ok := d.GetOk("extended_location"); ok { + parameters.ExtendedLocation = &containerservice.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: containerservice.ExtendedLocationTypesEdgeZone, + } + } + if v := d.Get("automatic_channel_upgrade").(string); v != "" { parameters.ManagedClusterProperties.AutoUpgradeProfile = &containerservice.ManagedClusterAutoUpgradeProfile{ UpgradeChannel: containerservice.UpgradeChannel(v), @@ -1560,6 +1569,10 @@ func resourceKubernetesClusterRead(d *pluginsdk.ResourceData, meta interface{}) d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + skuTier := string(containerservice.ManagedClusterSKUTierFree) if resp.Sku != nil && resp.Sku.Tier != "" { skuTier = string(resp.Sku.Tier) diff --git a/internal/services/cosmos/validate/cassandra_cluster_id_test.go b/internal/services/cosmos/validate/cassandra_cluster_id_test.go new file mode 100644 index 000000000000..d9e1dbb53974 --- /dev/null +++ b/internal/services/cosmos/validate/cassandra_cluster_id_test.go @@ -0,0 +1,76 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestCassandraClusterID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", + Valid: false, + }, + + { + // missing value for Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/cluster1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/CASSANDRACLUSTERS/CLUSTER1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := CassandraClusterID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/internal/services/cosmos/validate/cassandra_datacenter_id.go b/internal/services/cosmos/validate/cassandra_datacenter_id.go new file mode 100644 index 000000000000..d491b5754c54 --- /dev/null +++ b/internal/services/cosmos/validate/cassandra_datacenter_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" +) + +func CassandraDatacenterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.CassandraDatacenterID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/internal/services/cosmos/validate/cassandra_datacenter_id_test.go b/internal/services/cosmos/validate/cassandra_datacenter_id_test.go new file mode 100644 index 000000000000..2a9324eb15bc --- /dev/null +++ b/internal/services/cosmos/validate/cassandra_datacenter_id_test.go @@ -0,0 +1,88 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestCassandraDatacenterID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing CassandraClusterName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", + Valid: false, + }, + + { + // missing value for CassandraClusterName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/", + Valid: false, + }, + + { + // missing DataCenterName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/cluster1/", + Valid: false, + }, + + { + // missing value for DataCenterName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/cluster1/dataCenters/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/cluster1/dataCenters/dc1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/CASSANDRACLUSTERS/CLUSTER1/DATACENTERS/DC1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := CassandraDatacenterID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/internal/services/loadbalancer/loadbalancer_resource.go b/internal/services/loadbalancer/loadbalancer_resource.go index c9253b593a26..780a6429cdac 100644 --- a/internal/services/loadbalancer/loadbalancer_resource.go +++ b/internal/services/loadbalancer/loadbalancer_resource.go @@ -77,6 +77,8 @@ func resourceArmLoadBalancer() *pluginsdk.Resource { }, false), }, + "extended_location": azure.SchemaExtendedLocation(), + "frontend_ip_configuration": { Type: pluginsdk.TypeList, Optional: true, @@ -305,6 +307,13 @@ func resourceArmLoadBalancerCreateUpdate(d *pluginsdk.ResourceData, meta interfa LoadBalancerPropertiesFormat: &properties, } + if v, ok := d.GetOk("extended_location"); ok { + loadBalancer.ExtendedLocation = &network.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: network.ExtendedLocationTypesEdgeZone, + } + } + future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, loadBalancer) if err != nil { return fmt.Errorf("creating/updating Load Balancer %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) @@ -345,6 +354,10 @@ func resourceArmLoadBalancerRead(d *pluginsdk.ResourceData, meta interface{}) er d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + if sku := resp.Sku; sku != nil { d.Set("sku", string(sku.Name)) d.Set("sku_tier", string(sku.Tier)) diff --git a/internal/services/loadbalancer/loadbalancer_resource_test.go b/internal/services/loadbalancer/loadbalancer_resource_test.go index 9e64e041711b..f1ef4ae34dc2 100644 --- a/internal/services/loadbalancer/loadbalancer_resource_test.go +++ b/internal/services/loadbalancer/loadbalancer_resource_test.go @@ -261,6 +261,21 @@ func TestAccAzureRMLoadBalancer_PointToGatewayLB(t *testing.T) { }) } +func TestAccAzureRMLoadBalancer_extendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_lb", "test") + r := LoadBalancer{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.extendedLocation(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (r LoadBalancer) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { loadBalancerName := state.Attributes["name"] resourceGroup := state.Attributes["resource_group_name"] @@ -803,3 +818,28 @@ resource "azurerm_lb" "consumer" { } `, data.RandomInteger, data.Locations.Primary) } + +func (r LoadBalancer) extendedLocation(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-lb-%d" + location = "westus" +} + +resource "azurerm_lb" "test" { + name = "acctest-loadbalancer-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + extended_location = "microsoftlosangeles1" + + tags = { + Environment = "production" + Purpose = "AcceptanceTests" + } +} +`, data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/network/network_interface_resource.go b/internal/services/network/network_interface_resource.go index 1d8280e35bd8..54de643548b5 100644 --- a/internal/services/network/network_interface_resource.go +++ b/internal/services/network/network_interface_resource.go @@ -120,6 +120,8 @@ func resourceNetworkInterface() *pluginsdk.Resource { }, }, + "extended_location": azure.SchemaExtendedLocation(), + "dns_servers": { Type: pluginsdk.TypeList, Optional: true, @@ -266,6 +268,13 @@ func resourceNetworkInterfaceCreate(d *pluginsdk.ResourceData, meta interface{}) Tags: tags.Expand(t), } + if v, ok := d.GetOk("extended_location"); ok { + iface.ExtendedLocation = &network.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: network.ExtendedLocationTypesEdgeZone, + } + } + future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, iface) if err != nil { return fmt.Errorf("creating %s: %+v", id, err) @@ -307,8 +316,9 @@ func resourceNetworkInterfaceUpdate(d *pluginsdk.ResourceData, meta interface{}) location := azure.NormalizeLocation(d.Get("location").(string)) update := network.Interface{ - Name: utils.String(id.Name), - Location: utils.String(location), + Name: utils.String(id.Name), + Location: utils.String(location), + ExtendedLocation: existing.ExtendedLocation, InterfacePropertiesFormat: &network.InterfacePropertiesFormat{ EnableAcceleratedNetworking: utils.Bool(d.Get("enable_accelerated_networking").(bool)), DNSSettings: &network.InterfaceDNSSettings{}, @@ -404,6 +414,10 @@ func resourceNetworkInterfaceRead(d *pluginsdk.ResourceData, meta interface{}) e d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + if props := resp.InterfacePropertiesFormat; props != nil { primaryPrivateIPAddress := "" privateIPAddresses := make([]interface{}, 0) diff --git a/internal/services/network/network_interface_resource_test.go b/internal/services/network/network_interface_resource_test.go index 53f90d5a683a..f17abbcac9be 100644 --- a/internal/services/network/network_interface_resource_test.go +++ b/internal/services/network/network_interface_resource_test.go @@ -325,6 +325,28 @@ func TestAccNetworkInterface_pointToGatewayLB(t *testing.T) { }) } +func TestAccNetworkInterface_extendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_network_interface", "test") + r := NetworkInterfaceResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.extendedLocation(data, "Test1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.extendedLocation(data, "Test2"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (t NetworkInterfaceResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := parse.NetworkInterfaceID(state.ID) if err != nil { @@ -834,3 +856,47 @@ resource "azurerm_subnet" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } + +func (r NetworkInterfaceResource) extendedLocation(data acceptance.TestData, tag string) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "westus" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestvn-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + address_space = ["10.0.0.0/16"] +} + +resource "azurerm_subnet" "test" { + name = "internal" + 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 = "acctestni-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + extended_location = "microsoftlosangeles1" + + ip_configuration { + name = "primary" + subnet_id = azurerm_subnet.test.id + private_ip_address_allocation = "Dynamic" + } + + tags = { + ENV = "%s" + } +} +`, data.RandomInteger, data.RandomInteger, data.RandomInteger, tag) +} diff --git a/internal/services/network/public_ip_resource.go b/internal/services/network/public_ip_resource.go index 0d0538421bad..7c39a9878f20 100644 --- a/internal/services/network/public_ip_resource.go +++ b/internal/services/network/public_ip_resource.go @@ -79,6 +79,8 @@ func resourcePublicIp() *pluginsdk.Resource { }, false), }, + "extended_location": azure.SchemaExtendedLocation(), + "ip_version": { Type: pluginsdk.TypeString, Optional: true, @@ -274,6 +276,13 @@ func resourcePublicIpCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) e Zones: zones, } + if v, ok := d.GetOk("extended_location"); ok { + publicIp.ExtendedLocation = &network.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: network.ExtendedLocationTypesEdgeZone, + } + } + publicIpPrefixId, publicIpPrefixIdOk := d.GetOk("public_ip_prefix_id") if publicIpPrefixIdOk { @@ -367,6 +376,10 @@ func resourcePublicIpRead(d *pluginsdk.ResourceData, meta interface{}) error { d.Set("zones", zonesDeprecated) d.Set("location", location.NormalizeNilable(resp.Location)) + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + if sku := resp.Sku; sku != nil { d.Set("sku", string(sku.Name)) d.Set("sku_tier", string(sku.Tier)) diff --git a/internal/services/network/public_ip_resource_test.go b/internal/services/network/public_ip_resource_test.go index b19b282cf212..e2810880c89a 100644 --- a/internal/services/network/public_ip_resource_test.go +++ b/internal/services/network/public_ip_resource_test.go @@ -431,6 +431,21 @@ func TestAccPublicIpStatic_regionalTier(t *testing.T) { }) } +func TestAccPublicIpStatic_extendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_public_ip", "test") + r := PublicIPResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.extendedLocation(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (t PublicIPResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := parse.PublicIpAddressID(state.ID) if err != nil { @@ -919,3 +934,28 @@ resource "azurerm_public_ip" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } + +func (PublicIPResource) extendedLocation(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + + // There is no supported extended location in "West Europe" + location = "westus" +} + +resource "azurerm_public_ip" "test" { + name = "acctestpublicip-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + allocation_method = "Static" + sku = "Standard" + availability_zone = "No-Zone" + extended_location = "microsoftlosangeles1" +} +`, data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/network/virtual_network_gateway_resource.go b/internal/services/network/virtual_network_gateway_resource.go index b04ad27c485a..c0aa2bc2a2eb 100644 --- a/internal/services/network/virtual_network_gateway_resource.go +++ b/internal/services/network/virtual_network_gateway_resource.go @@ -73,6 +73,8 @@ func resourceVirtualNetworkGateway() *pluginsdk.Resource { }, true), }, + "extended_location": azure.SchemaExtendedLocation(), + "enable_bgp": { Type: pluginsdk.TypeBool, Optional: true, @@ -430,6 +432,13 @@ func resourceVirtualNetworkGatewayCreateUpdate(d *pluginsdk.ResourceData, meta i VirtualNetworkGatewayPropertiesFormat: properties, } + if v, ok := d.GetOk("extended_location"); ok { + gateway.ExtendedLocation = &network.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: network.ExtendedLocationTypesEdgeZone, + } + } + future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, gateway) if err != nil { return fmt.Errorf("Creating/Updating %s: %+v", id, err) @@ -469,6 +478,10 @@ func resourceVirtualNetworkGatewayRead(d *pluginsdk.ResourceData, meta interface d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + if gw := resp.VirtualNetworkGatewayPropertiesFormat; gw != nil { d.Set("type", string(gw.GatewayType)) d.Set("enable_bgp", gw.EnableBgp) diff --git a/internal/services/network/virtual_network_gateway_resource_test.go b/internal/services/network/virtual_network_gateway_resource_test.go index 7636908aaead..e35f8c423446 100644 --- a/internal/services/network/virtual_network_gateway_resource_test.go +++ b/internal/services/network/virtual_network_gateway_resource_test.go @@ -344,6 +344,21 @@ func TestAccVirtualNetworkGateway_customRoute(t *testing.T) { }) } +func TestAccVirtualNetworkGateway_extendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_virtual_network_gateway", "test") + r := VirtualNetworkGatewayResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.extendedLocation(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (t VirtualNetworkGatewayResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { gatewayName := state.Attributes["name"] resourceGroup := state.Attributes["resource_group_name"] @@ -1410,3 +1425,53 @@ resource "azurerm_virtual_network_gateway" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.Client().TenantID, data.Client().TenantID) } + +func (VirtualNetworkGatewayResource) extendedLocation(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "westus" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestvn-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + address_space = ["10.0.0.0/16"] +} + +resource "azurerm_subnet" "test" { + name = "GatewaySubnet" + resource_group_name = azurerm_resource_group.test.name + virtual_network_name = azurerm_virtual_network.test.name + address_prefix = "10.0.1.0/24" +} + +resource "azurerm_public_ip" "test" { + name = "acctestpip-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + allocation_method = "Dynamic" +} + +resource "azurerm_virtual_network_gateway" "test" { + name = "acctestvng-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + type = "Vpn" + vpn_type = "RouteBased" + sku = "Basic" + + ip_configuration { + public_ip_address_id = azurerm_public_ip.test.id + private_ip_address_allocation = "Dynamic" + subnet_id = azurerm_subnet.test.id + } +} +`, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/network/virtual_network_resource.go b/internal/services/network/virtual_network_resource.go index b95b37ea8a37..fffb12c6b2bd 100644 --- a/internal/services/network/virtual_network_resource.go +++ b/internal/services/network/virtual_network_resource.go @@ -64,6 +64,8 @@ func resourceVirtualNetwork() *pluginsdk.Resource { }, }, + "extended_location": azure.SchemaExtendedLocation(), + "bgp_community": { Type: pluginsdk.TypeString, Optional: true, @@ -186,6 +188,13 @@ func resourceVirtualNetworkCreateUpdate(d *pluginsdk.ResourceData, meta interfac Tags: tags.Expand(t), } + if v, ok := d.GetOk("extended_location"); ok { + vnet.ExtendedLocation = &network.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: network.ExtendedLocationTypesEdgeZone, + } + } + networkSecurityGroupNames := make([]string, 0) for _, subnet := range *vnet.VirtualNetworkPropertiesFormat.Subnets { if subnet.NetworkSecurityGroup != nil { @@ -255,6 +264,10 @@ func resourceVirtualNetworkRead(d *pluginsdk.ResourceData, meta interface{}) err d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + if props := resp.VirtualNetworkPropertiesFormat; props != nil { d.Set("guid", props.ResourceGUID) diff --git a/internal/services/network/virtual_network_resource_test.go b/internal/services/network/virtual_network_resource_test.go index 177f0b11083f..40f73496c9a3 100644 --- a/internal/services/network/virtual_network_resource_test.go +++ b/internal/services/network/virtual_network_resource_test.go @@ -202,6 +202,21 @@ func TestAccVirtualNetwork_bgpCommunity(t *testing.T) { }) } +func TestAccVirtualNetwork_extendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_virtual_network", "test") + r := VirtualNetworkResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.extendedLocation(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (t VirtualNetworkResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := parse.VirtualNetworkID(state.ID) if err != nil { @@ -450,3 +465,31 @@ resource "azurerm_virtual_network" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } + +func (VirtualNetworkResource) extendedLocation(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + + // There is no supported extended location in "West Europe" + location = "westus" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestvirtnet%d" + address_space = ["10.0.0.0/16"] + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + extended_location = "microsoftlosangeles1" + + subnet { + name = "subnet1" + address_prefix = "10.0.1.0/24" + } +} +`, data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/storage/storage_account_resource.go b/internal/services/storage/storage_account_resource.go index 2d4ae97ed717..5fb5eccb06f4 100644 --- a/internal/services/storage/storage_account_resource.go +++ b/internal/services/storage/storage_account_resource.go @@ -213,6 +213,8 @@ func resourceStorageAccount() *pluginsdk.Resource { Default: true, }, + "extended_location": azure.SchemaExtendedLocation(), + "min_tls_version": { Type: pluginsdk.TypeString, Optional: true, @@ -947,6 +949,13 @@ func resourceStorageAccountCreate(d *pluginsdk.ResourceData, meta interface{}) e }, } + if v, ok := d.GetOk("extended_location"); ok { + parameters.ExtendedLocation = &storage.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: storage.EdgeZone, + } + } + // For all Clouds except Public, China, and USGovernmentCloud, don't specify "allow_blob_public_access" and "min_tls_version" in request body. // https://github.com/hashicorp/terraform-provider-azurerm/issues/7812 // https://github.com/hashicorp/terraform-provider-azurerm/issues/8083 @@ -1564,6 +1573,9 @@ func resourceStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) err if location := resp.Location; location != nil { d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } d.Set("account_kind", resp.Kind) if sku := resp.Sku; sku != nil { diff --git a/internal/services/storage/storage_account_resource_test.go b/internal/services/storage/storage_account_resource_test.go index dccd12df4abc..dd794475e720 100644 --- a/internal/services/storage/storage_account_resource_test.go +++ b/internal/services/storage/storage_account_resource_test.go @@ -1046,6 +1046,28 @@ func TestAccStorageAccount_allowSharedKeyAccess(t *testing.T) { }) } +func TestAccStorageAccount_extendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_account", "test") + r := StorageAccountResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.extendedLocation(data, "Test1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.extendedLocation(data, "Test2"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (r StorageAccountResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := parse.StorageAccountID(state.ID) if err != nil { @@ -3048,3 +3070,30 @@ resource "azurerm_storage_account" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomString) } + +func (r StorageAccountResource) extendedLocation(data acceptance.TestData, tag string) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-storage-%d" + location = "westus" +} + +resource "azurerm_storage_account" "test" { + name = "unlikely23exst2acct%s" + resource_group_name = azurerm_resource_group.test.name + + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" + extended_location = "microsoftlosangeles1" + + tags = { + environment = "%s" + } +} +`, data.RandomInteger, data.RandomString, tag) +} diff --git a/website/docs/r/kubernetes_cluster.html.markdown b/website/docs/r/kubernetes_cluster.html.markdown index ff03824537fc..df04f4b5d212 100644 --- a/website/docs/r/kubernetes_cluster.html.markdown +++ b/website/docs/r/kubernetes_cluster.html.markdown @@ -96,6 +96,8 @@ In addition, one of either `identity` or `service_principal` blocks must be spec * `disk_encryption_set_id` - (Optional) The ID of the Disk Encryption Set which should be used for the Nodes and Volumes. More information [can be found in the documentation](https://docs.microsoft.com/en-us/azure/aks/azure-disk-customer-managed-keys). +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `identity` - (Optional) An `identity` block as defined below. One of either `identity` or `service_principal` must be specified. !> **NOTE:** A migration scenario from `service_principal` to `identity` is supported. When upgrading `service_principal` to `identity`, your cluster's control plane and addon pods will switch to use managed identity, but the kubelets will keep using your configured `service_principal` until you upgrade your Node Pool. diff --git a/website/docs/r/lb.html.markdown b/website/docs/r/lb.html.markdown index c56f56dff6e1..693717edeb72 100644 --- a/website/docs/r/lb.html.markdown +++ b/website/docs/r/lb.html.markdown @@ -44,6 +44,7 @@ The following arguments are supported: * `name` - (Required) Specifies the name of the Load Balancer. * `resource_group_name` - (Required) The name of the Resource Group in which to create the Load Balancer. * `location` - (Required) Specifies the supported Azure Region where the Load Balancer should be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. * `frontend_ip_configuration` - (Optional) One or multiple `frontend_ip_configuration` blocks as documented below. * `sku` - (Optional) The SKU of the Azure Load Balancer. Accepted values are `Basic`, `Standard` and `Gateway`. Defaults to `Basic`. diff --git a/website/docs/r/network_interface.html.markdown b/website/docs/r/network_interface.html.markdown index 193cf316dc41..9271289222d3 100644 --- a/website/docs/r/network_interface.html.markdown +++ b/website/docs/r/network_interface.html.markdown @@ -60,6 +60,8 @@ The following arguments are supported: --- +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `dns_servers` - (Optional) A list of IP Addresses defining the DNS Servers which should be used for this Network Interface. -> **Note:** Configuring DNS Servers on the Network Interface will override the DNS Servers defined on the Virtual Network. diff --git a/website/docs/r/public_ip.html.markdown b/website/docs/r/public_ip.html.markdown index 35d6a1f2689f..e72da321bea6 100644 --- a/website/docs/r/public_ip.html.markdown +++ b/website/docs/r/public_ip.html.markdown @@ -42,6 +42,8 @@ The following arguments are supported: * `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `sku` - (Optional) The SKU of the Public IP. Accepted values are `Basic` and `Standard`. Defaults to `Basic`. -> **Note** Public IP Standard SKUs require `allocation_method` to be set to `Static`. diff --git a/website/docs/r/storage_account.html.markdown b/website/docs/r/storage_account.html.markdown index 3780c29cbe3c..74a1b688909c 100644 --- a/website/docs/r/storage_account.html.markdown +++ b/website/docs/r/storage_account.html.markdown @@ -97,6 +97,8 @@ The following arguments are supported: * `enable_https_traffic_only` - (Optional) Boolean flag which forces HTTPS if enabled, see [here](https://docs.microsoft.com/en-us/azure/storage/storage-require-secure-transfer/) for more information. Defaults to `true`. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `min_tls_version` - (Optional) The minimum supported TLS version for the storage account. Possible values are `TLS1_0`, `TLS1_1`, and `TLS1_2`. Defaults to `TLS1_0` for new storage accounts. -> **NOTE:** At this time `min_tls_version` is only supported in the Public Cloud, China Cloud, and US Government Cloud. diff --git a/website/docs/r/virtual_network.html.markdown b/website/docs/r/virtual_network.html.markdown index cc6669a75a82..3e72653c057c 100644 --- a/website/docs/r/virtual_network.html.markdown +++ b/website/docs/r/virtual_network.html.markdown @@ -83,6 +83,8 @@ The following arguments are supported: * `location` - (Required) The location/region where the virtual network is created. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `bgp_community` - (Optional) The BGP community attribute in format `:`. -> **NOTE** The `as-number` segment is the Microsoft ASN, which is always `12076` for now. diff --git a/website/docs/r/virtual_network_gateway.html.markdown b/website/docs/r/virtual_network_gateway.html.markdown index 888260490118..b2b0e562b121 100644 --- a/website/docs/r/virtual_network_gateway.html.markdown +++ b/website/docs/r/virtual_network_gateway.html.markdown @@ -120,6 +120,8 @@ The following arguments are supported: * `vpn_type` - (Optional) The routing type of the Virtual Network Gateway. Valid options are `RouteBased` or `PolicyBased`. Defaults to `RouteBased`. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `enable_bgp` - (Optional) If `true`, BGP (Border Gateway Protocol) will be enabled for this Virtual Network Gateway. Defaults to `false`. From e975cf673c31b959046d62435c04d31ffe34fad0 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 5 Nov 2021 22:19:56 +0800 Subject: [PATCH 2/8] update code --- .../network/virtual_network_gateway_resource_test.go | 3 ++- internal/services/storage/storage_account_resource_test.go | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/services/network/virtual_network_gateway_resource_test.go b/internal/services/network/virtual_network_gateway_resource_test.go index e35f8c423446..acac1b24f311 100644 --- a/internal/services/network/virtual_network_gateway_resource_test.go +++ b/internal/services/network/virtual_network_gateway_resource_test.go @@ -1462,10 +1462,11 @@ resource "azurerm_virtual_network_gateway" "test" { name = "acctestvng-%d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name + extended_location = "microsoftlosangeles1" type = "Vpn" vpn_type = "RouteBased" - sku = "Basic" + sku = "Standard" ip_configuration { public_ip_address_id = azurerm_public_ip.test.id diff --git a/internal/services/storage/storage_account_resource_test.go b/internal/services/storage/storage_account_resource_test.go index dd794475e720..bf31bf7204e9 100644 --- a/internal/services/storage/storage_account_resource_test.go +++ b/internal/services/storage/storage_account_resource_test.go @@ -3083,11 +3083,10 @@ resource "azurerm_resource_group" "test" { } resource "azurerm_storage_account" "test" { - name = "unlikely23exst2acct%s" - resource_group_name = azurerm_resource_group.test.name - + name = "unlikely23exst2acct%s" + resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location - account_tier = "Standard" + account_tier = "Premium" account_replication_type = "LRS" extended_location = "microsoftlosangeles1" From a20c3728f27d1d65a31b2275b6c16e7f427e9e58 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Thu, 11 Nov 2021 17:06:00 +0800 Subject: [PATCH 3/8] update code --- .../compute/linux_virtual_machine_resource.go | 13 +++ ...nux_virtual_machine_resource_other_test.go | 86 +++++++++++++++++++ ...l_machine_scale_set_other_resource_test.go | 82 ++++++++++++++++++ ...inux_virtual_machine_scale_set_resource.go | 13 +++ .../services/compute/managed_disk_resource.go | 13 +++ .../compute/managed_disk_resource_test.go | 43 ++++++++++ .../windows_virtual_machine_resource.go | 13 +++ ...ows_virtual_machine_resource_other_test.go | 85 ++++++++++++++++++ ...l_machine_scale_set_other_resource_test.go | 77 +++++++++++++++++ ...dows_virtual_machine_scale_set_resource.go | 13 +++ .../r/linux_virtual_machine.html.markdown | 2 + ...ux_virtual_machine_scale_set.html.markdown | 2 + website/docs/r/managed_disk.html.markdown | 2 + .../r/windows_virtual_machine.html.markdown | 2 + ...ws_virtual_machine_scale_set.html.markdown | 2 + 15 files changed, 448 insertions(+) diff --git a/internal/services/compute/linux_virtual_machine_resource.go b/internal/services/compute/linux_virtual_machine_resource.go index bf602d20dbf4..e2f7c771e54a 100644 --- a/internal/services/compute/linux_virtual_machine_resource.go +++ b/internal/services/compute/linux_virtual_machine_resource.go @@ -166,6 +166,8 @@ func resourceLinuxVirtualMachine() *pluginsdk.Resource { }, false), }, + "extended_location": azure.SchemaExtendedLocation(), + "extensions_time_budget": { Type: pluginsdk.TypeString, Optional: true, @@ -425,6 +427,13 @@ func resourceLinuxVirtualMachineCreate(d *pluginsdk.ResourceData, meta interface Tags: tags.Expand(t), } + if v, ok := d.GetOk("extended_location"); ok { + params.ExtendedLocation = &compute.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: compute.ExtendedLocationTypesEdgeZone, + } + } + if v, ok := d.GetOk("patch_mode"); ok { params.VirtualMachineProperties.OsProfile.LinuxConfiguration.PatchSettings = &compute.LinuxPatchSettings{ PatchMode: compute.LinuxVMGuestPatchMode(v.(string)), @@ -568,6 +577,10 @@ func resourceLinuxVirtualMachineRead(d *pluginsdk.ResourceData, meta interface{} d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + identity, err := flattenVirtualMachineIdentity(resp.Identity) if err != nil { return err diff --git a/internal/services/compute/linux_virtual_machine_resource_other_test.go b/internal/services/compute/linux_virtual_machine_resource_other_test.go index b89e20f22b49..a120e72bbcb1 100644 --- a/internal/services/compute/linux_virtual_machine_resource_other_test.go +++ b/internal/services/compute/linux_virtual_machine_resource_other_test.go @@ -572,6 +572,21 @@ func TestAccLinuxVirtualMachine_otherGracefulShutdownEnabled(t *testing.T) { }) } +func TestAccLinuxVirtualMachine_otherExtendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine", "test") + r := LinuxVirtualMachineResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.otherExtendedLocation(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (r LinuxVirtualMachineResource) otherAllowExtensionOperationsDefault(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -1796,3 +1811,74 @@ resource "azurerm_linux_virtual_machine" "test" { } `, gracefulShutdown, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger) } + +func (r LinuxVirtualMachineResource) otherExtendedLocation(data acceptance.TestData) string { + return fmt.Sprintf(` +# note: whilst these aren't used in all tests, it saves us redefining these everywhere +locals { + first_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+wWK73dCr+jgQOAxNsHAnNNNMEMWOHYEccp6wJm2gotpr9katuF/ZAdou5AaW1C61slRkHRkpRRX9FA9CYBiitZgvCCz+3nWNN7l/Up54Zps/pHWGZLHNJZRYyAB6j5yVLMVHIHriY49d/GZTZVNB8GoJv9Gakwc/fuEZYYl4YDFiGMBP///TzlI4jhiJzjKnEvqPFki5p2ZRJqcbCiF4pJrxUQR/RXqVFQdbRLZgYfJ8xGB878RENq3yQ39d8dVOkq4edbkzwcUmwwwkYVPIoDGsYLaRHnG+To7FvMeyO7xDVQkMKzopTQV8AuKpyvpqu0a9pWOMaiCyDytO7GGN you@me.com" + second_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0/NDMj2wG6bSa6jbn6E3LYlUsYiWMp1CQ2sGAijPALW6OrSu30lz7nKpoh8Qdw7/A4nAJgweI5Oiiw5/BOaGENM70Go+VM8LQMSxJ4S7/8MIJEZQp5HcJZ7XDTcEwruknrd8mllEfGyFzPvJOx6QAQocFhXBW6+AlhM3gn/dvV5vdrO8ihjET2GoDUqXPYC57ZuY+/Fz6W3KV8V97BvNUhpY5yQrP5VpnyvvXNFQtzDfClTvZFPuoHQi3/KYPi6O0FSD74vo8JOBZZY09boInPejkm9fvHQqfh0bnN7B6XJoUwC1Qprrx+XIy7ust5AEn5XL7d4lOvcR14MxDDKEp you@me.com" +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "westus" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestnw-%d" + address_space = ["10.0.0.0/16"] + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_subnet" "test" { + name = "internal" + 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 = "acctestnic-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + ip_configuration { + name = "internal" + subnet_id = azurerm_subnet.test.id + private_ip_address_allocation = "Dynamic" + } +} + +resource "azurerm_linux_virtual_machine" "test" { + name = "acctestVM-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + size = "Standard_D2s_v3" + admin_username = "adminuser" + extended_location = "microsoftlosangeles1" + + network_interface_ids = [ + azurerm_network_interface.test.id, + ] + + admin_ssh_key { + username = "adminuser" + public_key = local.first_public_key + } + + os_disk { + caching = "ReadWrite" + storage_account_type = "Premium_LRS" + } + + source_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "18.04-LTS" + version = "latest" + } +} +`, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go b/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go index bef95bcd9b95..59cc20b6d04c 100644 --- a/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go +++ b/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go @@ -638,6 +638,23 @@ func TestAccLinuxVirtualMachineScaleSet_otherHealthProbeUpdate(t *testing.T) { }) } +func TestAccLinuxVirtualMachineScaleSet_otherExtendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test") + r := LinuxVirtualMachineScaleSetResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.otherExtendedLocation(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep( + "admin_password", + ), + }) +} + func (r LinuxVirtualMachineScaleSetResource) otherBootDiagnostics(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -2465,3 +2482,68 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" { } `, r.template(data), data.RandomInteger) } + +func (r LinuxVirtualMachineScaleSetResource) otherExtendedLocation(data acceptance.TestData) string { + return fmt.Sprintf(` +# note: whilst these aren't used in all tests, it saves us redefining these everywhere +locals { + first_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+wWK73dCr+jgQOAxNsHAnNNNMEMWOHYEccp6wJm2gotpr9katuF/ZAdou5AaW1C61slRkHRkpRRX9FA9CYBiitZgvCCz+3nWNN7l/Up54Zps/pHWGZLHNJZRYyAB6j5yVLMVHIHriY49d/GZTZVNB8GoJv9Gakwc/fuEZYYl4YDFiGMBP///TzlI4jhiJzjKnEvqPFki5p2ZRJqcbCiF4pJrxUQR/RXqVFQdbRLZgYfJ8xGB878RENq3yQ39d8dVOkq4edbkzwcUmwwwkYVPIoDGsYLaRHnG+To7FvMeyO7xDVQkMKzopTQV8AuKpyvpqu0a9pWOMaiCyDytO7GGN you@me.com" + second_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0/NDMj2wG6bSa6jbn6E3LYlUsYiWMp1CQ2sGAijPALW6OrSu30lz7nKpoh8Qdw7/A4nAJgweI5Oiiw5/BOaGENM70Go+VM8LQMSxJ4S7/8MIJEZQp5HcJZ7XDTcEwruknrd8mllEfGyFzPvJOx6QAQocFhXBW6+AlhM3gn/dvV5vdrO8ihjET2GoDUqXPYC57ZuY+/Fz6W3KV8V97BvNUhpY5yQrP5VpnyvvXNFQtzDfClTvZFPuoHQi3/KYPi6O0FSD74vo8JOBZZY09boInPejkm9fvHQqfh0bnN7B6XJoUwC1Qprrx+XIy7ust5AEn5XL7d4lOvcR14MxDDKEp you@me.com" +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "westus" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestnw-%d" + address_space = ["10.0.0.0/16"] + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_subnet" "test" { + name = "internal" + resource_group_name = azurerm_resource_group.test.name + virtual_network_name = azurerm_virtual_network.test.name + address_prefixes = ["10.0.2.0/24"] +} + +resource "azurerm_linux_virtual_machine_scale_set" "test" { + name = "acctestvmss-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku = "Standard_D2s_v3" + instances = 1 + admin_username = "adminuser" + admin_password = "P@ssword1234!" + extended_location = "microsoftlosangeles1" + + disable_password_authentication = false + + source_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "18.04-LTS" + version = "latest" + } + + os_disk { + storage_account_type = "Premium_LRS" + caching = "ReadWrite" + } + + network_interface { + name = "example" + primary = true + + ip_configuration { + name = "internal" + primary = true + subnet_id = azurerm_subnet.test.id + } + } +} +`, data.RandomInteger, data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/compute/linux_virtual_machine_scale_set_resource.go b/internal/services/compute/linux_virtual_machine_scale_set_resource.go index 5536f99b999a..4f32d8724443 100644 --- a/internal/services/compute/linux_virtual_machine_scale_set_resource.go +++ b/internal/services/compute/linux_virtual_machine_scale_set_resource.go @@ -141,6 +141,8 @@ func resourceLinuxVirtualMachineScaleSet() *pluginsdk.Resource { }, false), }, + "extended_location": azure.SchemaExtendedLocation(), + "extension": VirtualMachineScaleSetExtensionsSchema(), "extensions_time_budget": { @@ -508,6 +510,13 @@ func resourceLinuxVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta i Zones: zones, } + if v, ok := d.GetOk("extended_location"); ok { + props.ExtendedLocation = &compute.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: compute.ExtendedLocationTypesEdgeZone, + } + } + if v, ok := d.GetOk("platform_fault_domain_count"); ok { props.VirtualMachineScaleSetProperties.PlatformFaultDomainCount = utils.Int32(int32(v.(int))) } @@ -884,6 +893,10 @@ func resourceLinuxVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, meta int d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + var skuName *string var instances int if resp.Sku != nil { diff --git a/internal/services/compute/managed_disk_resource.go b/internal/services/compute/managed_disk_resource.go index eb60521f7d36..388455ddbb45 100644 --- a/internal/services/compute/managed_disk_resource.go +++ b/internal/services/compute/managed_disk_resource.go @@ -158,6 +158,8 @@ func resourceManagedDisk() *pluginsdk.Resource { "encryption_settings": encryptionSettingsSchema(), + "extended_location": azure.SchemaExtendedLocation(), + "network_access_policy": { Type: pluginsdk.TypeString, Optional: true, @@ -367,6 +369,13 @@ func resourceManagedDiskCreate(d *pluginsdk.ResourceData, meta interface{}) erro Zones: zones, } + if v, ok := d.GetOk("extended_location"); ok { + createDisk.ExtendedLocation = &compute.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: compute.ExtendedLocationTypesEdgeZone, + } + } + future, err := client.CreateOrUpdate(ctx, resourceGroup, name, createDisk) if err != nil { return fmt.Errorf("creating/updating Managed Disk %q (Resource Group %q): %+v", name, resourceGroup, err) @@ -662,6 +671,10 @@ func resourceManagedDiskRead(d *pluginsdk.ResourceData, meta interface{}) error d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + if sku := resp.Sku; sku != nil { d.Set("storage_account_type", string(sku.Name)) } diff --git a/internal/services/compute/managed_disk_resource_test.go b/internal/services/compute/managed_disk_resource_test.go index 8d9beb317b40..8bd45451c1bb 100644 --- a/internal/services/compute/managed_disk_resource_test.go +++ b/internal/services/compute/managed_disk_resource_test.go @@ -475,6 +475,21 @@ func TestAccAzureRMManagedDisk_create_withTrustedLaunchEnabled(t *testing.T) { }) } +func TestAccManagedDisk_extendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_managed_disk", "test") + r := ManagedDiskResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.extendedLocation(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (ManagedDiskResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := parse.ManagedDiskID(state.ID) if err != nil { @@ -1469,3 +1484,31 @@ resource "azurerm_managed_disk" "test" { } `, data.Locations.Primary, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } + +func (ManagedDiskResource) extendedLocation(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "westus" +} + +resource "azurerm_managed_disk" "test" { + name = "acctestd-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + storage_account_type = "Premium_LRS" + create_option = "Empty" + disk_size_gb = "1" + extended_location = "microsoftlosangeles1" + + tags = { + environment = "acctest" + cost-center = "ops" + } +} +`, data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/compute/windows_virtual_machine_resource.go b/internal/services/compute/windows_virtual_machine_resource.go index bb155f776a82..cd1f0d05d1c4 100644 --- a/internal/services/compute/windows_virtual_machine_resource.go +++ b/internal/services/compute/windows_virtual_machine_resource.go @@ -167,6 +167,8 @@ func resourceWindowsVirtualMachine() *pluginsdk.Resource { }, false), }, + "extended_location": azure.SchemaExtendedLocation(), + "extensions_time_budget": { Type: pluginsdk.TypeString, Optional: true, @@ -448,6 +450,13 @@ func resourceWindowsVirtualMachineCreate(d *pluginsdk.ResourceData, meta interfa Tags: tags.Expand(t), } + if v, ok := d.GetOk("extended_location"); ok { + params.ExtendedLocation = &compute.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: compute.ExtendedLocationTypesEdgeZone, + } + } + if !provisionVMAgent && allowExtensionOperations { return fmt.Errorf("`allow_extension_operations` cannot be set to `true` when `provision_vm_agent` is set to `false`") } @@ -588,6 +597,10 @@ func resourceWindowsVirtualMachineRead(d *pluginsdk.ResourceData, meta interface d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + identity, err := flattenVirtualMachineIdentity(resp.Identity) if err != nil { return err diff --git a/internal/services/compute/windows_virtual_machine_resource_other_test.go b/internal/services/compute/windows_virtual_machine_resource_other_test.go index cad4bc8b5d28..357c5e3560ef 100644 --- a/internal/services/compute/windows_virtual_machine_resource_other_test.go +++ b/internal/services/compute/windows_virtual_machine_resource_other_test.go @@ -1016,6 +1016,23 @@ func TestAccWindowsVirtualMachine_otherGracefulShutdownEnabled(t *testing.T) { }) } +func TestAccWindowsVirtualMachine_otherExtendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine", "test") + r := WindowsVirtualMachineResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.otherExtendedLocation(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep( + "admin_password", + ), + }) +} + func (r WindowsVirtualMachineResource) otherAdditionalUnattendContent(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -2502,3 +2519,71 @@ resource "azurerm_windows_virtual_machine" "test" { } `, data.RandomString, gracefulShutdown, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) } + +func (r WindowsVirtualMachineResource) otherExtendedLocation(data acceptance.TestData) string { + return fmt.Sprintf(` +locals { + vm_name = "acctestvm%s" +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "westus" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestnw-%d" + address_space = ["10.0.0.0/16"] + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_subnet" "test" { + name = "internal" + 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 = "acctestnic-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + ip_configuration { + name = "internal" + subnet_id = azurerm_subnet.test.id + private_ip_address_allocation = "Dynamic" + } +} + +resource "azurerm_windows_virtual_machine" "test" { + name = local.vm_name + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + size = "Standard_D2s_v3" + admin_username = "adminuser" + admin_password = "P@$$w0rd1234!" + extended_location = "microsoftlosangeles1" + + network_interface_ids = [ + azurerm_network_interface.test.id, + ] + + os_disk { + caching = "ReadWrite" + storage_account_type = "Premium_LRS" + } + + source_image_reference { + publisher = "MicrosoftWindowsServer" + offer = "WindowsServer" + sku = "2016-Datacenter" + version = "latest" + } + + enable_automatic_updates = false + patch_mode = "Manual" +} +`, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go b/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go index 471a15e5daae..38a50c038ca0 100644 --- a/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go +++ b/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go @@ -782,6 +782,23 @@ func TestAccWindowsVirtualMachineScaleSet_otherLicenseTypeUpdated(t *testing.T) }) } +func TestAccWindowsVirtualMachineScaleSet_otherExtendedLocation(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine_scale_set", "test") + r := WindowsVirtualMachineScaleSetResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.otherExtendedLocation(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep( + "admin_password", + ), + }) +} + func (WindowsVirtualMachineScaleSetResource) otherAdditionalUnattendContent(data acceptance.TestData) string { template := WindowsVirtualMachineScaleSetResource{}.template(data) return fmt.Sprintf(` @@ -2967,3 +2984,63 @@ resource "azurerm_windows_virtual_machine_scale_set" "test" { } `, r.template(data), licenseType) } + +func (r WindowsVirtualMachineScaleSetResource) otherExtendedLocation(data acceptance.TestData) string { + return fmt.Sprintf(` +locals { + vm_name = "%s" +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "westus" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestnw-%d" + address_space = ["10.0.0.0/16"] + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_subnet" "test" { + name = "internal" + resource_group_name = azurerm_resource_group.test.name + virtual_network_name = azurerm_virtual_network.test.name + address_prefixes = ["10.0.2.0/24"] +} + +resource "azurerm_windows_virtual_machine_scale_set" "test" { + name = local.vm_name + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku = "Standard_D2s_v3" + instances = 1 + admin_username = "adminuser" + admin_password = "P@ssword1234!" + + source_image_reference { + publisher = "MicrosoftWindowsServer" + offer = "WindowsServer" + sku = "2019-Datacenter" + version = "latest" + } + + os_disk { + storage_account_type = "Premium_LRS" + caching = "ReadWrite" + } + + network_interface { + name = "example" + primary = true + + ip_configuration { + name = "internal" + primary = true + subnet_id = azurerm_subnet.test.id + } + } +} +`, r.vmName(data), data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/compute/windows_virtual_machine_scale_set_resource.go b/internal/services/compute/windows_virtual_machine_scale_set_resource.go index 103713cf1347..cf115f231f75 100644 --- a/internal/services/compute/windows_virtual_machine_scale_set_resource.go +++ b/internal/services/compute/windows_virtual_machine_scale_set_resource.go @@ -142,6 +142,8 @@ func resourceWindowsVirtualMachineScaleSet() *pluginsdk.Resource { }, false), }, + "extended_location": azure.SchemaExtendedLocation(), + "extension": VirtualMachineScaleSetExtensionsSchema(), "extensions_time_budget": { @@ -536,6 +538,13 @@ func resourceWindowsVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta Zones: zones, } + if v, ok := d.GetOk("extended_location"); ok { + props.ExtendedLocation = &compute.ExtendedLocation{ + Name: utils.String(v.(string)), + Type: compute.ExtendedLocationTypesEdgeZone, + } + } + if v, ok := d.GetOk("platform_fault_domain_count"); ok { props.VirtualMachineScaleSetProperties.PlatformFaultDomainCount = utils.Int32(int32(v.(int))) } @@ -923,6 +932,10 @@ func resourceWindowsVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, meta i d.Set("location", azure.NormalizeLocation(*location)) } + if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { + d.Set("extended_location", resp.ExtendedLocation.Name) + } + var skuName *string var instances int if resp.Sku != nil { diff --git a/website/docs/r/linux_virtual_machine.html.markdown b/website/docs/r/linux_virtual_machine.html.markdown index bcdbef913978..e4afa7617dc4 100644 --- a/website/docs/r/linux_virtual_machine.html.markdown +++ b/website/docs/r/linux_virtual_machine.html.markdown @@ -148,6 +148,8 @@ The following arguments are supported: -> **NOTE:** This can only be configured when `priority` is set to `Spot`. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `extensions_time_budget` - (Optional) Specifies the duration allocated for all extensions to start. The time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in ISO 8601 format. Defaults to 90 minutes (`PT1H30M`). * `identity` - (Optional) An `identity` block as defined below. diff --git a/website/docs/r/linux_virtual_machine_scale_set.html.markdown b/website/docs/r/linux_virtual_machine_scale_set.html.markdown index ef8d320d2200..72430778673d 100644 --- a/website/docs/r/linux_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/linux_virtual_machine_scale_set.html.markdown @@ -144,6 +144,8 @@ The following arguments are supported: * `encryption_at_host_enabled` - (Optional) Should all of the disks (including the temp disk) attached to this Virtual Machine be encrypted by enabling Encryption at Host? +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `extension` - (Optional) One or more `extension` blocks as defined below * `extensions_time_budget` - (Optional) Specifies the duration allocated for all extensions to start. The time duration should be between `15` minutes and `120` minutes (inclusive) and should be specified in ISO 8601 format. Defaults to `90` minutes (`PT1H30M`). diff --git a/website/docs/r/managed_disk.html.markdown b/website/docs/r/managed_disk.html.markdown index 9444e69e5175..6cbcf2939f07 100644 --- a/website/docs/r/managed_disk.html.markdown +++ b/website/docs/r/managed_disk.html.markdown @@ -107,6 +107,8 @@ The following arguments are supported: * `encryption_settings` - (Optional) A `encryption_settings` block as defined below. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `image_reference_id` - (Optional) ID of an existing platform/marketplace disk image to copy when `create_option` is `FromImage`. * `logical_sector_size` - (Optional) Logical Sector Size. Possible values are: `512` and `4096`. Defaults to `4096`. Changing this forces a new resource to be created. diff --git a/website/docs/r/windows_virtual_machine.html.markdown b/website/docs/r/windows_virtual_machine.html.markdown index 07a3675ce684..dd514f977546 100644 --- a/website/docs/r/windows_virtual_machine.html.markdown +++ b/website/docs/r/windows_virtual_machine.html.markdown @@ -133,6 +133,8 @@ The following arguments are supported: -> **NOTE:** This can only be configured when `priority` is set to `Spot`. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `extensions_time_budget` - (Optional) Specifies the duration allocated for all extensions to start. The time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in ISO 8601 format. Defaults to 90 minutes (`PT1H30M`). * `identity` - (Optional) An `identity` block as defined below. diff --git a/website/docs/r/windows_virtual_machine_scale_set.html.markdown b/website/docs/r/windows_virtual_machine_scale_set.html.markdown index 1ab2d32253fc..f132979e8cf1 100644 --- a/website/docs/r/windows_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/windows_virtual_machine_scale_set.html.markdown @@ -132,6 +132,8 @@ The following arguments are supported: * `encryption_at_host_enabled` - (Optional) Should all of the disks (including the temp disk) attached to this Virtual Machine be encrypted by enabling Encryption at Host? +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. + * `extension` - (Optional) One or more `extension` blocks as defined below * `extensions_time_budget` - (Optional) Specifies the duration allocated for all extensions to start. The time duration should be between `15` minutes and `120` minutes (inclusive) and should be specified in ISO 8601 format. Defaults to `90` minutes (`PT1H30M`). From 4ae661a341ab7eeada8958ed9c63ddf1ed8fa191 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 12 Nov 2021 08:59:56 +0800 Subject: [PATCH 4/8] update code --- .../kubernetes_cluster_other_resource_test.go | 63 ------------------- .../containers/kubernetes_cluster_resource.go | 13 ---- .../docs/r/kubernetes_cluster.html.markdown | 2 - 3 files changed, 78 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_other_resource_test.go b/internal/services/containers/kubernetes_cluster_other_resource_test.go index 8e2116aa70aa..2f15af53e8a9 100644 --- a/internal/services/containers/kubernetes_cluster_other_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_other_resource_test.go @@ -15,7 +15,6 @@ var kubernetesOtherTests = map[string]func(t *testing.T){ "basicVMSS": testAccKubernetesCluster_basicVMSS, "requiresImport": testAccKubernetesCluster_requiresImport, "criticalAddonsTaint": testAccKubernetesCluster_criticalAddonsTaint, - "extendedLocation": testAccKubernetesCluster_extendedLocation, "kubeletAndLinuxOSConfig": testAccKubernetesCluster_kubeletAndLinuxOSConfig, "kubeletAndLinuxOSConfig_partial": testAccKubernetesCluster_kubeletAndLinuxOSConfigPartial, "linuxProfile": testAccKubernetesCluster_linuxProfile, @@ -812,33 +811,6 @@ func testAccKubernetesCluster_osSku(t *testing.T) { }) } -func TestAccKubernetesCluster_extendedLocation(t *testing.T) { - checkIfShouldRunTestsIndividually(t) - testAccKubernetesCluster_extendedLocation(t) -} - -func testAccKubernetesCluster_extendedLocation(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") - r := KubernetesClusterResource{} - - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.extendedLocation(data, "Test1"), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.ImportStep(), - { - Config: r.extendedLocation(data, "Test2"), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.ImportStep(), - }) -} - func (KubernetesClusterResource) basicAvailabilitySetConfig(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { @@ -2080,38 +2052,3 @@ resource "azurerm_kubernetes_cluster" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) } - -func (KubernetesClusterResource) extendedLocation(data acceptance.TestData, tag string) string { - return fmt.Sprintf(` -provider "azurerm" { - features {} -} - -resource "azurerm_resource_group" "test" { - name = "acctestRG-aks-%d" - location = "westus" -} - -resource "azurerm_kubernetes_cluster" "test" { - name = "acctestaks%d" - location = azurerm_resource_group.test.location - resource_group_name = azurerm_resource_group.test.name - dns_prefix = "acctestaks%d" - extended_location = "microsoftlosangeles1" - - default_node_pool { - name = "default" - node_count = 1 - vm_size = "Standard_DS2_v2" - } - - identity { - type = "SystemAssigned" - } - - tags = { - ENV = "%s" - } -} -`, data.RandomInteger, data.RandomInteger, data.RandomInteger, tag) -} diff --git a/internal/services/containers/kubernetes_cluster_resource.go b/internal/services/containers/kubernetes_cluster_resource.go index c69162683f91..a74a367756ad 100644 --- a/internal/services/containers/kubernetes_cluster_resource.go +++ b/internal/services/containers/kubernetes_cluster_resource.go @@ -83,8 +83,6 @@ func resourceKubernetesCluster() *pluginsdk.Resource { ExactlyOneOf: []string{"dns_prefix", "dns_prefix_private_cluster"}, }, - "extended_location": azure.SchemaExtendedLocation(), - "kubernetes_version": { Type: pluginsdk.TypeString, Optional: true, @@ -1082,13 +1080,6 @@ func resourceKubernetesClusterCreate(d *pluginsdk.ResourceData, meta interface{} Tags: tags.Expand(t), } - if v, ok := d.GetOk("extended_location"); ok { - parameters.ExtendedLocation = &containerservice.ExtendedLocation{ - Name: utils.String(v.(string)), - Type: containerservice.ExtendedLocationTypesEdgeZone, - } - } - if v := d.Get("automatic_channel_upgrade").(string); v != "" { parameters.ManagedClusterProperties.AutoUpgradeProfile = &containerservice.ManagedClusterAutoUpgradeProfile{ UpgradeChannel: containerservice.UpgradeChannel(v), @@ -1569,10 +1560,6 @@ func resourceKubernetesClusterRead(d *pluginsdk.ResourceData, meta interface{}) d.Set("location", azure.NormalizeLocation(*location)) } - if resp.ExtendedLocation != nil && resp.ExtendedLocation.Name != nil { - d.Set("extended_location", resp.ExtendedLocation.Name) - } - skuTier := string(containerservice.ManagedClusterSKUTierFree) if resp.Sku != nil && resp.Sku.Tier != "" { skuTier = string(resp.Sku.Tier) diff --git a/website/docs/r/kubernetes_cluster.html.markdown b/website/docs/r/kubernetes_cluster.html.markdown index df04f4b5d212..ff03824537fc 100644 --- a/website/docs/r/kubernetes_cluster.html.markdown +++ b/website/docs/r/kubernetes_cluster.html.markdown @@ -96,8 +96,6 @@ In addition, one of either `identity` or `service_principal` blocks must be spec * `disk_encryption_set_id` - (Optional) The ID of the Disk Encryption Set which should be used for the Nodes and Volumes. More information [can be found in the documentation](https://docs.microsoft.com/en-us/azure/aks/azure-disk-customer-managed-keys). -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. - * `identity` - (Optional) An `identity` block as defined below. One of either `identity` or `service_principal` must be specified. !> **NOTE:** A migration scenario from `service_principal` to `identity` is supported. When upgrading `service_principal` to `identity`, your cluster's control plane and addon pods will switch to use managed identity, but the kubelets will keep using your configured `service_principal` until you upgrade your Node Pool. From a54aa47e2b3a36ef28f7594dbdd093afaa93037c Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 12 Nov 2021 11:16:23 +0800 Subject: [PATCH 5/8] update code --- ...nux_virtual_machine_resource_other_test.go | 19 ++++++++++++--- ...l_machine_scale_set_other_resource_test.go | 23 ++++++++++++++----- .../compute/managed_disk_resource_test.go | 18 +++++++++++---- ...ows_virtual_machine_resource_other_test.go | 23 ++++++++++++++----- ...l_machine_scale_set_other_resource_test.go | 23 ++++++++++++++----- .../loadbalancer_resource_test.go | 18 +++++++++++---- .../network_interface_resource_test.go | 2 ++ .../network/public_ip_resource_test.go | 17 +++++++++++--- .../virtual_network_gateway_resource_test.go | 19 ++++++++++++--- .../network/virtual_network_resource_test.go | 17 +++++++++++--- .../storage/storage_account_resource_test.go | 2 ++ website/docs/r/lb.html.markdown | 2 +- .../r/linux_virtual_machine.html.markdown | 2 +- ...ux_virtual_machine_scale_set.html.markdown | 2 +- website/docs/r/managed_disk.html.markdown | 2 +- .../docs/r/network_interface.html.markdown | 2 +- website/docs/r/public_ip.html.markdown | 2 +- website/docs/r/storage_account.html.markdown | 2 +- website/docs/r/virtual_network.html.markdown | 2 +- .../r/virtual_network_gateway.html.markdown | 2 +- .../r/windows_virtual_machine.html.markdown | 2 +- ...ws_virtual_machine_scale_set.html.markdown | 2 +- 22 files changed, 152 insertions(+), 51 deletions(-) diff --git a/internal/services/compute/linux_virtual_machine_resource_other_test.go b/internal/services/compute/linux_virtual_machine_resource_other_test.go index a120e72bbcb1..7521d85270b8 100644 --- a/internal/services/compute/linux_virtual_machine_resource_other_test.go +++ b/internal/services/compute/linux_virtual_machine_resource_other_test.go @@ -578,7 +578,14 @@ func TestAccLinuxVirtualMachine_otherExtendedLocation(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.otherExtendedLocation(data), + Config: r.otherExtendedLocation(data, "Test1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.otherExtendedLocation(data, "Test2"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -1812,7 +1819,7 @@ resource "azurerm_linux_virtual_machine" "test" { `, gracefulShutdown, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger) } -func (r LinuxVirtualMachineResource) otherExtendedLocation(data acceptance.TestData) string { +func (r LinuxVirtualMachineResource) otherExtendedLocation(data acceptance.TestData, tag string) string { return fmt.Sprintf(` # note: whilst these aren't used in all tests, it saves us redefining these everywhere locals { @@ -1822,6 +1829,8 @@ locals { resource "azurerm_resource_group" "test" { name = "acctestRG-%d" + + // There is no supported extended location in "West Europe" location = "westus" } @@ -1879,6 +1888,10 @@ resource "azurerm_linux_virtual_machine" "test" { sku = "18.04-LTS" version = "latest" } + + tags = { + ENV = "%s" + } } -`, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, tag) } diff --git a/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go b/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go index 59cc20b6d04c..522331a57460 100644 --- a/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go +++ b/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go @@ -644,14 +644,19 @@ func TestAccLinuxVirtualMachineScaleSet_otherExtendedLocation(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.otherExtendedLocation(data), + Config: r.otherExtendedLocation(data, "Test1"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.ImportStep( - "admin_password", - ), + data.ImportStep("admin_password"), + { + Config: r.otherExtendedLocation(data, "Test2"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("admin_password"), }) } @@ -2483,7 +2488,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" { `, r.template(data), data.RandomInteger) } -func (r LinuxVirtualMachineScaleSetResource) otherExtendedLocation(data acceptance.TestData) string { +func (r LinuxVirtualMachineScaleSetResource) otherExtendedLocation(data acceptance.TestData, tag string) string { return fmt.Sprintf(` # note: whilst these aren't used in all tests, it saves us redefining these everywhere locals { @@ -2493,6 +2498,8 @@ locals { resource "azurerm_resource_group" "test" { name = "acctestRG-%d" + + // There is no supported extended location in "West Europe" location = "westus" } @@ -2544,6 +2551,10 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" { subnet_id = azurerm_subnet.test.id } } + + tags = { + ENV = "%s" + } } -`, data.RandomInteger, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.RandomInteger, data.RandomInteger, tag) } diff --git a/internal/services/compute/managed_disk_resource_test.go b/internal/services/compute/managed_disk_resource_test.go index 8bd45451c1bb..f5f5879b8daf 100644 --- a/internal/services/compute/managed_disk_resource_test.go +++ b/internal/services/compute/managed_disk_resource_test.go @@ -481,7 +481,14 @@ func TestAccManagedDisk_extendedLocation(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.extendedLocation(data), + Config: r.extendedLocation(data, "Test1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.extendedLocation(data, "Test2"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -1485,7 +1492,7 @@ resource "azurerm_managed_disk" "test" { `, data.Locations.Primary, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } -func (ManagedDiskResource) extendedLocation(data acceptance.TestData) string { +func (ManagedDiskResource) extendedLocation(data acceptance.TestData, tag string) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -1493,6 +1500,8 @@ provider "azurerm" { resource "azurerm_resource_group" "test" { name = "acctestRG-%d" + + // There is no supported extended location in "West Europe" location = "westus" } @@ -1506,9 +1515,8 @@ resource "azurerm_managed_disk" "test" { extended_location = "microsoftlosangeles1" tags = { - environment = "acctest" - cost-center = "ops" + ENV = "%s" } } -`, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.RandomInteger, tag) } diff --git a/internal/services/compute/windows_virtual_machine_resource_other_test.go b/internal/services/compute/windows_virtual_machine_resource_other_test.go index 357c5e3560ef..142f40ac5872 100644 --- a/internal/services/compute/windows_virtual_machine_resource_other_test.go +++ b/internal/services/compute/windows_virtual_machine_resource_other_test.go @@ -1022,14 +1022,19 @@ func TestAccWindowsVirtualMachine_otherExtendedLocation(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.otherExtendedLocation(data), + Config: r.otherExtendedLocation(data, "Test1"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.ImportStep( - "admin_password", - ), + data.ImportStep("admin_password"), + { + Config: r.otherExtendedLocation(data, "Test2"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("admin_password"), }) } @@ -2520,7 +2525,7 @@ resource "azurerm_windows_virtual_machine" "test" { `, data.RandomString, gracefulShutdown, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) } -func (r WindowsVirtualMachineResource) otherExtendedLocation(data acceptance.TestData) string { +func (r WindowsVirtualMachineResource) otherExtendedLocation(data acceptance.TestData, tag string) string { return fmt.Sprintf(` locals { vm_name = "acctestvm%s" @@ -2528,6 +2533,8 @@ locals { resource "azurerm_resource_group" "test" { name = "acctestRG-%d" + + // There is no supported extended location in "West Europe" location = "westus" } @@ -2584,6 +2591,10 @@ resource "azurerm_windows_virtual_machine" "test" { enable_automatic_updates = false patch_mode = "Manual" + + tags = { + ENV = "%s" + } } -`, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) +`, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger, tag) } diff --git a/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go b/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go index 38a50c038ca0..d37220b10c8c 100644 --- a/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go +++ b/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go @@ -788,14 +788,19 @@ func TestAccWindowsVirtualMachineScaleSet_otherExtendedLocation(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.otherExtendedLocation(data), + Config: r.otherExtendedLocation(data, "Test1"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.ImportStep( - "admin_password", - ), + data.ImportStep("admin_password"), + { + Config: r.otherExtendedLocation(data, "Test2"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("admin_password"), }) } @@ -2985,7 +2990,7 @@ resource "azurerm_windows_virtual_machine_scale_set" "test" { `, r.template(data), licenseType) } -func (r WindowsVirtualMachineScaleSetResource) otherExtendedLocation(data acceptance.TestData) string { +func (r WindowsVirtualMachineScaleSetResource) otherExtendedLocation(data acceptance.TestData, tag string) string { return fmt.Sprintf(` locals { vm_name = "%s" @@ -2993,6 +2998,8 @@ locals { resource "azurerm_resource_group" "test" { name = "acctestRG-%d" + + // There is no supported extended location in "West Europe" location = "westus" } @@ -3041,6 +3048,10 @@ resource "azurerm_windows_virtual_machine_scale_set" "test" { subnet_id = azurerm_subnet.test.id } } + + tags = { + ENV = "%s" + } } -`, r.vmName(data), data.RandomInteger, data.RandomInteger) +`, r.vmName(data), data.RandomInteger, data.RandomInteger, tag) } diff --git a/internal/services/loadbalancer/loadbalancer_resource_test.go b/internal/services/loadbalancer/loadbalancer_resource_test.go index f1ef4ae34dc2..06139b05c7ac 100644 --- a/internal/services/loadbalancer/loadbalancer_resource_test.go +++ b/internal/services/loadbalancer/loadbalancer_resource_test.go @@ -267,7 +267,14 @@ func TestAccAzureRMLoadBalancer_extendedLocation(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.extendedLocation(data), + Config: r.extendedLocation(data, "Test1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.extendedLocation(data, "Test2"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -819,7 +826,7 @@ resource "azurerm_lb" "consumer" { `, data.RandomInteger, data.Locations.Primary) } -func (r LoadBalancer) extendedLocation(data acceptance.TestData) string { +func (r LoadBalancer) extendedLocation(data acceptance.TestData, tag string) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -827,6 +834,8 @@ provider "azurerm" { resource "azurerm_resource_group" "test" { name = "acctestRG-lb-%d" + + // There is no supported extended location in "West Europe" location = "westus" } @@ -837,9 +846,8 @@ resource "azurerm_lb" "test" { extended_location = "microsoftlosangeles1" tags = { - Environment = "production" - Purpose = "AcceptanceTests" + ENV = "%s" } } -`, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.RandomInteger, tag) } diff --git a/internal/services/network/network_interface_resource_test.go b/internal/services/network/network_interface_resource_test.go index f17abbcac9be..745dca377528 100644 --- a/internal/services/network/network_interface_resource_test.go +++ b/internal/services/network/network_interface_resource_test.go @@ -865,6 +865,8 @@ provider "azurerm" { resource "azurerm_resource_group" "test" { name = "acctestRG-%d" + + // There is no supported extended location in "West Europe" location = "westus" } diff --git a/internal/services/network/public_ip_resource_test.go b/internal/services/network/public_ip_resource_test.go index e2810880c89a..e8841ab7af2a 100644 --- a/internal/services/network/public_ip_resource_test.go +++ b/internal/services/network/public_ip_resource_test.go @@ -437,7 +437,14 @@ func TestAccPublicIpStatic_extendedLocation(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.extendedLocation(data), + Config: r.extendedLocation(data, "Test1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.extendedLocation(data, "Test2"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -935,7 +942,7 @@ resource "azurerm_public_ip" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } -func (PublicIPResource) extendedLocation(data acceptance.TestData) string { +func (PublicIPResource) extendedLocation(data acceptance.TestData, tag string) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -956,6 +963,10 @@ resource "azurerm_public_ip" "test" { sku = "Standard" availability_zone = "No-Zone" extended_location = "microsoftlosangeles1" + + tags = { + ENV = "%s" + } } -`, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.RandomInteger, tag) } diff --git a/internal/services/network/virtual_network_gateway_resource_test.go b/internal/services/network/virtual_network_gateway_resource_test.go index acac1b24f311..7fa8494c9483 100644 --- a/internal/services/network/virtual_network_gateway_resource_test.go +++ b/internal/services/network/virtual_network_gateway_resource_test.go @@ -350,7 +350,14 @@ func TestAccVirtualNetworkGateway_extendedLocation(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.extendedLocation(data), + Config: r.extendedLocation(data, "Test1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.extendedLocation(data, "Test2"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -1426,7 +1433,7 @@ resource "azurerm_virtual_network_gateway" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.Client().TenantID, data.Client().TenantID) } -func (VirtualNetworkGatewayResource) extendedLocation(data acceptance.TestData) string { +func (VirtualNetworkGatewayResource) extendedLocation(data acceptance.TestData, tag string) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -1434,6 +1441,8 @@ provider "azurerm" { resource "azurerm_resource_group" "test" { name = "acctestRG-%d" + + // There is no supported extended location in "West Europe" location = "westus" } @@ -1473,6 +1482,10 @@ resource "azurerm_virtual_network_gateway" "test" { private_ip_address_allocation = "Dynamic" subnet_id = azurerm_subnet.test.id } + + tags = { + ENV = "%s" + } } -`, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, tag) } diff --git a/internal/services/network/virtual_network_resource_test.go b/internal/services/network/virtual_network_resource_test.go index 40f73496c9a3..51c3bdb29bbe 100644 --- a/internal/services/network/virtual_network_resource_test.go +++ b/internal/services/network/virtual_network_resource_test.go @@ -208,7 +208,14 @@ func TestAccVirtualNetwork_extendedLocation(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.extendedLocation(data), + Config: r.extendedLocation(data, "Test1"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.extendedLocation(data, "Test2"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -466,7 +473,7 @@ resource "azurerm_virtual_network" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } -func (VirtualNetworkResource) extendedLocation(data acceptance.TestData) string { +func (VirtualNetworkResource) extendedLocation(data acceptance.TestData, tag string) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -490,6 +497,10 @@ resource "azurerm_virtual_network" "test" { name = "subnet1" address_prefix = "10.0.1.0/24" } + + tags = { + ENV = "%s" + } } -`, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.RandomInteger, tag) } diff --git a/internal/services/storage/storage_account_resource_test.go b/internal/services/storage/storage_account_resource_test.go index bf31bf7204e9..574e603359ae 100644 --- a/internal/services/storage/storage_account_resource_test.go +++ b/internal/services/storage/storage_account_resource_test.go @@ -3079,6 +3079,8 @@ provider "azurerm" { resource "azurerm_resource_group" "test" { name = "acctestRG-storage-%d" + + // There is no supported extended location in "West Europe" location = "westus" } diff --git a/website/docs/r/lb.html.markdown b/website/docs/r/lb.html.markdown index 693717edeb72..9b580a4252ab 100644 --- a/website/docs/r/lb.html.markdown +++ b/website/docs/r/lb.html.markdown @@ -44,7 +44,7 @@ The following arguments are supported: * `name` - (Required) Specifies the name of the Load Balancer. * `resource_group_name` - (Required) The name of the Resource Group in which to create the Load Balancer. * `location` - (Required) Specifies the supported Azure Region where the Load Balancer should be created. -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `frontend_ip_configuration` - (Optional) One or multiple `frontend_ip_configuration` blocks as documented below. * `sku` - (Optional) The SKU of the Azure Load Balancer. Accepted values are `Basic`, `Standard` and `Gateway`. Defaults to `Basic`. diff --git a/website/docs/r/linux_virtual_machine.html.markdown b/website/docs/r/linux_virtual_machine.html.markdown index e4afa7617dc4..0af152b57911 100644 --- a/website/docs/r/linux_virtual_machine.html.markdown +++ b/website/docs/r/linux_virtual_machine.html.markdown @@ -148,7 +148,7 @@ The following arguments are supported: -> **NOTE:** This can only be configured when `priority` is set to `Spot`. -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `extensions_time_budget` - (Optional) Specifies the duration allocated for all extensions to start. The time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in ISO 8601 format. Defaults to 90 minutes (`PT1H30M`). diff --git a/website/docs/r/linux_virtual_machine_scale_set.html.markdown b/website/docs/r/linux_virtual_machine_scale_set.html.markdown index 72430778673d..e872bec12ff8 100644 --- a/website/docs/r/linux_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/linux_virtual_machine_scale_set.html.markdown @@ -144,7 +144,7 @@ The following arguments are supported: * `encryption_at_host_enabled` - (Optional) Should all of the disks (including the temp disk) attached to this Virtual Machine be encrypted by enabling Encryption at Host? -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `extension` - (Optional) One or more `extension` blocks as defined below diff --git a/website/docs/r/managed_disk.html.markdown b/website/docs/r/managed_disk.html.markdown index 6cbcf2939f07..e729db78d233 100644 --- a/website/docs/r/managed_disk.html.markdown +++ b/website/docs/r/managed_disk.html.markdown @@ -107,7 +107,7 @@ The following arguments are supported: * `encryption_settings` - (Optional) A `encryption_settings` block as defined below. -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `image_reference_id` - (Optional) ID of an existing platform/marketplace disk image to copy when `create_option` is `FromImage`. diff --git a/website/docs/r/network_interface.html.markdown b/website/docs/r/network_interface.html.markdown index 9271289222d3..2a1fe1298203 100644 --- a/website/docs/r/network_interface.html.markdown +++ b/website/docs/r/network_interface.html.markdown @@ -60,7 +60,7 @@ The following arguments are supported: --- -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `dns_servers` - (Optional) A list of IP Addresses defining the DNS Servers which should be used for this Network Interface. diff --git a/website/docs/r/public_ip.html.markdown b/website/docs/r/public_ip.html.markdown index e72da321bea6..8100720d0a8e 100644 --- a/website/docs/r/public_ip.html.markdown +++ b/website/docs/r/public_ip.html.markdown @@ -42,7 +42,7 @@ The following arguments are supported: * `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `sku` - (Optional) The SKU of the Public IP. Accepted values are `Basic` and `Standard`. Defaults to `Basic`. diff --git a/website/docs/r/storage_account.html.markdown b/website/docs/r/storage_account.html.markdown index 74a1b688909c..9622a2df7c0a 100644 --- a/website/docs/r/storage_account.html.markdown +++ b/website/docs/r/storage_account.html.markdown @@ -97,7 +97,7 @@ The following arguments are supported: * `enable_https_traffic_only` - (Optional) Boolean flag which forces HTTPS if enabled, see [here](https://docs.microsoft.com/en-us/azure/storage/storage-require-secure-transfer/) for more information. Defaults to `true`. -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `min_tls_version` - (Optional) The minimum supported TLS version for the storage account. Possible values are `TLS1_0`, `TLS1_1`, and `TLS1_2`. Defaults to `TLS1_0` for new storage accounts. diff --git a/website/docs/r/virtual_network.html.markdown b/website/docs/r/virtual_network.html.markdown index 3e72653c057c..c252ed0f711f 100644 --- a/website/docs/r/virtual_network.html.markdown +++ b/website/docs/r/virtual_network.html.markdown @@ -83,7 +83,7 @@ The following arguments are supported: * `location` - (Required) The location/region where the virtual network is created. Changing this forces a new resource to be created. -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `bgp_community` - (Optional) The BGP community attribute in format `:`. diff --git a/website/docs/r/virtual_network_gateway.html.markdown b/website/docs/r/virtual_network_gateway.html.markdown index b2b0e562b121..474a17af92c4 100644 --- a/website/docs/r/virtual_network_gateway.html.markdown +++ b/website/docs/r/virtual_network_gateway.html.markdown @@ -120,7 +120,7 @@ The following arguments are supported: * `vpn_type` - (Optional) The routing type of the Virtual Network Gateway. Valid options are `RouteBased` or `PolicyBased`. Defaults to `RouteBased`. -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `enable_bgp` - (Optional) If `true`, BGP (Border Gateway Protocol) will be enabled for this Virtual Network Gateway. Defaults to `false`. diff --git a/website/docs/r/windows_virtual_machine.html.markdown b/website/docs/r/windows_virtual_machine.html.markdown index dd514f977546..549ba89637ab 100644 --- a/website/docs/r/windows_virtual_machine.html.markdown +++ b/website/docs/r/windows_virtual_machine.html.markdown @@ -133,7 +133,7 @@ The following arguments are supported: -> **NOTE:** This can only be configured when `priority` is set to `Spot`. -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `extensions_time_budget` - (Optional) Specifies the duration allocated for all extensions to start. The time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in ISO 8601 format. Defaults to 90 minutes (`PT1H30M`). diff --git a/website/docs/r/windows_virtual_machine_scale_set.html.markdown b/website/docs/r/windows_virtual_machine_scale_set.html.markdown index f132979e8cf1..40ed0405b171 100644 --- a/website/docs/r/windows_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/windows_virtual_machine_scale_set.html.markdown @@ -132,7 +132,7 @@ The following arguments are supported: * `encryption_at_host_enabled` - (Optional) Should all of the disks (including the temp disk) attached to this Virtual Machine be encrypted by enabling Encryption at Host? -* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It offers Azure capacity close to the customer to address the low latency and high throughput requirements and Data Residency requirements of the applications. Changing this forces a new resource to be created. +* `extended_location` - (Optional) Specifies the supported Azure extended location where the resource exists. It allows customers to take advantage of more granular locations. Changing this forces a new resource to be created. * `extension` - (Optional) One or more `extension` blocks as defined below From 09bad097a1a392ff53da87e4af1aec4a61c54680 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 12 Nov 2021 12:02:00 +0800 Subject: [PATCH 6/8] update code --- .../validate/cassandra_cluster_id_test.go | 76 ---------------- .../validate/cassandra_datacenter_id.go | 23 ----- .../validate/cassandra_datacenter_id_test.go | 88 ------------------- 3 files changed, 187 deletions(-) delete mode 100644 internal/services/cosmos/validate/cassandra_cluster_id_test.go delete mode 100644 internal/services/cosmos/validate/cassandra_datacenter_id.go delete mode 100644 internal/services/cosmos/validate/cassandra_datacenter_id_test.go diff --git a/internal/services/cosmos/validate/cassandra_cluster_id_test.go b/internal/services/cosmos/validate/cassandra_cluster_id_test.go deleted file mode 100644 index d9e1dbb53974..000000000000 --- a/internal/services/cosmos/validate/cassandra_cluster_id_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestCassandraClusterID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/cluster1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/CASSANDRACLUSTERS/CLUSTER1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := CassandraClusterID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/cassandra_datacenter_id.go b/internal/services/cosmos/validate/cassandra_datacenter_id.go deleted file mode 100644 index d491b5754c54..000000000000 --- a/internal/services/cosmos/validate/cassandra_datacenter_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func CassandraDatacenterID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.CassandraDatacenterID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/cassandra_datacenter_id_test.go b/internal/services/cosmos/validate/cassandra_datacenter_id_test.go deleted file mode 100644 index 2a9324eb15bc..000000000000 --- a/internal/services/cosmos/validate/cassandra_datacenter_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestCassandraDatacenterID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing CassandraClusterName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for CassandraClusterName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/", - Valid: false, - }, - - { - // missing DataCenterName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/cluster1/", - Valid: false, - }, - - { - // missing value for DataCenterName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/cluster1/dataCenters/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/cassandraClusters/cluster1/dataCenters/dc1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/CASSANDRACLUSTERS/CLUSTER1/DATACENTERS/DC1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := CassandraDatacenterID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} From 1d7397ddb1d9893cd66b4b7d858cdfd6b71787b8 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 12 Nov 2021 15:47:24 +0800 Subject: [PATCH 7/8] update code --- .../compute/linux_virtual_machine_resource_other_test.go | 2 +- .../linux_virtual_machine_scale_set_other_resource_test.go | 2 +- internal/services/compute/managed_disk_resource_test.go | 2 +- .../compute/windows_virtual_machine_resource_other_test.go | 2 +- .../windows_virtual_machine_scale_set_other_resource_test.go | 2 +- internal/services/loadbalancer/loadbalancer_resource_test.go | 2 +- internal/services/network/network_interface_resource_test.go | 2 +- internal/services/network/public_ip_resource_test.go | 4 ++-- .../services/network/virtual_network_gateway_resource_test.go | 2 +- internal/services/network/virtual_network_resource_test.go | 2 +- internal/services/storage/storage_account_resource_test.go | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/services/compute/linux_virtual_machine_resource_other_test.go b/internal/services/compute/linux_virtual_machine_resource_other_test.go index 7521d85270b8..85f3be88e2e2 100644 --- a/internal/services/compute/linux_virtual_machine_resource_other_test.go +++ b/internal/services/compute/linux_virtual_machine_resource_other_test.go @@ -1828,7 +1828,7 @@ locals { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" + name = "acctestRG-%d" // There is no supported extended location in "West Europe" location = "westus" diff --git a/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go b/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go index 522331a57460..a30b10952c60 100644 --- a/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go +++ b/internal/services/compute/linux_virtual_machine_scale_set_other_resource_test.go @@ -2497,7 +2497,7 @@ locals { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" + name = "acctestRG-%d" // There is no supported extended location in "West Europe" location = "westus" diff --git a/internal/services/compute/managed_disk_resource_test.go b/internal/services/compute/managed_disk_resource_test.go index 422128b46575..63de304ba08e 100644 --- a/internal/services/compute/managed_disk_resource_test.go +++ b/internal/services/compute/managed_disk_resource_test.go @@ -1582,7 +1582,7 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" + name = "acctestRG-%d" // There is no supported extended location in "West Europe" location = "westus" diff --git a/internal/services/compute/windows_virtual_machine_resource_other_test.go b/internal/services/compute/windows_virtual_machine_resource_other_test.go index 142f40ac5872..8bf7fe6555ca 100644 --- a/internal/services/compute/windows_virtual_machine_resource_other_test.go +++ b/internal/services/compute/windows_virtual_machine_resource_other_test.go @@ -2532,7 +2532,7 @@ locals { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" + name = "acctestRG-%d" // There is no supported extended location in "West Europe" location = "westus" diff --git a/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go b/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go index d37220b10c8c..fbce64c75df2 100644 --- a/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go +++ b/internal/services/compute/windows_virtual_machine_scale_set_other_resource_test.go @@ -2997,7 +2997,7 @@ locals { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" + name = "acctestRG-%d" // There is no supported extended location in "West Europe" location = "westus" diff --git a/internal/services/loadbalancer/loadbalancer_resource_test.go b/internal/services/loadbalancer/loadbalancer_resource_test.go index 06139b05c7ac..7f1517c1222e 100644 --- a/internal/services/loadbalancer/loadbalancer_resource_test.go +++ b/internal/services/loadbalancer/loadbalancer_resource_test.go @@ -833,7 +833,7 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-lb-%d" + name = "acctestRG-lb-%d" // There is no supported extended location in "West Europe" location = "westus" diff --git a/internal/services/network/network_interface_resource_test.go b/internal/services/network/network_interface_resource_test.go index 745dca377528..5d9bc015eb18 100644 --- a/internal/services/network/network_interface_resource_test.go +++ b/internal/services/network/network_interface_resource_test.go @@ -864,7 +864,7 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" + name = "acctestRG-%d" // There is no supported extended location in "West Europe" location = "westus" diff --git a/internal/services/network/public_ip_resource_test.go b/internal/services/network/public_ip_resource_test.go index e8841ab7af2a..9436767aba0d 100644 --- a/internal/services/network/public_ip_resource_test.go +++ b/internal/services/network/public_ip_resource_test.go @@ -949,10 +949,10 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" + name = "acctestRG-%d" // There is no supported extended location in "West Europe" - location = "westus" + location = "westus" } resource "azurerm_public_ip" "test" { diff --git a/internal/services/network/virtual_network_gateway_resource_test.go b/internal/services/network/virtual_network_gateway_resource_test.go index 8a54879bdb11..a815f1869362 100644 --- a/internal/services/network/virtual_network_gateway_resource_test.go +++ b/internal/services/network/virtual_network_gateway_resource_test.go @@ -1566,7 +1566,7 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" + name = "acctestRG-%d" // There is no supported extended location in "West Europe" location = "westus" diff --git a/internal/services/network/virtual_network_resource_test.go b/internal/services/network/virtual_network_resource_test.go index 51c3bdb29bbe..e2a54fbc5f58 100644 --- a/internal/services/network/virtual_network_resource_test.go +++ b/internal/services/network/virtual_network_resource_test.go @@ -480,7 +480,7 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" + name = "acctestRG-%d" // There is no supported extended location in "West Europe" location = "westus" diff --git a/internal/services/storage/storage_account_resource_test.go b/internal/services/storage/storage_account_resource_test.go index 574e603359ae..323982623973 100644 --- a/internal/services/storage/storage_account_resource_test.go +++ b/internal/services/storage/storage_account_resource_test.go @@ -3078,7 +3078,7 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-storage-%d" + name = "acctestRG-storage-%d" // There is no supported extended location in "West Europe" location = "westus" From 54dff6bf473c7c04d2f33ded78d3f5d78ee6da84 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 19 Jan 2022 10:09:45 +0800 Subject: [PATCH 8/8] update code --- internal/services/storage/storage_account_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/storage/storage_account_resource.go b/internal/services/storage/storage_account_resource.go index 96fc53aad4f5..5da3f5a0b8f1 100644 --- a/internal/services/storage/storage_account_resource.go +++ b/internal/services/storage/storage_account_resource.go @@ -1000,7 +1000,7 @@ func resourceStorageAccountCreate(d *pluginsdk.ResourceData, meta interface{}) e if v, ok := d.GetOk("extended_location"); ok { parameters.ExtendedLocation = &storage.ExtendedLocation{ Name: utils.String(v.(string)), - Type: storage.EdgeZone, + Type: storage.ExtendedLocationTypesEdgeZone, } }