Problem getting started with Terraform and OpenStack

Hi,

I’m trying to get started with Terraform and Openstack. I have no experience using it and most tutorials seem to assume AWS. However, we have our own OpenStack installation.

I’m trying to follow this tutorial:

So far, I’ve got this definition:

#OS_DEBUG=1 
#TF_LOG=DEBUG
# Configure the OpenStack Provider
provider "openstack" {
  user_name   = "rdu"
  application_credential_id = "xxx"
  application_credential_secret = "yyy"
  tenant_name = "www-prod"
  auth_url    = "https://keystone.service.auth.url/v3"
  region      = "here"
}

resource "openstack_compute_instance_v2" "web" {
  count = "1"
  name = www-web01-prod"
  image_name = "CentOS 7.6"
  flavor_id = "0420ef5b-1db7-4465-b4d9-16e9472397c9"
  key_pair = "rdu-rsa-pub"
  security_groups = ["default"]
  network {
    name = "frontend_network"
  }
}

saved as ww.tf

terraform validate says:
Success! The configuration is valid.

However, when I run “terraform plan”, I get:

Error: Resource not found

  on ww.tf line 4, in provider "openstack":
   4: provider "openstack" {

terraform providers does list openstack:

.
└── provider.openstack

Obviously, there’s something very wrong here, but I have no idea what it is.

As it happens, posting a problem to a forum usually makes the problem resolve itself.

I didn’t realize that it uses the openstack python utilities and for these to work, I have to activate the correct virtual env and set an environment variable for the correct “cloud”.