Skip to content

Commit b2126e0

Browse files
wtripp180901sjpb
authored andcommitted
compute volumes now attached creation
1 parent 63724c4 commit b2126e0

File tree

1 file changed

+8
-21
lines changed
  • environments/skeleton/{{cookiecutter.environment}}/terraform/compute

1 file changed

+8
-21
lines changed

environments/skeleton/{{cookiecutter.environment}}/terraform/compute/nodes.tf

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ resource "openstack_blockstorage_volume_v3" "compute" {
2020
size = var.volumes[each.value.volume].size
2121
}
2222

23+
resource "openstack_compute_volume_attach_v2" "compute" {
24+
25+
for_each = local.all_compute_volumes
26+
27+
instance_id = openstack_compute_instance_v2.compute["${each.value.node}"].id
28+
volume_id = openstack_blockstorage_volume_v3.compute["${each.key}"].id
29+
}
30+
2331
resource "openstack_networking_port_v2" "compute" {
2432

2533
for_each = toset(var.nodes)
@@ -48,27 +56,6 @@ resource "openstack_compute_instance_v2" "compute" {
4856
image_id = var.image_id
4957
flavor_name = var.flavor
5058
key_pair = var.key_pair
51-
52-
# root device:
53-
block_device {
54-
uuid = var.image_id
55-
source_type = "image"
56-
destination_type = var.volume_backed_instances ? "volume" : "local"
57-
volume_size = var.volume_backed_instances ? var.root_volume_size : null
58-
boot_index = 0
59-
delete_on_termination = true
60-
}
61-
62-
# additional volumes:
63-
dynamic "block_device" {
64-
for_each = var.volumes
65-
content {
66-
destination_type = "volume"
67-
source_type = "volume"
68-
boot_index = -1
69-
uuid = openstack_blockstorage_volume_v3.compute["${each.key}-${block_device.key}"].id
70-
}
71-
}
7259

7360
network {
7461
port = openstack_networking_port_v2.compute[each.key].id

0 commit comments

Comments
 (0)