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

Get unattached reserved_ip in data #1049

Open
AAverin opened this issue Oct 12, 2023 · 2 comments
Open

Get unattached reserved_ip in data #1049

AAverin opened this issue Oct 12, 2023 · 2 comments
Labels
do-api Depends on changes to the DigitalOcean API

Comments

@AAverin
Copy link

AAverin commented Oct 12, 2023

Is your feature request related to a problem? Please describe.

If reserved_ip resource is managed by terraform it ends up in the state. Then destroying such infrastructure results in destruction of the reserved ip too.
I would like to keep my reserved ip in case I want to tear down and recreate the whole setup, but still have it accessible on the same production ip.
A way to do that could be to remove resource from terraform state and have data instead.

data "digitalocean_reserved_ip" "nomad_bastion" {
  ip_address = digitalocean_droplet.nomad_bastion.ipv4_address

  depends_on = [
    resource.digitalocean_droplet.nomad_bastion
  ]
}

resource "digitalocean_reserved_ip_assignment" "bastion_static_ip" {
  ip_address = data.digitalocean_reserved_ip.nomad_bastion.ip_address
  droplet_id = digitalocean_droplet.nomad_bastion.id

  depends_on = [
    data.digitalocean_reserved_ip.digitalocean_droplet.nomad_bastion,
    resource.digitalocean_droplet.nomad_bastion
  ]
}

Issue is that ip_address field is required on data.digitalocean_reserved_ip and it is not possible to just get already created reserved_ip by name to then assign it to the droplet.

Describe the solution you'd like

ip_address field should be marked as optional and data.digitalocean_reserved_ip should provide access to created reserved ip by name without ip_address, basically allowing to get unassigned reserved_ip.

Describe alternatives you've considered

Additional context

@AAverin AAverin closed this as completed Oct 12, 2023
@AAverin AAverin reopened this Oct 12, 2023
@andrewsomething
Copy link
Member

Currently DigitalOcean reserved IPs do not have a "name." The only unique identifier for the reserved IP is the IP address itself. In order to retrieve information about the reserved IP from the DigitalOcean, you must supply the IP.

https://docs.digitalocean.com/reference/api/api-reference/#operation/reservedIPs_get

@AAverin
Copy link
Author

AAverin commented Oct 13, 2023

@andrewsomething Why would I need to get a reserved IP if I already know it? What's the point of it?

@andrewsomething andrewsomething added the do-api Depends on changes to the DigitalOcean API label Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-api Depends on changes to the DigitalOcean API
Projects
None yet
Development

No branches or pull requests

2 participants