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

IP assignment failure after applying second time #1264

Closed
nikita-vanyasin opened this issue Nov 10, 2024 · 2 comments
Closed

IP assignment failure after applying second time #1264

nikita-vanyasin opened this issue Nov 10, 2024 · 2 comments
Labels

Comments

@nikita-vanyasin
Copy link

Bug Report


Describe the bug

In few minutes after creating a droplet, I've tried to plan and apply again.
Somehow the provider tries to move reserved IP to 'default' project, although it was explicetely assigned to another project.

Affected Resource(s)

  • digitalocean_project
  • digitalocean_reserved_ip

Expected Behavior

Should be no change in IP assignment.

Actual Behavior

Looks like 'floatingip' appeared in my state although I've never requested it. Second plan/apply tries to replace it with reservedip.

Plan output:

  # digitalocean_project.jaysearch-prod will be updated in-place
  ~ resource "digitalocean_project" "reducted-prod" {
        id          = "<reducted>"
        name        = "tf-managed-1"
      ~ resources   = [
          - "do:floatingip:161.<reducted>.96",
          + "do:reservedip:161.<reducted>.96",
            # (1 unchanged element hidden)
        ]
        # (7 unchanged attributes hidden)
    }

Apply error:

digitalocean_project.reducted-prod: Modifying... [id=9227bb8a-c2e5-4d71-98cb-37f31679d3ef]
╷
│ Error: Error assigning resources to default project: Error assigning resources: POST https://api.digitalocean.com/v2/projects/<reducted>/resources: 412 (request "eefac58c-3ff3-4ad7-99eb-d5e674681abf") Cannot move a Reserved IP with an associated Droplet. Move the Droplet instead
│
│   with digitalocean_project.reducted-prod,
│   on digitalocean.tf line 26, in resource "digitalocean_project" "reducted-prod":
│   26: resource "digitalocean_project" "reducted-prod" {
│

Steps to Reproduce

Terraform Configuration Files


resource "digitalocean_project" "reducted-prod" {
  name        = "tf-managed-1"
  description = ""
  purpose     = "Infra for reducted"
  resources = [
    digitalocean_droplet.reducted1.urn,
    digitalocean_reserved_ip.reducted-ip.urn
  ]
}

# ...

resource "digitalocean_reserved_ip" "reducted-ip" {
  droplet_id = digitalocean_droplet.reducted1.id
  region     = digitalocean_droplet.reducted1.region
}

output "jaysearch1-reserved-ip" {
  # this address should be used for A record in DNS
  value = digitalocean_reserved_ip.reducted-ip.ip_address
}

# ...

Debug Output
Will send via DigitalOcean support ticket

@andrewsomething
Copy link
Member

Hi @nikita-vanyasin,

Thanks for raising this issue. It is a duplicate of #1031. This is a problem with the DigitalOcean projects API following the rename of floating IPs to reserved IPs. If you assign a reserved IP, the API response returns the URN in floating IP format.

As a work around, you can use the floating IP format in the project assignment:

resource "digitalocean_project_resources" "example" {
  project = digitalocean_project.example.id
  resources = [
    format("do:floatingip:%s", digitalocean_reserved_ip.example.ip_address)
  ]
}

Any updates will be shared in #1031

Somehow the provider tries to move reserved IP to 'default' project, although it was explicetely assigned to another project.

When assigned to a Droplet, reserved IPs always belong to the same project as the Droplet. This happens at the API level and is not something controlled by the Terraform provider.

@nikita-vanyasin
Copy link
Author

Thanks @andrewsomething, workaround worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants