Skip to content
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

dme_domain resource import #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions dme/resource_dme_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func resourceDMEDomain() *schema.Resource {
Read: resourceDMEDomainRead,
Update: resourceDMEDomainUpdate,
Delete: resourceDMEDomainDelete,
Importer: &schema.ResourceImporter{
State: resourceDMEDomainImport,
},

Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Expand Down Expand Up @@ -205,3 +208,12 @@ func resourceDMEDomainDelete(d *schema.ResourceData, m interface{}) error {
d.SetId("")
return nil
}

func resourceDMEDomainImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
err := resourceDMEDomainRead(d, m)
if err != nil {
return nil, err
}

return []*schema.ResourceData{d}, nil
}
13 changes: 10 additions & 3 deletions dme/resource_dme_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestAccDomain_Basic(t *testing.T) {
resourceName := "dme_domain.example"
var domain models.DomainAttribute
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -21,15 +22,21 @@ func TestAccDomain_Basic(t *testing.T) {
{
Config: testAccCheckDMEDomainConfig_basic("domain_test_basic1.com", "false"),
Check: resource.ComposeTestCheckFunc(
testAccCheckDMEDomainExists("dme_domain.example", &domain),
testAccCheckDMEDomainExists(resourceName, &domain),
testAccCheckDMEDomainAttributes("domain_test_basic1.com", "false", &domain),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccDMEDomain_Update(t *testing.T) {
resourceName := "dme_domain.example"
var domain models.DomainAttribute

resource.Test(t, resource.TestCase{
Expand All @@ -40,14 +47,14 @@ func TestAccDMEDomain_Update(t *testing.T) {
{
Config: testAccCheckDMEDomainConfig_basic("domain_test_update1.com", "false"),
Check: resource.ComposeTestCheckFunc(
testAccCheckDMEDomainExists("dme_domain.example", &domain),
testAccCheckDMEDomainExists(resourceName, &domain),
testAccCheckDMEDomainAttributes("domain_test_update1.com", "false", &domain),
),
},
{
Config: testAccCheckDMEDomainConfig_basic("domain_test_update1.com", "true"),
Check: resource.ComposeTestCheckFunc(
testAccCheckDMEDomainExists("dme_domain.example", &domain),
testAccCheckDMEDomainExists(resourceName, &domain),
testAccCheckDMEDomainAttributes("domain_test_update1.com", "true", &domain),
),
},
Expand Down
12 changes: 11 additions & 1 deletion website/docs/r/domain.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,14 @@ It takes around 10 minutes to reflect the changes on the DNS Made Easy platform.
was last updated in Epoch time. Not configurable by the user.
* `created` - The number of seconds since the domain
was last created in Epoch time. Not configurable by the user.
* `id` - Set to the dme calculated id of domain action.
* `id` - Set to the dme calculated id of domain action.

## Import

Domain can be imported using the `id`, e.g.

```bash
$ terraform import dme_domain.example_com 7955579
```

You can copy `id` from domain index page URL, e.g. https://cp.dnsmadeeasy.com/dns/managed/7955579.