aequitas / terraform-provider-transip

Terraform provider to manage Transip resources
https://registry.terraform.io/providers/aequitas/transip/latest/docs
MIT License
35 stars 16 forks source link

Terraform apply Error: Failed to set ID for VPS and takes to much time #58

Closed pabl-o-ce closed 2 years ago

pabl-o-ce commented 2 years ago

Hi guys, great work

I was using Terraform for create vm's in TransIP

All works beautiful the first time

then I destroy and try again to create and it take to much time and also end with this error Error: Failed to set ID for VPS

my instance resource look like this:

# Workshop defender instance
resource "transip_vps" "crowdsec_instance_defender" {
  # Add number of instances
  count                         = var.tsp_number_of_instances
  # Availability zone
  availability_zone             = "rtm0"
  # Add instances type
  product_name                  = "vps-bladevps-xs"
  # Add image type
  operating_system              = "ubuntu-22.04"
  # Add cloud-init on user-data folder
  install_text                  = file("${path.module}/user-data/workshop-blank.yml")
  # Add description name
  description                   = (count.index<9) ? "defender0${(count.index+1)}" : "defender${(count.index+1)}"
}

is something I'm doing wrong?

JoooostB commented 2 years ago

After initiating the terraform apply again, were the instances created/visible in the TransIP dashboard prior to receiving the Failed to set ID for VPS error? I'm a bit lost on which side this issue arises, as we only throw this error when no unique name can be retrieved from TransIP.

Edit: Side-note @aequitas, I don't think this needs to be retry-able anyway: https://github.com/aequitas/terraform-provider-transip/blob/1a72a5c3bfaa4aab2f5c9b6b8bc16ee5897659a0/resource_transip_vps.go#L233-L234

pabl-o-ce commented 2 years ago

I will get you some pictures in here: step 1: [success] terraform plan -var-file="terraform.tfvars" step 2: [fails] terraform apply -var-file="terraform.tfvars"

in this step I was receiving this Error: Failed to set ID for VPS from like 30 minutes of waiting for creating the vm's now I only receive a quick response show in the photo above:

Screen Shot 2022-08-07 at 11 48 54 AM

mmm... sound that have some issues with the account?

JoooostB commented 2 years ago

mmm... sound that have some issues with the account?

I'm afraid so, worth trying to create a VPS using the REST API directly:

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer [your JSON web token]" \
-d '
{
  "productName": "vps-bladevps-xs",
  "availabilityZone": "rtm0",
  "description": "defender01",
  "operatingSystem": "ubuntu-22.04",
  "installFlavour": "installer"
} 
' \
"https://api.transip.nl/v6/vps"

If that doesn't work either you've a create case to contact TransIP support. Please report back your findings, I'm rather interested in what exactly went wrong here :)

aequitas commented 2 years ago

Maybe it's a race condition where the older VPS with the same name is still lingering on the Transip API side. Creating a new VPS with the same name could maybe create a conflict then. I think this problem is reproducable on my side, maybe even possible to write a test for it. I'll have a look tomorrow.

JoooostB commented 2 years ago

I thought about that, but isn't the name generated by them in the username-vpsxxxx format? As we only set the description and need to lookup the name afterwards.

pabl-o-ce commented 2 years ago

I think this problem is reproducable on my side, maybe even possible to write a test for it.

If you want I can create what I made in a repo so you can test it on your side with your accounts

I'm afraid so, worth trying to create a VPS using the REST API directly

The token from what I read is generate from the control panel website... right? sorry I'm new on TransIP

pabl-o-ce commented 2 years ago

this is the repo: https://github.com/pabl-o-ce/transip-test If you need it :)

pabl-o-ce commented 2 years ago

Also I reproduce the same error with 20 minutes of delay:

Screen Shot 2022-08-08 at 10 22 48 AM
pabl-o-ce commented 2 years ago

seems to be a problem of the account guys sorry for the noise.. it was not filled out all information required :)

All works great now [amazing]

Thanks for the support