latitudesh / terraform-provider-latitudesh

Latitude.sh Terraform Provider
https://registry.terraform.io/providers/latitudesh/latitudesh/latest/docs
Mozilla Public License 2.0
10 stars 4 forks source link

Cannot parse acknowledgment of server being created #43

Closed mccjul closed 11 months ago

mccjul commented 1 year ago

Bug Report

Describe the bug

When trying to deploy a server on latitude with terraform I run into this error:

Error: json: cannot unmarshal string into Go struct field ServerProject.data.attributes.project.id of type int64

The server I specify is actually deployed (I can see it on the dashboard), but the terraform failed and so is not reflected in the tfstate. I then try to terraform import latitudesh_server.<resource_name> <project id that I get from dashboard> and get the same issue.

Affected Resource(s)

Expected Behavior

The plan should be applied and the the tfstate should reflect that the server has been deployed.

Actual Behavior

See bug description.

Steps to Reproduce

  1. write a terraform file with a latitudesh_server
  2. terraform apply

Terraform Configuration Files

terraform {
  required_providers {
    latitudesh = {
      source  = "latitudesh/latitudesh"
      version = "~> 0.2.7"
    }
  }
}

variable "latitudesh_token" {
  description = "Latitude.sh API token"
  sensitive   = true
}

provider "latitudesh" {
  auth_token = var.latitudesh_token
}

resource "latitudesh_project" "test_project" {
  name        = "test_project"
  description = "test_project"
  environment = "Development"
}

resource "latitudesh_server" "bonkers" {
  hostname         = "bonkers"
  operating_system = "ubuntu_22_04_x64_lts"
  plan             = "c2-small-x86"
  project          = latitudesh_project.test_project.id
  site             = "ASH"
  ssh_keys         = []
} 

Terraform version

terraform --version                    
Terraform v1.6.0
on darwin_arm64
+ provider registry.terraform.io/latitudesh/latitudesh v0.2.7

Debug Output

latitudesh_server.bonkers: Creating...
latitudesh_server.bonkers: Still creating... [10s elapsed]
╷
│ Error: json: cannot unmarshal string into Go struct field ServerProject.data.attributes.project.id of type int64
│ 
│   with latitudesh_server.bonkers,
│   on latitudesh.tf line 25, in resource "latitudesh_server" "bonkers":
│   25: resource "latitudesh_server" "bonkers" {
│ 
ynhummel commented 1 year ago

Hello @mccjul, thank you for your contribution, and I apologize for the delay. I've been trying to reproduce your error, but with no success. Is there any other information you can provide to help us? Perhaps setting the TF_LOG environment variable to a level that provides more information.

ynhummel commented 11 months ago

At the time, I could not reproduce the error, but it should be solved with our latest update at https://github.com/latitudesh/terraform-provider-latitudesh/releases/tag/v0.2.9 now that we have changed our server's project type definition. I'll be closing this issue, but feel free to reopen it if the error persists.

Thanks for your contribution!