From 2fa0c35770ef080fdc9c594f31eabdd271a677cc Mon Sep 17 00:00:00 2001 From: Matt White Date: Wed, 11 Dec 2019 20:19:50 +0000 Subject: [PATCH] Add DNS alias support (#2) * Update DNS SDK to 2018-05-01 * A and AAAA record support for aliases * Add missing } * Update modules.txt and fix imports for dns tests * Fic incorrect function name * AAAA testacc pass! + improve resource read code: * A * CNAME * AAAA * Add CNAME tests * Change CNAME tests to Zone Record Set * Update docs --- azurerm/data_source_dns_zone.go | 2 +- .../internal/services/dns/client/client.go | 2 +- azurerm/resource_arm_dns_a_record.go | 44 +++- azurerm/resource_arm_dns_a_record_test.go | 99 +++++++- azurerm/resource_arm_dns_aaaa_record.go | 43 +++- azurerm/resource_arm_dns_aaaa_record_test.go | 99 +++++++- azurerm/resource_arm_dns_caa_record.go | 2 +- azurerm/resource_arm_dns_caa_record_test.go | 2 +- azurerm/resource_arm_dns_cname_record.go | 26 +- azurerm/resource_arm_dns_cname_record_test.go | 99 +++++++- azurerm/resource_arm_dns_mx_record.go | 2 +- azurerm/resource_arm_dns_mx_record_test.go | 2 +- azurerm/resource_arm_dns_ns_record.go | 2 +- azurerm/resource_arm_dns_ns_record_test.go | 2 +- azurerm/resource_arm_dns_ptr_record.go | 2 +- azurerm/resource_arm_dns_ptr_record_test.go | 2 +- azurerm/resource_arm_dns_srv_record.go | 2 +- azurerm/resource_arm_dns_srv_record_test.go | 2 +- azurerm/resource_arm_dns_txt_record.go | 2 +- azurerm/resource_arm_dns_txt_record_test.go | 2 +- azurerm/resource_arm_dns_zone.go | 2 +- .../mgmt/2018-05-01}/dns/client.go | 2 +- .../mgmt/2018-05-01/dns/dnsapi/interfaces.go | 56 +++++ .../mgmt/2018-05-01}/dns/models.go | 238 ++++++++++++------ .../mgmt/2018-05-01}/dns/recordsets.go | 99 ++------ .../mgmt/2018-05-01/dns/resourcereference.go | 117 +++++++++ .../mgmt/2018-05-01}/dns/version.go | 2 +- .../mgmt/2018-05-01}/dns/zones.go | 79 +----- vendor/modules.txt | 2 +- website/docs/r/dns_a_record.html.markdown | 36 ++- website/docs/r/dns_aaaa_record.html.markdown | 38 ++- website/docs/r/dns_cname_record.html.markdown | 34 +++ 32 files changed, 861 insertions(+), 282 deletions(-) rename vendor/github.com/Azure/azure-sdk-for-go/services/{preview/dns/mgmt/2018-03-01-preview => dns/mgmt/2018-05-01}/dns/client.go (98%) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/dnsapi/interfaces.go rename vendor/github.com/Azure/azure-sdk-for-go/services/{preview/dns/mgmt/2018-03-01-preview => dns/mgmt/2018-05-01}/dns/models.go (84%) rename vendor/github.com/Azure/azure-sdk-for-go/services/{preview/dns/mgmt/2018-03-01-preview => dns/mgmt/2018-05-01}/dns/recordsets.go (85%) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/resourcereference.go rename vendor/github.com/Azure/azure-sdk-for-go/services/{preview/dns/mgmt/2018-03-01-preview => dns/mgmt/2018-05-01}/dns/version.go (93%) rename vendor/github.com/Azure/azure-sdk-for-go/services/{preview/dns/mgmt/2018-03-01-preview => dns/mgmt/2018-05-01}/dns/zones.go (84%) diff --git a/azurerm/data_source_dns_zone.go b/azurerm/data_source_dns_zone.go index 601c1b0b6a23..c8b9e2a3cf8a 100644 --- a/azurerm/data_source_dns_zone.go +++ b/azurerm/data_source_dns_zone.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" diff --git a/azurerm/internal/services/dns/client/client.go b/azurerm/internal/services/dns/client/client.go index ab989f05426e..8e65e94e8449 100644 --- a/azurerm/internal/services/dns/client/client.go +++ b/azurerm/internal/services/dns/client/client.go @@ -1,7 +1,7 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" ) diff --git a/azurerm/resource_arm_dns_a_record.go b/azurerm/resource_arm_dns_a_record.go index 8902b8d8b25b..186ae89a9ce8 100644 --- a/azurerm/resource_arm_dns_a_record.go +++ b/azurerm/resource_arm_dns_a_record.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" @@ -47,10 +47,11 @@ func resourceArmDnsARecord() *schema.Resource { }, "records": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Set: schema.HashString, + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + ConflictsWith: []string{"target_resource_id"}, }, "ttl": { @@ -63,6 +64,13 @@ func resourceArmDnsARecord() *schema.Resource { Computed: true, }, + "target_resource_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: azure.ValidateResourceID, + ConflictsWith: []string{"records"}, + }, + "tags": tags.Schema(), }, } @@ -92,13 +100,24 @@ func resourceArmDnsARecordCreateUpdate(d *schema.ResourceData, meta interface{}) ttl := int64(d.Get("ttl").(int)) t := d.Get("tags").(map[string]interface{}) + targetResourceId := d.Get("target_resource_id").(string) + + if bool(targetResourceId == "") && bool(len(d.Get("records").(*schema.Set).List()) == 0) { + return fmt.Errorf("Neither 'records' nor 'target_resource_id' is defined") + } + + var targetResource dns.SubResource + if targetResourceId != "" { + targetResource.ID = utils.String(targetResourceId) + } parameters := dns.RecordSet{ Name: &name, RecordSetProperties: &dns.RecordSetProperties{ - Metadata: tags.Expand(t), - TTL: &ttl, - ARecords: expandAzureRmDnsARecords(d), + Metadata: tags.Expand(t), + TTL: &ttl, + ARecords: expandAzureRmDnsARecords(d), + TargetResource: &targetResource, }, } @@ -150,10 +169,15 @@ func resourceArmDnsARecordRead(d *schema.ResourceData, meta interface{}) error { d.Set("zone_name", zoneName) d.Set("ttl", resp.TTL) d.Set("fqdn", resp.Fqdn) + d.Set("target_resource_id", (resp.TargetResource).ID) - if err := d.Set("records", flattenAzureRmDnsARecords(resp.ARecords)); err != nil { - return err + // Only flatten DNS records if they are present in the resource, e.g. not for alias records + if resp.ARecords != nil { + if err := d.Set("records", flattenAzureRmDnsARecords(resp.ARecords)); err != nil { + return err + } } + return tags.FlattenAndSet(d, resp.Metadata) } diff --git a/azurerm/resource_arm_dns_a_record_test.go b/azurerm/resource_arm_dns_a_record_test.go index df122d28e5c9..e192303beec6 100644 --- a/azurerm/resource_arm_dns_a_record_test.go +++ b/azurerm/resource_arm_dns_a_record_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" @@ -132,6 +132,43 @@ func TestAccAzureRMDnsARecord_withTags(t *testing.T) { }) } +func TestAccAzureRMDnsARecord_withAlias(t *testing.T) { + resourceName := "azurerm_dns_a_record.test" + targetResourceName := "azurerm_public_ip.test" + targetResourceName2 := "azurerm_public_ip.test2" + ri := tf.AccRandTimeInt() + location := testLocation() + preConfig := testAccAzureRMDnsARecord_withAlias(ri, location) + postConfig := testAccAzureRMDnsARecord_withAliasUpdate(ri, location) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMDnsARecordDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMDnsARecordExists(resourceName), + resource.TestCheckResourceAttrPair(resourceName, "target_resource_id", targetResourceName, "id"), + ), + }, + { + Config: postConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMDnsARecordExists(resourceName), + resource.TestCheckResourceAttrPair(resourceName, "target_resource_id", targetResourceName2, "id"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testCheckAzureRMDnsARecordExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API @@ -302,3 +339,63 @@ resource "azurerm_dns_a_record" "test" { } `, rInt, location, rInt, rInt) } + +func testAccAzureRMDnsARecord_withAlias(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_dns_zone" "test" { + name = "acctestzone%d.com" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_public_ip" "test" { + name = "mypublicip%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + allocation_method = "Dynamic" + ip_version = "IPv4" +} + +resource "azurerm_dns_a_record" "test" { + name = "myarecord%d" + resource_group_name = "${azurerm_resource_group.test.name}" + zone_name = "${azurerm_dns_zone.test.name}" + ttl = 300 + target_resource_id = "${azurerm_public_ip.test.id}" +} +`, rInt, location, rInt, rInt, rInt) +} + +func testAccAzureRMDnsARecord_withAliasUpdate(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_dns_zone" "test" { + name = "acctestzone%d.com" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_public_ip" "test2" { + name = "mypublicip%d2" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + allocation_method = "Dynamic" + ip_version = "IPv4" +} + +resource "azurerm_dns_a_record" "test" { + name = "myarecord%d" + resource_group_name = "${azurerm_resource_group.test.name}" + zone_name = "${azurerm_dns_zone.test.name}" + ttl = 300 + target_resource_id = "${azurerm_public_ip.test2.id}" +} +`, rInt, location, rInt, rInt, rInt) +} diff --git a/azurerm/resource_arm_dns_aaaa_record.go b/azurerm/resource_arm_dns_aaaa_record.go index 38bd87533274..08616ebfa5d7 100644 --- a/azurerm/resource_arm_dns_aaaa_record.go +++ b/azurerm/resource_arm_dns_aaaa_record.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" @@ -47,10 +47,11 @@ func resourceArmDnsAAAARecord() *schema.Resource { }, "records": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Set: schema.HashString, + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + ConflictsWith: []string{"target_resource_id"}, }, "ttl": { @@ -64,6 +65,13 @@ func resourceArmDnsAAAARecord() *schema.Resource { }, "tags": tags.Schema(), + + "target_resource_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: azure.ValidateResourceID, + ConflictsWith: []string{"records"}, + }, }, } } @@ -92,13 +100,24 @@ func resourceArmDnsAaaaRecordCreateUpdate(d *schema.ResourceData, meta interface ttl := int64(d.Get("ttl").(int)) t := d.Get("tags").(map[string]interface{}) + targetResourceId := d.Get("target_resource_id").(string) + + if bool(targetResourceId == "") && bool(len(d.Get("records").(*schema.Set).List()) == 0) { + return fmt.Errorf("Neither 'records' nor 'target_resource_id' is defined") + } + + var targetResource dns.SubResource + if targetResourceId != "" { + targetResource.ID = utils.String(targetResourceId) + } parameters := dns.RecordSet{ Name: &name, RecordSetProperties: &dns.RecordSetProperties{ - Metadata: tags.Expand(t), - TTL: &ttl, - AaaaRecords: expandAzureRmDnsAaaaRecords(d), + Metadata: tags.Expand(t), + TTL: &ttl, + AaaaRecords: expandAzureRmDnsAaaaRecords(d), + TargetResource: &targetResource, }, } @@ -150,9 +169,13 @@ func resourceArmDnsAaaaRecordRead(d *schema.ResourceData, meta interface{}) erro d.Set("zone_name", zoneName) d.Set("ttl", resp.TTL) d.Set("fqdn", resp.Fqdn) + d.Set("target_resource_id", (resp.TargetResource).ID) - if err := d.Set("records", flattenAzureRmDnsAaaaRecords(resp.AaaaRecords)); err != nil { - return err + // Only flatten DNS records if they are present in the resource, e.g. not for alias records + if resp.AaaaRecords != nil { + if err := d.Set("records", flattenAzureRmDnsAaaaRecords(resp.AaaaRecords)); err != nil { + return err + } } return tags.FlattenAndSet(d, resp.Metadata) } diff --git a/azurerm/resource_arm_dns_aaaa_record_test.go b/azurerm/resource_arm_dns_aaaa_record_test.go index 6a63a1d82c5a..dab56aea0bea 100644 --- a/azurerm/resource_arm_dns_aaaa_record_test.go +++ b/azurerm/resource_arm_dns_aaaa_record_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" @@ -132,6 +132,43 @@ func TestAccAzureRMDnsAAAARecord_withTags(t *testing.T) { }) } +func TestAccAzureRMDnsAAAARecord_withAlias(t *testing.T) { + resourceName := "azurerm_dns_aaaa_record.test" + targetResourceName := "azurerm_public_ip.test" + targetResourceName2 := "azurerm_public_ip.test2" + ri := tf.AccRandTimeInt() + location := testLocation() + preConfig := testAccAzureRMDnsAAAARecord_withAlias(ri, location) + postConfig := testAccAzureRMDnsAAAARecord_withAliasUpdate(ri, location) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMDnsARecordDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMDnsAaaaRecordExists(resourceName), + resource.TestCheckResourceAttrPair(resourceName, "target_resource_id", targetResourceName, "id"), + ), + }, + { + Config: postConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMDnsAaaaRecordExists(resourceName), + resource.TestCheckResourceAttrPair(resourceName, "target_resource_id", targetResourceName2, "id"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testCheckAzureRMDnsAaaaRecordExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API @@ -302,3 +339,63 @@ resource "azurerm_dns_aaaa_record" "test" { } `, rInt, location, rInt, rInt) } + +func testAccAzureRMDnsAAAARecord_withAlias(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_dns_zone" "test" { + name = "acctestzone%d.com" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_public_ip" "test" { + name = "mypublicip%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + allocation_method = "Dynamic" + ip_version = "IPv6" +} + +resource "azurerm_dns_aaaa_record" "test" { + name = "myaaaarecord%d" + resource_group_name = "${azurerm_resource_group.test.name}" + zone_name = "${azurerm_dns_zone.test.name}" + ttl = 300 + target_resource_id = "${azurerm_public_ip.test.id}" +} +`, rInt, location, rInt, rInt, rInt) +} + +func testAccAzureRMDnsAAAARecord_withAliasUpdate(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_dns_zone" "test" { + name = "acctestzone%d.com" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_public_ip" "test2" { + name = "mypublicip%d2" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + allocation_method = "Dynamic" + ip_version = "IPv6" +} + +resource "azurerm_dns_aaaa_record" "test" { + name = "myaaaarecord%d" + resource_group_name = "${azurerm_resource_group.test.name}" + zone_name = "${azurerm_dns_zone.test.name}" + ttl = 300 + target_resource_id = "${azurerm_public_ip.test2.id}" +} +`, rInt, location, rInt, rInt, rInt) +} diff --git a/azurerm/resource_arm_dns_caa_record.go b/azurerm/resource_arm_dns_caa_record.go index 0aa3150d8954..d505a33904a7 100644 --- a/azurerm/resource_arm_dns_caa_record.go +++ b/azurerm/resource_arm_dns_caa_record.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" diff --git a/azurerm/resource_arm_dns_caa_record_test.go b/azurerm/resource_arm_dns_caa_record_test.go index 2268441f2151..0ea488cd88d9 100644 --- a/azurerm/resource_arm_dns_caa_record_test.go +++ b/azurerm/resource_arm_dns_caa_record_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" diff --git a/azurerm/resource_arm_dns_cname_record.go b/azurerm/resource_arm_dns_cname_record.go index 226852ac2cc9..30ceb0a88966 100644 --- a/azurerm/resource_arm_dns_cname_record.go +++ b/azurerm/resource_arm_dns_cname_record.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" @@ -54,8 +54,9 @@ func resourceArmDnsCNameRecord() *schema.Resource { }, "record": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Optional: true, + ConflictsWith: []string{"target_resource_id"}, }, "ttl": { @@ -68,6 +69,13 @@ func resourceArmDnsCNameRecord() *schema.Resource { Computed: true, }, + "target_resource_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: azure.ValidateResourceID, + ConflictsWith: []string{"records"}, + }, + "tags": tags.Schema(), }, } @@ -98,6 +106,16 @@ func resourceArmDnsCNameRecordCreateUpdate(d *schema.ResourceData, meta interfac ttl := int64(d.Get("ttl").(int)) record := d.Get("record").(string) t := d.Get("tags").(map[string]interface{}) + targetResourceId := d.Get("target_resource_id").(string) + + if bool(targetResourceId == "") && bool(len(record) == 0) { + return fmt.Errorf("Neither 'record' nor 'target_resource_id' is defined") + } + + var targetResource dns.SubResource + if targetResourceId != "" { + targetResource.ID = utils.String(targetResourceId) + } parameters := dns.RecordSet{ Name: &name, @@ -107,6 +125,7 @@ func resourceArmDnsCNameRecordCreateUpdate(d *schema.ResourceData, meta interfac CnameRecord: &dns.CnameRecord{ Cname: &record, }, + TargetResource: &targetResource, }, } @@ -158,6 +177,7 @@ func resourceArmDnsCNameRecordRead(d *schema.ResourceData, meta interface{}) err d.Set("zone_name", zoneName) d.Set("ttl", resp.TTL) d.Set("fqdn", resp.Fqdn) + d.Set("target_resource_id", (resp.TargetResource).ID) if props := resp.RecordSetProperties; props != nil { if record := props.CnameRecord; record != nil { diff --git a/azurerm/resource_arm_dns_cname_record_test.go b/azurerm/resource_arm_dns_cname_record_test.go index cf08dba55ca8..6f4db65f34ba 100644 --- a/azurerm/resource_arm_dns_cname_record_test.go +++ b/azurerm/resource_arm_dns_cname_record_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" @@ -156,6 +156,43 @@ func TestAccAzureRMDnsCNameRecord_withTags(t *testing.T) { }) } +func TestAccAzureRMDnsCNameRecord_withAlias(t *testing.T) { + resourceName := "azurerm_dns_cname_record.test" + targetResourceName := "azurerm_dns_cname_record.target" + targetResourceName2 := "azurerm_dns_cname_record.target2" + ri := tf.AccRandTimeInt() + location := testLocation() + preConfig := testAccAzureRMDnsCNameRecord_withAlias(ri, location) + postConfig := testAccAzureRMDnsCNameRecord_withAliasUpdate(ri, location) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMDnsCNameRecordDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMDnsCNameRecordExists(resourceName), + resource.TestCheckResourceAttrPair(resourceName, "target_resource_id", targetResourceName, "id"), + ), + }, + { + Config: postConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMDnsCNameRecordExists(resourceName), + resource.TestCheckResourceAttrPair(resourceName, "target_resource_id", targetResourceName2, "id"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testCheckAzureRMDnsCNameRecordExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API @@ -348,3 +385,63 @@ resource "azurerm_dns_cname_record" "test" { } `, rInt, location, rInt, rInt) } + +func testAccAzureRMDnsCNameRecord_withAlias(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_dns_zone" "test" { + name = "acctestzone%d.com" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_dns_cname_record" "target" { + name = "mycnametarget%d" + resource_group_name = "${azurerm_resource_group.test.name}" + zone_name = "${azurerm_dns_zone.test.name}" + ttl = 300 + record = "contoso.com" +} + +resource "azurerm_dns_cname_record" "test" { + name = "mycnamerecord%d" + resource_group_name = "${azurerm_resource_group.test.name}" + zone_name = "${azurerm_dns_zone.test.name}" + ttl = 300 + target_resource_id = "${azurerm_dns_cname_record.target.id}" +} +`, rInt, location, rInt, rInt, rInt) +} + +func testAccAzureRMDnsCNameRecord_withAliasUpdate(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_dns_zone" "test" { + name = "acctestzone%d.com" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_dns_cname_record" "target2" { + name = "mycnametarget%d2" + resource_group_name = "${azurerm_resource_group.test.name}" + zone_name = "${azurerm_dns_zone.test.name}" + ttl = 300 + record = "contoso.co.uk" +} + +resource "azurerm_dns_cname_record" "test" { + name = "mycnamerecord%d" + resource_group_name = "${azurerm_resource_group.test.name}" + zone_name = "${azurerm_dns_zone.test.name}" + ttl = 300 + target_resource_id = "${azurerm_dns_cname_record.target2.id}" +} +`, rInt, location, rInt, rInt, rInt) +} diff --git a/azurerm/resource_arm_dns_mx_record.go b/azurerm/resource_arm_dns_mx_record.go index 13edef07daab..18d7ed18d321 100644 --- a/azurerm/resource_arm_dns_mx_record.go +++ b/azurerm/resource_arm_dns_mx_record.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" diff --git a/azurerm/resource_arm_dns_mx_record_test.go b/azurerm/resource_arm_dns_mx_record_test.go index 956bd4ebab7e..8a03d7090ecc 100644 --- a/azurerm/resource_arm_dns_mx_record_test.go +++ b/azurerm/resource_arm_dns_mx_record_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" diff --git a/azurerm/resource_arm_dns_ns_record.go b/azurerm/resource_arm_dns_ns_record.go index e1b9f0a3ab10..2935bd1dcad9 100644 --- a/azurerm/resource_arm_dns_ns_record.go +++ b/azurerm/resource_arm_dns_ns_record.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" diff --git a/azurerm/resource_arm_dns_ns_record_test.go b/azurerm/resource_arm_dns_ns_record_test.go index f46614888e67..794136f6a562 100644 --- a/azurerm/resource_arm_dns_ns_record_test.go +++ b/azurerm/resource_arm_dns_ns_record_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" diff --git a/azurerm/resource_arm_dns_ptr_record.go b/azurerm/resource_arm_dns_ptr_record.go index e0e1ae68928d..eb18a30da338 100644 --- a/azurerm/resource_arm_dns_ptr_record.go +++ b/azurerm/resource_arm_dns_ptr_record.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" diff --git a/azurerm/resource_arm_dns_ptr_record_test.go b/azurerm/resource_arm_dns_ptr_record_test.go index ce3f20ead5f3..69db46b2574a 100644 --- a/azurerm/resource_arm_dns_ptr_record_test.go +++ b/azurerm/resource_arm_dns_ptr_record_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" diff --git a/azurerm/resource_arm_dns_srv_record.go b/azurerm/resource_arm_dns_srv_record.go index b6e815b0fb97..f183536b617a 100644 --- a/azurerm/resource_arm_dns_srv_record.go +++ b/azurerm/resource_arm_dns_srv_record.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" diff --git a/azurerm/resource_arm_dns_srv_record_test.go b/azurerm/resource_arm_dns_srv_record_test.go index 14fd79e26809..fe4df2034ec2 100644 --- a/azurerm/resource_arm_dns_srv_record_test.go +++ b/azurerm/resource_arm_dns_srv_record_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" diff --git a/azurerm/resource_arm_dns_txt_record.go b/azurerm/resource_arm_dns_txt_record.go index fbfbb17bcf33..afae293fc0a6 100644 --- a/azurerm/resource_arm_dns_txt_record.go +++ b/azurerm/resource_arm_dns_txt_record.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" diff --git a/azurerm/resource_arm_dns_txt_record_test.go b/azurerm/resource_arm_dns_txt_record_test.go index 01b8af21f780..93f8bf057766 100644 --- a/azurerm/resource_arm_dns_txt_record_test.go +++ b/azurerm/resource_arm_dns_txt_record_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" diff --git a/azurerm/resource_arm_dns_zone.go b/azurerm/resource_arm_dns_zone.go index 90867eb5ccfa..8a2a7c93116a 100644 --- a/azurerm/resource_arm_dns_zone.go +++ b/azurerm/resource_arm_dns_zone.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/client.go similarity index 98% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/client.go index 7b653b49a40b..cf17ca134ab0 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/client.go @@ -1,4 +1,4 @@ -// Package dns implements the Azure ARM Dns service API version 2018-03-01-preview. +// Package dns implements the Azure ARM Dns service API version 2018-05-01. // // The DNS Management Client. package dns diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/dnsapi/interfaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/dnsapi/interfaces.go new file mode 100644 index 000000000000..1e9eb8c0783a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/dnsapi/interfaces.go @@ -0,0 +1,56 @@ +package dnsapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/Azure/go-autorest/autorest" +) + +// RecordSetsClientAPI contains the set of methods on the RecordSetsClient type. +type RecordSetsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType dns.RecordType, parameters dns.RecordSet, ifMatch string, ifNoneMatch string) (result dns.RecordSet, err error) + Delete(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType dns.RecordType, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType dns.RecordType) (result dns.RecordSet, err error) + ListAllByDNSZone(ctx context.Context, resourceGroupName string, zoneName string, top *int32, recordSetNameSuffix string) (result dns.RecordSetListResultPage, err error) + ListByDNSZone(ctx context.Context, resourceGroupName string, zoneName string, top *int32, recordsetnamesuffix string) (result dns.RecordSetListResultPage, err error) + ListByType(ctx context.Context, resourceGroupName string, zoneName string, recordType dns.RecordType, top *int32, recordsetnamesuffix string) (result dns.RecordSetListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType dns.RecordType, parameters dns.RecordSet, ifMatch string) (result dns.RecordSet, err error) +} + +var _ RecordSetsClientAPI = (*dns.RecordSetsClient)(nil) + +// ZonesClientAPI contains the set of methods on the ZonesClient type. +type ZonesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, zoneName string, parameters dns.Zone, ifMatch string, ifNoneMatch string) (result dns.Zone, err error) + Delete(ctx context.Context, resourceGroupName string, zoneName string, ifMatch string) (result dns.ZonesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, zoneName string) (result dns.Zone, err error) + List(ctx context.Context, top *int32) (result dns.ZoneListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, top *int32) (result dns.ZoneListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, zoneName string, parameters dns.ZoneUpdate, ifMatch string) (result dns.Zone, err error) +} + +var _ ZonesClientAPI = (*dns.ZonesClient)(nil) + +// ResourceReferenceClientAPI contains the set of methods on the ResourceReferenceClient type. +type ResourceReferenceClientAPI interface { + GetByTargetResources(ctx context.Context, parameters dns.ResourceReferenceRequest) (result dns.ResourceReferenceResult, err error) +} + +var _ ResourceReferenceClientAPI = (*dns.ResourceReferenceClient)(nil) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/models.go similarity index 84% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/models.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/models.go index 538db27d647f..b9b4c627c0ab 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/models.go @@ -28,7 +28,7 @@ import ( ) // The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns" +const fqdn = "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" // RecordType enumerates the values for record type. type RecordType string @@ -88,18 +88,6 @@ type ARecord struct { Ipv4Address *string `json:"ipv4Address,omitempty"` } -// AzureEntityResource the resource model definition for a Azure Resource Manager resource with an etag. -type AzureEntityResource struct { - // Etag - READ-ONLY; Resource Etag. - Etag *string `json:"etag,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - Type *string `json:"type,omitempty"` -} - // CaaRecord a CAA record. type CaaRecord struct { // Flags - The flags for this CAA record as an integer between 0 and 255. @@ -148,17 +136,6 @@ type NsRecord struct { Nsdname *string `json:"nsdname,omitempty"` } -// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than -// required location and tags -type ProxyResource struct { - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - Type *string `json:"type,omitempty"` -} - // PtrRecord a PTR record. type PtrRecord struct { // Ptrdname - The PTR target domain name for this PTR record. @@ -406,6 +383,10 @@ type RecordSetProperties struct { TTL *int64 `json:"TTL,omitempty"` // Fqdn - READ-ONLY; Fully qualified domain name of the record set. Fqdn *string `json:"fqdn,omitempty"` + // ProvisioningState - READ-ONLY; provisioning State of the record set. + ProvisioningState *string `json:"provisioningState,omitempty"` + // TargetResource - A reference to an azure resource from where the dns resource value is taken. + TargetResource *SubResource `json:"targetResource,omitempty"` // ARecords - The list of A records in the record set. ARecords *[]ARecord `json:"ARecords,omitempty"` // AaaaRecords - The list of AAAA records in the record set. @@ -437,6 +418,9 @@ func (rsp RecordSetProperties) MarshalJSON() ([]byte, error) { if rsp.TTL != nil { objectMap["TTL"] = rsp.TTL } + if rsp.TargetResource != nil { + objectMap["targetResource"] = rsp.TargetResource + } if rsp.ARecords != nil { objectMap["ARecords"] = rsp.ARecords } @@ -476,14 +460,130 @@ type RecordSetUpdateParameters struct { RecordSet *RecordSet `json:"RecordSet,omitempty"` } -// Resource ... +// Resource common properties of an Azure Resource Manager resource type Resource struct { - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource + // Name - READ-ONLY; Resource name. Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; Resource type. Type *string `json:"type,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// ResourceReference represents a single Azure resource and its referencing DNS records. +type ResourceReference struct { + // DNSResources - A list of dns Records + DNSResources *[]SubResource `json:"dnsResources,omitempty"` + // TargetResource - A reference to an azure resource from where the dns resource value is taken. + TargetResource *SubResource `json:"targetResource,omitempty"` +} + +// ResourceReferenceRequest represents the properties of the Dns Resource Reference Request. +type ResourceReferenceRequest struct { + // ResourceReferenceRequestProperties - The properties of the Resource Reference Request. + *ResourceReferenceRequestProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceReferenceRequest. +func (rrr ResourceReferenceRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rrr.ResourceReferenceRequestProperties != nil { + objectMap["properties"] = rrr.ResourceReferenceRequestProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ResourceReferenceRequest struct. +func (rrr *ResourceReferenceRequest) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var resourceReferenceRequestProperties ResourceReferenceRequestProperties + err = json.Unmarshal(*v, &resourceReferenceRequestProperties) + if err != nil { + return err + } + rrr.ResourceReferenceRequestProperties = &resourceReferenceRequestProperties + } + } + } + + return nil +} + +// ResourceReferenceRequestProperties represents the properties of the Dns Resource Reference Request. +type ResourceReferenceRequestProperties struct { + // TargetResources - A list of references to azure resources for which referencing dns records need to be queried. + TargetResources *[]SubResource `json:"targetResources,omitempty"` +} + +// ResourceReferenceResult represents the properties of the Dns Resource Reference Result. +type ResourceReferenceResult struct { + autorest.Response `json:"-"` + // ResourceReferenceResultProperties - The result of dns resource reference request. Returns a list of dns resource references for each of the azure resource in the request. + *ResourceReferenceResultProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceReferenceResult. +func (rrr ResourceReferenceResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rrr.ResourceReferenceResultProperties != nil { + objectMap["properties"] = rrr.ResourceReferenceResultProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ResourceReferenceResult struct. +func (rrr *ResourceReferenceResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var resourceReferenceResultProperties ResourceReferenceResultProperties + err = json.Unmarshal(*v, &resourceReferenceResultProperties) + if err != nil { + return err + } + rrr.ResourceReferenceResultProperties = &resourceReferenceResultProperties + } + } + } + + return nil +} + +// ResourceReferenceResultProperties the result of dns resource reference request. Returns a list of dns +// resource references for each of the azure resource in the request. +type ResourceReferenceResultProperties struct { + // DNSResourceReferences - The result of dns resource reference request. A list of dns resource references for each of the azure resource in the request + DNSResourceReferences *[]ResourceReference `json:"dnsResourceReferences,omitempty"` } // SoaRecord an SOA record. @@ -522,32 +622,6 @@ type SubResource struct { ID *string `json:"id,omitempty"` } -// TrackedResource the resource model definition for a ARM tracked top level resource -type TrackedResource struct { - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // Location - The geo-location where the resource lives - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for TrackedResource. -func (tr TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tr.Tags != nil { - objectMap["tags"] = tr.Tags - } - if tr.Location != nil { - objectMap["location"] = tr.Location - } - return json.Marshal(objectMap) -} - // TxtRecord a TXT record. type TxtRecord struct { // Value - The text value of this TXT record. @@ -561,16 +635,16 @@ type Zone struct { Etag *string `json:"etag,omitempty"` // ZoneProperties - The properties of the zone. *ZoneProperties `json:"properties,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // Location - The geo-location where the resource lives - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource + // Name - READ-ONLY; Resource name. Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + // Type - READ-ONLY; Resource type. Type *string `json:"type,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` } // MarshalJSON is the custom marshaler for Zone. @@ -582,12 +656,12 @@ func (z Zone) MarshalJSON() ([]byte, error) { if z.ZoneProperties != nil { objectMap["properties"] = z.ZoneProperties } - if z.Tags != nil { - objectMap["tags"] = z.Tags - } if z.Location != nil { objectMap["location"] = z.Location } + if z.Tags != nil { + objectMap["tags"] = z.Tags + } return json.Marshal(objectMap) } @@ -618,24 +692,6 @@ func (z *Zone) UnmarshalJSON(body []byte) error { } z.ZoneProperties = &zoneProperties } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - z.Tags = tags - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - z.Location = &location - } case "id": if v != nil { var ID string @@ -663,6 +719,24 @@ func (z *Zone) UnmarshalJSON(body []byte) error { } z.Type = &typeVar } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + z.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + z.Tags = tags + } } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/recordsets.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/recordsets.go similarity index 85% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/recordsets.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/recordsets.go index 046dfca4aedd..a54a79fa17de 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/recordsets.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/recordsets.go @@ -21,7 +21,6 @@ import ( "context" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" "net/http" ) @@ -43,7 +42,7 @@ func NewRecordSetsClientWithBaseURI(baseURI string, subscriptionID string) Recor // CreateOrUpdate creates or updates a record set within a DNS zone. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). // relativeRecordSetName - the name of the record set, relative to the name of the zone. // recordType - the type of DNS record in this record set. Record sets of type SOA can be updated but not @@ -64,16 +63,6 @@ func (client RecordSetsClient) CreateOrUpdate(ctx context.Context, resourceGroup tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.RecordSetsClient", "CreateOrUpdate", err.Error()) - } - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, ifMatch, ifNoneMatch) if err != nil { err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", nil, "Failure preparing request") @@ -105,7 +94,7 @@ func (client RecordSetsClient) CreateOrUpdatePreparer(ctx context.Context, resou "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -153,7 +142,7 @@ func (client RecordSetsClient) CreateOrUpdateResponder(resp *http.Response) (res // Delete deletes a record set from a DNS zone. This operation cannot be undone. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). // relativeRecordSetName - the name of the record set, relative to the name of the zone. // recordType - the type of DNS record in this record set. Record sets of type SOA cannot be deleted (they are @@ -171,16 +160,6 @@ func (client RecordSetsClient) Delete(ctx context.Context, resourceGroupName str tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.RecordSetsClient", "Delete", err.Error()) - } - req, err := client.DeletePreparer(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, ifMatch) if err != nil { err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", nil, "Failure preparing request") @@ -212,7 +191,7 @@ func (client RecordSetsClient) DeletePreparer(ctx context.Context, resourceGroup "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -250,7 +229,7 @@ func (client RecordSetsClient) DeleteResponder(resp *http.Response) (result auto // Get gets a record set. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). // relativeRecordSetName - the name of the record set, relative to the name of the zone. // recordType - the type of DNS record in this record set. @@ -265,16 +244,6 @@ func (client RecordSetsClient) Get(ctx context.Context, resourceGroupName string tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.RecordSetsClient", "Get", err.Error()) - } - req, err := client.GetPreparer(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType) if err != nil { err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", nil, "Failure preparing request") @@ -306,7 +275,7 @@ func (client RecordSetsClient) GetPreparer(ctx context.Context, resourceGroupNam "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -341,7 +310,7 @@ func (client RecordSetsClient) GetResponder(resp *http.Response) (result RecordS // ListAllByDNSZone lists all record sets in a DNS zone. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). // top - the maximum number of record sets to return. If not specified, returns up to 100 record sets. // recordSetNameSuffix - the suffix label of the record set name that has to be used to filter the record set @@ -358,16 +327,6 @@ func (client RecordSetsClient) ListAllByDNSZone(ctx context.Context, resourceGro tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.RecordSetsClient", "ListAllByDNSZone", err.Error()) - } - result.fn = client.listAllByDNSZoneNextResults req, err := client.ListAllByDNSZonePreparer(ctx, resourceGroupName, zoneName, top, recordSetNameSuffix) if err != nil { @@ -398,7 +357,7 @@ func (client RecordSetsClient) ListAllByDNSZonePreparer(ctx context.Context, res "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -476,7 +435,7 @@ func (client RecordSetsClient) ListAllByDNSZoneComplete(ctx context.Context, res // ListByDNSZone lists all record sets in a DNS zone. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). // top - the maximum number of record sets to return. If not specified, returns up to 100 record sets. // recordsetnamesuffix - the suffix label of the record set name that has to be used to filter the record set @@ -493,16 +452,6 @@ func (client RecordSetsClient) ListByDNSZone(ctx context.Context, resourceGroupN tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.RecordSetsClient", "ListByDNSZone", err.Error()) - } - result.fn = client.listByDNSZoneNextResults req, err := client.ListByDNSZonePreparer(ctx, resourceGroupName, zoneName, top, recordsetnamesuffix) if err != nil { @@ -533,7 +482,7 @@ func (client RecordSetsClient) ListByDNSZonePreparer(ctx context.Context, resour "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -611,7 +560,7 @@ func (client RecordSetsClient) ListByDNSZoneComplete(ctx context.Context, resour // ListByType lists the record sets of a specified type in a DNS zone. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). // recordType - the type of record sets to enumerate. // top - the maximum number of record sets to return. If not specified, returns up to 100 record sets. @@ -629,16 +578,6 @@ func (client RecordSetsClient) ListByType(ctx context.Context, resourceGroupName tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.RecordSetsClient", "ListByType", err.Error()) - } - result.fn = client.listByTypeNextResults req, err := client.ListByTypePreparer(ctx, resourceGroupName, zoneName, recordType, top, recordsetnamesuffix) if err != nil { @@ -670,7 +609,7 @@ func (client RecordSetsClient) ListByTypePreparer(ctx context.Context, resourceG "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -748,7 +687,7 @@ func (client RecordSetsClient) ListByTypeComplete(ctx context.Context, resourceG // Update updates a record set within a DNS zone. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). // relativeRecordSetName - the name of the record set, relative to the name of the zone. // recordType - the type of DNS record in this record set. @@ -766,16 +705,6 @@ func (client RecordSetsClient) Update(ctx context.Context, resourceGroupName str tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.RecordSetsClient", "Update", err.Error()) - } - req, err := client.UpdatePreparer(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, ifMatch) if err != nil { err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Update", nil, "Failure preparing request") @@ -807,7 +736,7 @@ func (client RecordSetsClient) UpdatePreparer(ctx context.Context, resourceGroup "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/resourcereference.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/resourcereference.go new file mode 100644 index 000000000000..35f01ca41b50 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/resourcereference.go @@ -0,0 +1,117 @@ +package dns + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ResourceReferenceClient is the the DNS Management Client. +type ResourceReferenceClient struct { + BaseClient +} + +// NewResourceReferenceClient creates an instance of the ResourceReferenceClient client. +func NewResourceReferenceClient(subscriptionID string) ResourceReferenceClient { + return NewResourceReferenceClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewResourceReferenceClientWithBaseURI creates an instance of the ResourceReferenceClient client. +func NewResourceReferenceClientWithBaseURI(baseURI string, subscriptionID string) ResourceReferenceClient { + return ResourceReferenceClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByTargetResources returns the DNS records specified by the referencing targetResourceIds. +// Parameters: +// parameters - properties for dns resource reference request. +func (client ResourceReferenceClient) GetByTargetResources(ctx context.Context, parameters ResourceReferenceRequest) (result ResourceReferenceResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceReferenceClient.GetByTargetResources") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByTargetResourcesPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "dns.ResourceReferenceClient", "GetByTargetResources", nil, "Failure preparing request") + return + } + + resp, err := client.GetByTargetResourcesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "dns.ResourceReferenceClient", "GetByTargetResources", resp, "Failure sending request") + return + } + + result, err = client.GetByTargetResourcesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "dns.ResourceReferenceClient", "GetByTargetResources", resp, "Failure responding to request") + } + + return +} + +// GetByTargetResourcesPreparer prepares the GetByTargetResources request. +func (client ResourceReferenceClient) GetByTargetResourcesPreparer(ctx context.Context, parameters ResourceReferenceRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByTargetResourcesSender sends the GetByTargetResources request. The method will close the +// http.Response Body if it receives an error. +func (client ResourceReferenceClient) GetByTargetResourcesSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetByTargetResourcesResponder handles the response to the GetByTargetResources request. The method always +// closes the http.Response Body. +func (client ResourceReferenceClient) GetByTargetResourcesResponder(resp *http.Response) (result ResourceReferenceResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/version.go similarity index 93% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/version.go index 0275c857cae2..7762623de8cd 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " dns/2018-03-01-preview" + return "Azure-SDK-For-Go/" + version.Number + " dns/2018-05-01" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/zones.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/zones.go similarity index 84% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/zones.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/zones.go index d2a13f6b057b..de1ede07511d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns/zones.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/zones.go @@ -21,7 +21,6 @@ import ( "context" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" "net/http" ) @@ -43,7 +42,7 @@ func NewZonesClientWithBaseURI(baseURI string, subscriptionID string) ZonesClien // CreateOrUpdate creates or updates a DNS zone. Does not modify DNS records within the zone. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). // parameters - parameters supplied to the CreateOrUpdate operation. // ifMatch - the etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the @@ -61,16 +60,6 @@ func (client ZonesClient) CreateOrUpdate(ctx context.Context, resourceGroupName tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.ZonesClient", "CreateOrUpdate", err.Error()) - } - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, zoneName, parameters, ifMatch, ifNoneMatch) if err != nil { err = autorest.NewErrorWithError(err, "dns.ZonesClient", "CreateOrUpdate", nil, "Failure preparing request") @@ -100,7 +89,7 @@ func (client ZonesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGr "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -146,7 +135,7 @@ func (client ZonesClient) CreateOrUpdateResponder(resp *http.Response) (result Z // Delete deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be // undone. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). // ifMatch - the etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen // etag value to prevent accidentally deleting any concurrent changes. @@ -161,16 +150,6 @@ func (client ZonesClient) Delete(ctx context.Context, resourceGroupName string, tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.ZonesClient", "Delete", err.Error()) - } - req, err := client.DeletePreparer(ctx, resourceGroupName, zoneName, ifMatch) if err != nil { err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Delete", nil, "Failure preparing request") @@ -194,7 +173,7 @@ func (client ZonesClient) DeletePreparer(ctx context.Context, resourceGroupName "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -238,7 +217,7 @@ func (client ZonesClient) DeleteResponder(resp *http.Response) (result autorest. // Get gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). func (client ZonesClient) Get(ctx context.Context, resourceGroupName string, zoneName string) (result Zone, err error) { if tracing.IsEnabled() { @@ -251,16 +230,6 @@ func (client ZonesClient) Get(ctx context.Context, resourceGroupName string, zon tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.ZonesClient", "Get", err.Error()) - } - req, err := client.GetPreparer(ctx, resourceGroupName, zoneName) if err != nil { err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Get", nil, "Failure preparing request") @@ -290,7 +259,7 @@ func (client ZonesClient) GetPreparer(ctx context.Context, resourceGroupName str "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -337,12 +306,6 @@ func (client ZonesClient) List(ctx context.Context, top *int32) (result ZoneList tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.ZonesClient", "List", err.Error()) - } - result.fn = client.listNextResults req, err := client.ListPreparer(ctx, top) if err != nil { @@ -371,7 +334,7 @@ func (client ZonesClient) ListPreparer(ctx context.Context, top *int32) (*http.R "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -446,7 +409,7 @@ func (client ZonesClient) ListComplete(ctx context.Context, top *int32) (result // ListByResourceGroup lists the DNS zones within a resource group. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // top - the maximum number of record sets to return. If not specified, returns up to 100 record sets. func (client ZonesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, top *int32) (result ZoneListResultPage, err error) { if tracing.IsEnabled() { @@ -459,16 +422,6 @@ func (client ZonesClient) ListByResourceGroup(ctx context.Context, resourceGroup tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.ZonesClient", "ListByResourceGroup", err.Error()) - } - result.fn = client.listByResourceGroupNextResults req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, top) if err != nil { @@ -498,7 +451,7 @@ func (client ZonesClient) ListByResourceGroupPreparer(ctx context.Context, resou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -573,7 +526,7 @@ func (client ZonesClient) ListByResourceGroupComplete(ctx context.Context, resou // Update updates a DNS zone. Does not modify DNS records within the zone. // Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceGroupName - the name of the resource group. // zoneName - the name of the DNS zone (without a terminating dot). // parameters - parameters supplied to the Update operation. // ifMatch - the etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the @@ -589,16 +542,6 @@ func (client ZonesClient) Update(ctx context.Context, resourceGroupName string, tracing.EndSpan(ctx, sc, err) }() } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("dns.ZonesClient", "Update", err.Error()) - } - req, err := client.UpdatePreparer(ctx, resourceGroupName, zoneName, parameters, ifMatch) if err != nil { err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Update", nil, "Failure preparing request") @@ -628,7 +571,7 @@ func (client ZonesClient) UpdatePreparer(ctx context.Context, resourceGroupName "zoneName": autorest.Encode("path", zoneName), } - const APIVersion = "2018-03-01-preview" + const APIVersion = "2018-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/modules.txt b/vendor/modules.txt index b907f87dcabb..1ea35cdb0598 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -47,7 +47,7 @@ github.com/Azure/azure-sdk-for-go/services/notificationhubs/mgmt/2017-04-01/noti github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization github.com/Azure/azure-sdk-for-go/services/preview/botservice/mgmt/2018-07-12/botservice -github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns +github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid github.com/Azure/azure-sdk-for-go/services/preview/hdinsight/mgmt/2018-06-01-preview/hdinsight github.com/Azure/azure-sdk-for-go/services/preview/iothub/mgmt/2018-12-01-preview/devices diff --git a/website/docs/r/dns_a_record.html.markdown b/website/docs/r/dns_a_record.html.markdown index f3218bfe76b8..9252557cd295 100644 --- a/website/docs/r/dns_a_record.html.markdown +++ b/website/docs/r/dns_a_record.html.markdown @@ -33,6 +33,36 @@ resource "azurerm_dns_a_record" "example" { } ``` +## Example Usage (Alias Record) + +```hcl +resource "azurerm_resource_group" "example" { + name = "acceptanceTestResourceGroup1" + location = "West US" +} + +resource "azurerm_dns_zone" "example" { + name = "mydomain.com" + resource_group_name = "${azurerm_resource_group.example.name}" +} + +resource "azurerm_public_ip" "example" { + name = "mypublicip" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" + allocation_method = "Dynamic" + ip_version = "IPv4" +} + +resource "azurerm_dns_a_record" "example" { + name = "test" + zone_name = "${azurerm_dns_zone.example.name}" + resource_group_name = "${azurerm_resource_group.example.name}" + ttl = 300 + target_resource_id = "${azurerm_public_ip.example.id}" +} +``` + ## Argument Reference The following arguments are supported: @@ -45,10 +75,14 @@ The following arguments are supported: * `TTL` - (Required) The Time To Live (TTL) of the DNS record in seconds. -* `records` - (Required) List of IPv4 Addresses. +* `records` - (Optional) List of IPv4 Addresses. Conflicts with `target_resource_id`. + +* `target_resource_id` - (Optional) The Azure resource id of the target object. Conflicts with `records` * `tags` - (Optional) A mapping of tags to assign to the resource. +~> **Note:** either `records` OR `target_resource_id` must be specified, but not both. + ## Attributes Reference The following attributes are exported: diff --git a/website/docs/r/dns_aaaa_record.html.markdown b/website/docs/r/dns_aaaa_record.html.markdown index 449e9bb62d28..4324e9535957 100644 --- a/website/docs/r/dns_aaaa_record.html.markdown +++ b/website/docs/r/dns_aaaa_record.html.markdown @@ -29,7 +29,37 @@ resource "azurerm_dns_aaaa_record" "example" { zone_name = "${azurerm_dns_zone.example.name}" resource_group_name = "${azurerm_resource_group.example.name}" ttl = 300 - records = ["2607:f8b0:4009:1803::1005"] + +} +``` + +## Example Usage (Alias Record) + +```hcl +resource "azurerm_resource_group" "example" { + name = "acceptanceTestResourceGroup1" + location = "West US" +} + +resource "azurerm_dns_zone" "example" { + name = "mydomain.com" + resource_group_name = "${azurerm_resource_group.example.name}" +} + +resource "azurerm_public_ip" "example" { + name = "mypublicip" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" + allocation_method = "Dynamic" + ip_version = "IPv6 +} + +resource "azurerm_dns_aaaa_record" "example" { + name = "test" + zone_name = "${azurerm_dns_zone.example.name}" + resource_group_name = "${azurerm_resource_group.example.name}" + ttl = 300 + target_resource_id = "${azurerm_public_ip.example.id}" } ``` @@ -45,10 +75,14 @@ The following arguments are supported: * `TTL` - (Required) The Time To Live (TTL) of the DNS record in seconds. -* `records` - (Required) List of IPv6 Addresses. +* `records` - (Optional) List of IPv4 Addresses. Conflicts with `target_resource_id`. + +* `target_resource_id` - (Optional) The Azure resource id of the target object. Conflicts with `records` * `tags` - (Optional) A mapping of tags to assign to the resource. +~> **Note:** either `records` OR `target_resource_id` must be specified, but not both. + ## Attributes Reference The following attributes are exported: diff --git a/website/docs/r/dns_cname_record.html.markdown b/website/docs/r/dns_cname_record.html.markdown index deeffb562f70..00b205b72b13 100644 --- a/website/docs/r/dns_cname_record.html.markdown +++ b/website/docs/r/dns_cname_record.html.markdown @@ -33,6 +33,36 @@ resource "azurerm_dns_cname_record" "example" { } ``` +## Example Usage (Alias Record) + +```hcl +resource "azurerm_resource_group" "example" { + name = "acceptanceTestResourceGroup1" + location = "West US" +} + +resource "azurerm_dns_zone" "example" { + name = "mydomain.com" + resource_group_name = "${azurerm_resource_group.example.name}" +} + +resource "azurerm_dns_cname_record" "target" { + name = "target" + zone_name = "${azurerm_dns_zone.example.name}" + resource_group_name = "${azurerm_resource_group.example.name}" + ttl = 300 + record = "contoso.com" +} + +resource "azurerm_dns_cname_record" "example" { + name = "test" + zone_name = "${azurerm_dns_zone.example.name}" + resource_group_name = "${azurerm_resource_group.example.name}" + ttl = 300 + target_resource_id = "${azurerm_dns_cname_record.target.id}" +} +``` + ## Argument Reference The following arguments are supported: @@ -47,8 +77,12 @@ The following arguments are supported: * `record` - (Required) The target of the CNAME. +* `target_resource_id` - (Optional) The Azure resource id of the target object. Conflicts with `records` + * `tags` - (Optional) A mapping of tags to assign to the resource. +~> **Note:** either `record` OR `target_resource_id` must be specified, but not both. + ## Attributes Reference The following attributes are exported: