terraform-provider-openstack / terraform-provider-openstack

Terraform OpenStack provider
https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs
Mozilla Public License 2.0
380 stars 363 forks source link

Refactor compute_instance_v2 microversion support #1059

Open ozerovandrei opened 4 years ago

ozerovandrei commented 4 years ago

We should refactor https://github.com/terraform-providers/terraform-provider-openstack/blob/master/openstack/resource_openstack_compute_instance_v2.go to make microversion selection more clear.

elafontaine commented 4 years ago

If you also take into consideration that the policies are hard coded, could you instead use the one available in Nova ? Or don't even try to validate them, use 2.15 if it's available and let Nova decide if the policy apply or not ?

I'm saying this as I want to use terraform openstack plug-in for server groups with a policy we have on our side "custom-policy-for-failure-domain" (not real, fake one). I've put the terraform in debug and it used 2.1

So somethine like the following should trigger to use nova-api at least 2.15 and shouldn't be parsed when sent to Nova.

resource "openstack_compute_servergroup_v2" "test-sg" {
  name     = "my-sg"
  policies = ["custom-policy-for-failure-domain"]
}

Would you prefer I open up an other issue instead?

ozerovandrei commented 4 years ago

I guess we can also provide optional microversion parameter that can be checked against available OpenStack service API versions and set into client.