Skip to content

Commit

Permalink
private_dns_zone_virtual_network_link: suppress case differences for …
Browse files Browse the repository at this point in the history
…name attribute

See Azure/azure-rest-api-specs#10933
  • Loading branch information
manicminer committed Oct 29, 2020
1 parent f413632 commit 8b8256a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts"
Expand Down Expand Up @@ -41,8 +42,8 @@ func resourceArmPrivateDnsZoneVirtualNetworkLink() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
// lower-cased due to the broken API https://github.com/Azure/azure-rest-api-specs/issues/10933
ValidateFunc: validate.LowerCasedString,
// TODO: make this case sensitive once the API's fixed https://github.com/Azure/azure-rest-api-specs/issues/10933
DiffSuppressFunc: suppress.CaseDifference,
},

"private_dns_zone_name": {
Expand Down Expand Up @@ -88,7 +89,7 @@ func resourceArmPrivateDnsZoneVirtualNetworkLinkCreateUpdate(d *schema.ResourceD
existing, err := client.Get(ctx, resGroup, dnsZoneName, name)
if err != nil {
if !utils.ResponseWasNotFound(existing.Response) {
return fmt.Errorf("error checking for presence of existing Private DNS Zone Virtual network link %q (Resource Group %q): %s", name, resGroup, err)
return fmt.Errorf("checking for presence of existing Virtual Network Link %q (Private DNS Zone %q / Resource Group %q): %s", name, dnsZoneName, resGroup, err)
}
}

Expand Down Expand Up @@ -116,20 +117,20 @@ func resourceArmPrivateDnsZoneVirtualNetworkLinkCreateUpdate(d *schema.ResourceD

future, err := client.CreateOrUpdate(ctx, resGroup, dnsZoneName, name, parameters, etag, ifNoneMatch)
if err != nil {
return fmt.Errorf("error creating/updating Private DNS Zone Virtual network link %q (Resource Group %q): %s", name, resGroup, err)
return fmt.Errorf("creating/updating Virtual Network Link %q (Private DNS Zone %q / Resource Group %q): %s", name, dnsZoneName, resGroup, err)
}

if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
return fmt.Errorf("error waiting for Private DNS Zone Virtual network link %q to become available: %+v", name, err)
return fmt.Errorf("waiting for Private DNS Zone Virtual Network Link %q to become available: %+v", name, err)
}

resp, err := client.Get(ctx, resGroup, dnsZoneName, name)
if err != nil {
return fmt.Errorf("error retrieving Private DNS Zone Virtual network link %q (Resource Group %q): %s", name, resGroup, err)
return fmt.Errorf("retrieving Virtual Network Link %q (Private DNS Zone %q / Resource Group %q): %s", name, dnsZoneName, resGroup, err)
}

if resp.ID == nil {
return fmt.Errorf("cannot read Private DNS Zone Virtual network link %q (Resource Group %q) ID", name, resGroup)
return fmt.Errorf("cannot read Virtual Network Link %q (Private DNS Zone %q / Resource Group %q) ID", name, dnsZoneName, resGroup)
}

d.SetId(*resp.ID)
Expand Down Expand Up @@ -157,7 +158,7 @@ func resourceArmPrivateDnsZoneVirtualNetworkLinkRead(d *schema.ResourceData, met
d.SetId("")
return nil
}
return fmt.Errorf("error reading Private DNS Zone Virtual network link %q (Resource Group %q): %+v", name, resGroup, err)
return fmt.Errorf("reading Virtual Network Link %q (Private DNS Zone %q / Resource Group %q): %+v", name, dnsZoneName, resGroup, err)
}

d.Set("name", name)
Expand Down Expand Up @@ -194,7 +195,7 @@ func resourceArmPrivateDnsZoneVirtualNetworkLinkDelete(d *schema.ResourceData, m
if response.WasNotFound(future.Response()) {
return nil
}
return fmt.Errorf("error deleting Virtual Network Link %q (Private DNS Zone %q / Resource Group %q): %+v", name, dnsZoneName, resGroup, err)
return fmt.Errorf("deleting Virtual Network Link %q (Private DNS Zone %q / Resource Group %q): %+v", name, dnsZoneName, resGroup, err)
}

// whilst the Delete above returns a Future, the Azure API's broken such that even though it's marked as "gone"
Expand Down Expand Up @@ -225,7 +226,7 @@ func resourceArmPrivateDnsZoneVirtualNetworkLinkDelete(d *schema.ResourceData, m
}

if _, err := stateConf.WaitForState(); err != nil {
return fmt.Errorf("error waiting for deletion of Virtual Network Link %q (Private DNS Zone %q / Resource Group %q): %+v", name, dnsZoneName, resGroup, err)
return fmt.Errorf("waiting for deletion of Virtual Network Link %q (Private DNS Zone %q / Resource Group %q): %+v", name, dnsZoneName, resGroup, err)
}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ resource "azurerm_virtual_network" "test" {
resource "azurerm_private_dns_zone" "test" {
name = "acctestzone%d.com"
resource_group_name = "${azurerm_resource_group.test.name}"
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_private_dns_zone_virtual_network_link" "test" {
name = "acctest%d"
private_dns_zone_name = "${azurerm_private_dns_zone.test.name}"
virtual_network_id = "${azurerm_virtual_network.test.id}"
resource_group_name = "${azurerm_resource_group.test.name}"
name = "acctestVnetZone%d.com"
private_dns_zone_name = azurerm_private_dns_zone.test.name
virtual_network_id = azurerm_virtual_network.test.id
resource_group_name = azurerm_resource_group.test.name
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
Expand Down Expand Up @@ -215,10 +215,10 @@ resource "azurerm_private_dns_zone" "test" {
}
resource "azurerm_private_dns_zone_virtual_network_link" "test" {
name = "acctest%d"
private_dns_zone_name = "${azurerm_private_dns_zone.test.name}"
virtual_network_id = "${azurerm_virtual_network.test.id}"
resource_group_name = "${azurerm_resource_group.test.name}"
name = "acctestVnetZone%d.com"
private_dns_zone_name = azurerm_private_dns_zone.test.name
virtual_network_id = azurerm_virtual_network.test.id
resource_group_name = azurerm_resource_group.test.name
tags = {
environment = "Production"
Expand Down Expand Up @@ -257,10 +257,10 @@ resource "azurerm_private_dns_zone" "test" {
}
resource "azurerm_private_dns_zone_virtual_network_link" "test" {
name = "acctestzone%d.com"
private_dns_zone_name = "${azurerm_private_dns_zone.test.name}"
virtual_network_id = "${azurerm_virtual_network.test.id}"
resource_group_name = "${azurerm_resource_group.test.name}"
name = "acctestVnetZone%d.com"
private_dns_zone_name = azurerm_private_dns_zone.test.name
virtual_network_id = azurerm_virtual_network.test.id
resource_group_name = azurerm_resource_group.test.name
tags = {
environment = "staging"
Expand Down

0 comments on commit 8b8256a

Please sign in to comment.