6

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}"
  }
}
ydaetskcoR
  • 53,225
  • 8
  • 158
  • 177
Vittal Angadi
  • 91
  • 2
  • 3

3 Answers3

9

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.

Ivan Hristov
  • 3,046
  • 2
  • 25
  • 23
  • 1
    Thank you! This literally saved my butt. The drive on my flavour was smaller than the image I was trying to put on it. I would have never figured it out without this flag! – llevar Apr 21 '17 at 18:44
  • Many Thanks @Ivan! I think this should be marked as an answer. – harshavmb Jun 21 '18 at 07:15
1

From your config:

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

You are assigning name but providing network id.

Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
leor
  • 11
  • 1
0

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).

Misko
  • 1,542
  • 2
  • 19
  • 31