-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r/dns_(a|aaaa|cname)_record: support for configuring target_resource_id
#5218
Conversation
* 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
No problem @tombuildsstuff :) I was having trouble ensuring that the These were the tests that I wrote to ensure this was happening: func TestAccAzureRMDnsARecord_RecordsToAlias(t *testing.T) {
resourceName := "azurerm_dns_a_record.test"
targetResourceName := "azurerm_public_ip.test"
ri := tf.AccRandTimeInt()
location := testLocation()
preConfig := testAccAzureRMDnsARecord_RecordsToAlias(ri, location)
postConfig := testAccAzureRMDnsARecord_RecordsToAliasUpdate(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.TestCheckResourceAttr(resourceName, "records.#", "2"),
),
},
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMDnsARecordExists(resourceName),
resource.TestCheckResourceAttrPair(resourceName, "target_resource_id", targetResourceName, "id"),
resource.TestCheckNoResourceAttr(resourceName, "records"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func TestAccAzureRMDnsARecord_AliasToRecords(t *testing.T) {
resourceName := "azurerm_dns_a_record.test"
targetResourceName := "azurerm_public_ip.test"
ri := tf.AccRandTimeInt()
location := testLocation()
preConfig := testAccAzureRMDnsARecord_AliasToRecords(ri, location)
postConfig := testAccAzureRMDnsARecord_AliasToRecordsUpdate(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.TestCheckResourceAttr(resourceName, "records.#", "2"),
resource.TestCheckNoResourceAttr(resourceName, "target_resource_id"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func testAccAzureRMDnsARecord_AliasToRecords(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_AliasToRecordsUpdate(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_a_record" "test" {
name = "myarecord%d"
resource_group_name = "${azurerm_resource_group.test.name}"
zone_name = "${azurerm_dns_zone.test.name}"
ttl = 300
records = ["1.2.3.4", "1.2.4.5"]
}
`, rInt, location, rInt, rInt)
} |
@matt-FFFFFF will look to add that prior to review/merge - but that should be fine now given we're nil-ing them out 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This has been released in version 1.40.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 1.40.0"
}
# ... other configuration ... |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
This PR supersedes (and includes the work from) #5133 - which adds support for
target_resource_id
to theazurerm_dns_a_record
,azurerm_dns_aaaa_record
andazurerm_dns_cname_record
resources. Since #5133 is from @matt-FFFFFF's master branch, unfortunately we're unable to push to that - hence opening this PR including those changes insteadFixes #3624
Fixes #4623
Original PR description: