-
Notifications
You must be signed in to change notification settings - Fork 1
/
volumes.tf
42 lines (38 loc) · 1.79 KB
/
volumes.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# ---------------------------------------------------------------------------
# Trivadis AG, Infrastructure Managed Services
# Saegereistrasse 29, 8152 Glattbrugg, Switzerland
# ---------------------------------------------------------------------------
# Name.......: volumes.tf
# Author.....: Stefan Oehrli (oes) [email protected]
# Editor.....: Stefan Oehrli
# Date.......: 2020.10.14
# Revision...:
# Purpose....: Define volumes for compute instances.
# Notes......: --
# Reference..: --
# License....: Apache License Version 2.0, January 2004 as shown
# at http://www.apache.org/licenses/
# ---------------------------------------------------------------------------
# define the block volume
resource "oci_core_volume" "CreateVolume" {
count = var.host_volume_enabled == true ? var.tvd_participants : 0
availability_domain = local.availability_domain
compartment_id = var.compartment_id
display_name = var.label_prefix == "none" ? format("${local.resource_shortname}-${var.host_name}%02d-volume", count.index) : format("${var.label_prefix}-${local.resource_shortname}-${var.host_name}%02d-volume", count.index)
size_in_gbs = var.host_volume_size
freeform_tags = var.tags
dynamic "source_details" {
for_each = var.host_volume_source == "" ? [] : [1]
content {
id = var.host_volume_source
type = "volume"
}
}
}
resource "oci_core_volume_attachment" "CreateVolumeAttachment" {
count = var.host_volume_enabled == true ? var.tvd_participants : 0
attachment_type = var.host_volume_attachment_type
instance_id = oci_core_instance.compute.*.id[count.index]
volume_id = oci_core_volume.CreateVolume.*.id[count.index]
}
# --- EOF -------------------------------------------------------------------