6
votes

I am trying to create an OpenStack instance using Terraform but I'm getting the following error:

Error applying plan:

1 error(s) occurred:

* openstack_compute_instance_v2.basic: Error creating OpenStack server: Invalid
request due to incorrect syntax or missing required parameters.

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with

but the same Terraform code does successfully create the security group, key pair and volume in my OpenStack account

Here is my Terraform code:

provider "openstack" {
  user_name = "admin"
  tenant_name = "admin"
  password  = "admin"
  auth_url  = "http://my_IP():5000/v2.0"
}
resource "openstack_blockstorage_volume_v1" "myvol" {
  name = "myvol"
  size = 1
}
resource "openstack_compute_instance_v2" "basic" {
  name = "basic"
  image_id = "8ce1c922-ad0-81a3-823ea1b0af9b"
  flavor_id = "2"
  key_pair = "tf-keypair-1"
  security_groups = ["default"]

  metadata {
    this = "that"
  }

  network {
    name = "8b510300-610a--9cc3-6e76e33395b4"
  }
  volume {
    volume_id = "${openstack_blockstorage_volume_v1.myvol.id}"
  }
}
3
Have you exported the OS_REGION_NAME name environment variable correctly? - ydaetskcoR

3 Answers

9
votes

This message was quite hard to debug up until recently. In version 0.8.8 of Terraform (more specifically the Enable HTTP Logging improvement for the OpenStack Terraform provider), the team added OS_DEBUG environmental variable to help provide more information in cases like these. One way to use it is as follows:

TF_LOG=DEBUG OS_DEBUG=1 terraform apply ...

Once I had this message because I had forgotten to add the ssh key in the OpenStack for the user I was using.

0
votes

You have to check all your parameters carefully for typos and/or incorrect values. TF does not do that for you.

This happens when you specify for example non-existent keypair or network name (e.g. n your example, you specified ID instead of name for network).

0
votes

From your config:

network { name = "8b510300-610a--9cc3-6e76e33395b4" }

You are assigning name but providing network id.