Newer
Older
# is created in internal-network module and called in root module
variable "internal_subnet_id" {type = "string"}
# is created in key-pair module and called in root module
variable "key_pair" {type = "string"}
data "openstack_images_image_v2" "compute" {
name = var.image_compute
most_recent = true
}
resource "openstack_compute_instance_v2" "compute" {
depends_on = [var.internal_subnet_id]
name = "c${count.index}"
image_id = data.openstack_images_image_v2.compute.id
security_groups = ["default"]
count = var.compute_node_count
user_data = <<-EOF
#cloud-config
runcmd:
- [ bash, -xc, 'echo DEBUG: empty user_data var: add post instantiation steps here' ]
# defines the networks of the instance
network {
}
# output
output "id" {
value = openstack_compute_instance_v2.compute.*.id
}
output "image_id" {
value = data.openstack_images_image_v2.compute.id
}
output "network" {
value = zipmap(openstack_compute_instance_v2.compute.*.name, openstack_compute_instance_v2.compute.*.network)
}