mirror of https://github.com/hashicorp/terraform
Make dnsimple_records importable (#9130)
* Make dnsimple_records importable
terraform 0.7 supports importing a resource into the local state, and
this adds that feature to the dnsimple_record resource.
Unfortunately, the DNSimple v1 API requires a domain name and record ID
to fetch a record, so the import command accepts both pieces of data as
a slash-delimted string like so:
terraform import dnsimple_record.test example.com/1234
* add an acceptance test for importing a dnsimple_record
pull/13982/head
parent
fdf55c7c68
commit
ae7df37e6f
@ -0,0 +1,41 @@
|
||||
package dnsimple
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDnsimpleRecord_import(t *testing.T) {
|
||||
resourceName := "dnsimple_record.foobar"
|
||||
domain := os.Getenv("DNSIMPLE_DOMAIN")
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDNSimpleRecordDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: fmt.Sprintf(testAccCheckDNSimpleRecordConfig_import, domain),
|
||||
},
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
ImportStateIdPrefix: fmt.Sprintf("%s_", domain),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const testAccCheckDNSimpleRecordConfig_import = `
|
||||
resource "dnsimple_record" "foobar" {
|
||||
domain = "%s"
|
||||
|
||||
name = "terraform"
|
||||
value = "192.168.0.10"
|
||||
type = "A"
|
||||
ttl = 3600
|
||||
}`
|
||||
Loading…
Reference in new issue