Open stillinbeta opened 6 years ago
You could use digitalocean_floating_ip
to both create and assign the IP.
It works for me:
resource "digitalocean_droplet" "foobar" {
name = "baz"
size = "s-1vcpu-1gb"
image = "ubuntu-18-04-x64"
region = "sgp1"
ipv6 = true
private_networking = true
}
resource "digitalocean_floating_ip" "foobar" {
droplet_id = "${digitalocean_droplet.foobar.id}"
region = "${digitalocean_droplet.foobar.region}"
}
Source: https://www.terraform.io/docs/providers/do/r/floating_ip.html#example-usage
Same error:
1 error(s) occurred:
* digitalocean_floating_ip.ip: 1 error(s) occurred:
* digitalocean_floating_ip.ip: Error Assigning FloatingIP (174.138.109.215) to the droplet: json: cannot unmarshal number 2928307671 into Go struct field Action.resource_id of type int
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
variable "digital_ocean_token" {}
provider "digitalocean" {
token = "${var.digital_ocean_token}"
version = "1.0.0"
}
resource "digitalocean_floating_ip" "ip" {
region = "nyc1"
droplet_id = "${digitalocean_droplet.droplet.id}"
}
resource "digitalocean_droplet" "droplet" {
name = "mastodon"
image = "ubuntu-18-04-x64"
region = "nyc1"
size = "1gb"
}
Could you try:
provider.digitalocean v1.0.2
That's what I'm using.
Thanks.
It still crashes for me:
1 error(s) occurred:
* digitalocean_floating_ip.ip: 1 error(s) occurred:
* digitalocean_floating_ip.ip: Error Assigning FloatingIP (138.197.231.156) to the droplet: json: cannot unmarshal number 2328225692 into Go struct field Action.resource_id of type int
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
zsh: exit 1 terraform apply tf.plan
terraform apply tf.plan 0.89s user 0.57s system 4% cpu 36.020 total
Just tested and it works for me:
provider "digitalocean" {}
resource "digitalocean_floating_ip" "ip" {
region = "nyc1"
droplet_id = "${digitalocean_droplet.droplet.id}"
}
resource "digitalocean_droplet" "droplet" {
name = "mastodon"
image = "ubuntu-18-04-x64"
region = "nyc1"
size = "1gb"
}
Output:
digitalocean_droplet.droplet: Creation complete after 2m4s
digitalocean_floating_ip.ip: Creating...
digitalocean_floating_ip.ip: Still creating... (10s elapsed)
digitalocean_floating_ip.ip: Creation complete after 19s
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
I tried this again on my macbook and on a x86 linux cloud instance, and it worked in both places. My guess, therefore, is that somehow this is an ARM-specific bug. Unless you have an ARM machine, I'm probably on my own to fix this.
Thanks for that additional info on the platform. My suspicion that the Action.resource_id
is larger than what fits in an int
on your platform. If that's the case, this would need to be solved in github.com/digitalocean/godo
@stillinbeta I just tested with version 1.0.0 and 1.0.2 on my Raspberry Pi 3 and am unable to reproduce.
I'm wondering if Andrew is right in the specific int id is too large? Not sure where to go with this one.
While running on my ARM platform i encountered the same issue. The issue is not apparent on my x86 workstation.
Same issue on Windows. After checking the Terraform binary, it seems I somehow installed the 32 bits version, was solved after using 64 bits.
my arm laptop is 32 bits, so that's probably the throughline.
@stillinbeta @martinaamodt did switching to the 64 bit arm binary solve this?
Terraform Version
Affected Resource(s)
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
Terraform Configuration Files
Debug Output
https://gist.github.com/stillinbeta/20d7b6c52cb59a839b47ce0997451ebb
Panic Output
none
Expected Behavior
The floating IP address should be assigned and exit cleanly.
Actual Behavior
Behind the scenes the floating IP is assigned to the appropriate droplet, but it then errors out. Because of the error, the floating IP isn't marked as assigned in the terraform state, so it will try to apply the assignment again next time Terraform is executed.
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
digital_ocean_api_key
in e.g. terraform.tfvarsterraform apply
Important Factoids
none
References
none