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

Adds a 'vultr_reverse_name' resource #78

Closed
wants to merge 8 commits into from
Closed

Adds a 'vultr_reverse_name' resource #78

wants to merge 8 commits into from

Conversation

cimnine
Copy link

@cimnine cimnine commented Jun 12, 2019

This PR implements a new resource for setting reverse dns entries.

An extra resource has been chosen, because in order to set the reverse name, the IP(s) of the instance have to be known. And that's only the case after the instance has been created.

The syntax is like this:

// Define reverse name for main IPv4
resource "vultr_reverse_name" "example_v4" {
  instance_id = "${vultr_instance.example.id}"
  ip          = "${vultr_instance.example.ipv4_address}"
  name        = "example.com"
}

// Define reverse name for main IPv6
resource "vultr_reverse_name" "example_v6" {
  instance_id = "${vultr_instance.example.id}"
  ip          = "${vultr_instance.example.ipv6_addresses[0]}"
  name        = "example.com"
}

As you see, it works for IPv4 and IPv6 likewise. (Although internally they are handled by two different API endpoints. But the behavior as observed by the is very similar. That's why I've decided to combine the IPv4 and IPv6 case into one resource type.)

When destroying an IPv4 reverse name resource, nothing actually happens. That's because there is no API endpoint by Vultr to "restore the default name".

I think this resolves #34 and #56.

cimnine added 2 commits June 12, 2019 02:49
It works for IPv4 and IPv6 likewise.
An extra resource has been chosen, because in order to set the
reverse name, the IP(s) of the instance have to be known. And
that's only after they have been created.

When an IPv4 reverse name is deleted, nothing really happens.
This is because there is not API of Vultr to 'reset' the reverse
name.
@cimnine cimnine changed the title Implements 'vultr_reverse_name' resource Adds a 'vultr_reverse_name' resource Jun 12, 2019
@squat
Copy link
Owner

squat commented Jun 12, 2019

@cimnine thank you for making the PR! I made a few notes for small changes and I have one question about the name attribute. Otherwise this looks great!

vultr/resource_reverse_name.go Outdated Show resolved Hide resolved
vultr/resource_reverse_name.go Outdated Show resolved Hide resolved
vultr/resource_reverse_name.go Outdated Show resolved Hide resolved
vultr/resource_reverse_name.go Outdated Show resolved Hide resolved
vultr/resource_reverse_name.go Outdated Show resolved Hide resolved
vultr/resource_reverse_name.go Outdated Show resolved Hide resolved
@cimnine
Copy link
Author

cimnine commented Jun 12, 2019

Thank you for your feedback!

I've implemented all your suggestions and added some additional validation.

Because adding additional validation required two external dependencies, and glide updates all dependencies when adding new ones, this PR suddenly got huge :-/

Maybe it's time to move on and go mod init github.com/squat/terraform-provider-vultr 😉

@squat
Copy link
Owner

squat commented Jun 12, 2019

Hmm I don’t believe that adding the validation dependency really needs 9,000,000 new lines of code, not diff’d lines but added lines. Can you please try make vendor to remove the unneeded files?

cimnine added 6 commits June 12, 2019 12:05
Command used:

```bash
glide get \
  --quick \
  -v \
  "golang.org/x/net/idna" \
  "github.com/hashicorp/terraform/helper/validation"
```
Even if it's technically speaking not required, this resource
doesn't make sense if isnt'.
For querying existing reverse names without declaring them
through terraform.
@cimnine
Copy link
Author

cimnine commented Jun 12, 2019

Unfortunately I've found it impossible to pass the build and have less code changes in vendor. (Or I just don't get how.) Still, by excluding nested vendor directories, I've managed to remove about 2 million loc. But there are still plenty left.

glide get -v "golang.org/x/net/idna" "github.com/hashicorp/terraform/helper/validation"

# tried, but doesn't work on travis:
glide get --quick -v "golang.org/x/net/idna" "github.com/hashicorp/terraform/helper/validation"

I've used the command above. Maybe you could give it a try?

We could argue if it's really necessary to add these dependencies. The IP checker isn't, that's trivial to implement. But the conversion between IDN and ASCII domain name representations is not easy to implement. And I believe that conversion is necessary in order to reliably compare whether domain names have changed.

@squat
Copy link
Owner

squat commented Jun 12, 2019

I’ll take a look at the vendoring commit

@cimnine
Copy link
Author

cimnine commented Jun 24, 2019

As you might have seen I've went ahead (maybe too far?) and presented a way that creates less changes to the code base by migrating over to the go mod ecosystem.

Feel free to close these PRs anytime should you not be comfortable with the way I was approaching things.

~Chris

@cimnine cimnine closed this Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reverse DNS and reserved IP functionality
2 participants