Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Grammar checks

...

As for the contents of the file, copy and past the the example below, and replace the key-value pairs defined within locals to according to your needs:

Code Block
# main.tf
locals {
  keypair_name       = "john-cloudy-publickey" # <- REPLACE WITH CORRECT KEYPAIR NAME
  virtual_image      = "Ubuntu 22.04 NVIDIA_AI!"
  plan               = "vm.a6000.4"
  app_name           = "demo"
  instance_name      = "john-cloudy"
  instance_index     = 1
  private_networks   = ["private"]
  external_network   = "external"
  security_groups    = ["ssh"]
  instance_has_fip   = true
  extra_volume       = true
  extra_volume_size  = 512
  extra_volume2      = true
  extra_volume2_size = 512

  tags = {
    environment     = "production"
    owner           = "john-cloudy"
    deployment-tool = "terraform"
  }
}

terraform {
  required_version = ">= 0.14.0"
  required_providers {
    openstack = {
      source  = "terraform-provider-openstack/openstack"
      version = "~> 1.53.0"
    }
  }
}

data "openstack_images_image_v2" "image" {
  name        = local.virtual_image
  most_recent = true
}

data "openstack_compute_flavor_v2" "flavor" {
  name = local.plan
}

module "instance" {
  source = "./ewc-tf-module-openstack-compute"

  app_name       = local.app_name
  instance_name  = local.instance_name
  instance_index = local.instance_index
  image_id       = data.openstack_images_image_v2.image.id
  flavor_id      = data.openstack_compute_flavor_v2.flavor.id
  keypair_name   = local.keypair_name

  networks = local.private_networks

  instance_has_fip = local.instance_has_fip

  extra_volume       = local.extra_volume
  extra_volume_size  = local.extra_volume_size
  extra_volume2      = local.extra_volume2
  extra_volume2_size = local.extra_volume2_size

  security_groups = local.security_groups

  external_network_name = local.external_network

  tags = local.tags
}

...