digitalocean / digitalocean/godo
[BUG] Error creating droplet: cannot unmarshal large number into Go int field
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 389
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 15
Description
# Bug Report
## Describe the bug
When attempting to create a `digitalocean_droplet` with an attached `digitalocean_volume`, Terraform fails with a `json: cannot unmarshal number ... into Go struct field LinkAction.links.actions.id of type int` error. This suggests an internal type conversion issue within the provider when parsing large integer IDs returned by the DigitalOcean API.
The specific number (`2771062950` in the last attempt) exceeds the typical maximum value for a 32-bit Go integer, leading to a deserialization failure.
### Affected Resource(s)
- `digitalocean_droplet`
- `digitalocean_volume` (implicitly, as the error occurs when the droplet resource is created with the volume attached)
### Expected Behavior
The `digitalocean_droplet.vault_server` should be created successfully, and the `digitalocean_volume.vault_data_volume` should be attached to it without any unmarshalling errors.
### Actual Behavior
`terraform apply` fails during the creation of the `digitalocean_droplet` with the following error:
digitalocean_droplet.vault_server: Creating...
╷
│ Error: Error creating droplet: json: cannot unmarshal number 2771062950 into Go struct field LinkAction.links.actions.id of type int
│
│ with digitalocean_droplet.vault_server,
│ on main.tf line 101, in resource "digitalocean_droplet" "vault_server":
│ 101: resource "digitalocean_droplet" "vault_server" {
│
╵
*(The exact numerical ID in the error message changes with each attempt but consistently shows a value greater than a 32-bit integer maximum.)*
### Steps to Reproduce
1. Ensure `main.tf`, `variables.tf`, and `terraform.tfvars` are configured as provided in the "Relevant Configuration" section below.
2. Run `terraform init -upgrade`
3. Run `terraform apply`
**Terraform Configuration Files**
```terraform
# main.tf (relevant parts)
terraform {
required_version = ">= 1.6.3"
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "2.66.0" # Explicitly set to latest stable
}
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
vault = {
source = "hashicorp/vault"
version = "~> 3.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.0"
}
}
backend "s3" {
bucket = "terraform-state-bucket1"
key = "terraform.tfstate"
endpoints = {
s3 = "[https://nyc3.digitaloceanspaces.com](https://nyc3.digitaloceanspaces.com)"
}
skip_credentials_validation = true
skip_requesting_account_id = true
skip_metadata_api_check = true
skip_region_validation = true
skip_s3_checksum = true
use_fips_endpoint = true
region = "us-east-1"
}
}
provider "digitalocean" {
token = var.do_token
spaces_access_id = var.access_id
spaces_secret_key = var.secret_key
version = "2.66.0" # Also explicitly set here
}
resource "digitalocean_droplet" "vault_server" {
image = "ubuntu-22-04-x64"
name = "vault-server"
region = var.region
size = "s-1vcpu-2gb"
ssh_keys = [var.ssh_key_id]
volume_ids = [digitalocean_volume.vault_data_volume.id]
user_data = <<-EOT
#!/bin/bash
# (Full cloud-init script for Vault installation and volume setup as previously provided)
sudo apt-get update -y && sudo apt-get install -y unzip curl gdisk xfsprogs
curl -fsSL [https://releases.hashicorp.com/vault/1.15.2/vault_1.15.2_linux_amd64.zip](https://releases.hashicorp.com/vault/1.15.2/vault_1.15.2_linux_amd64.zip) -o vault.zip
unzip vault.zip
sudo mv vault /usr/local/bin/vault
sudo useradd --system --home /etc/vault.d --shell /bin/false vault
VOLUME_DEVICE="/dev/sdb" # Assuming /dev/sdb for attached block storage
MOUNT_POINT="/mnt/vault_data"
VAULT_DATA_PATH="${MOUNT_POINT}/vault/data"
# ... partitioning, formatting, fstab, mounting logic ...
sudo mkdir -p /etc/vault.d "${VAULT_DATA_PATH}"
sudo chown -R vault:vault /etc/vault.d "${MOUNT_POINT}"
sudo tee /etc/vault.d/vault.hcl > /dev/null < /dev/null <
Contributor guide
Assessment
This issue has not been assessed yet.