dogtag-IaC/dtca.tf

92 lines
3.1 KiB
HCL

# Create network ports
resource "openstack_networking_port_v2" "dtcaport" {
name = "${var.caname}-sunet-se-port"
network_id = data.openstack_networking_network_v2.public.id
# A list of security group ID
security_group_ids = [
data.openstack_networking_secgroup_v2.sshfromjumphosts.id,
data.openstack_networking_secgroup_v2.allegress.id
]
admin_state_up = "true"
#lifecycle {
# prevent_destroy = true
#}
}
resource "openstack_networking_port_v2" "dtcadbport" {
name = "${var.cadbname}-sunet-se-port"
network_id = data.openstack_networking_network_v2.public.id
# A list of security group ID
security_group_ids = [
data.openstack_networking_secgroup_v2.sshfromjumphosts.id,
data.openstack_networking_secgroup_v2.allegress.id
]
admin_state_up = "true"
#lifecycle {
# prevent_destroy = true
#}
}
# Create volumes
resource "openstack_blockstorage_volume_v3" "cavolumeboot" {
name = "${var.caname}-sunet-se-vol"
description = "OS volume for ${var.caname}"
size = 100
image_id = data.openstack_images_image_v2.caimage.id
enable_online_resize = true # Allow us to resize volume while attached.
}
resource "openstack_blockstorage_volume_v3" "cadbvolumeboot" {
name = "${var.cadbname}-sunet-se-vol"
description = "OS volume for ${var.cadbname}"
size = 100
image_id = data.openstack_images_image_v2.caimage.id
enable_online_resize = true # Allow us to resize volume while attached.
}
# Create ca instance
resource "openstack_compute_instance_v2" "dtca" {
name = "${var.caname}.sunet.se"
flavor_id = data.openstack_compute_flavor_v2.b2c2r4.id
key_pair = data.openstack_compute_keypair_v2.manderssonpub.id
security_groups = [
data.openstack_networking_secgroup_v2.sshfromjumphosts.name,
data.openstack_networking_secgroup_v2.allegress.name
]
network {
port = resource.openstack_networking_port_v2.dtcaport.id
}
block_device {
uuid = resource.openstack_blockstorage_volume_v3.cavolumeboot.id
source_type = "volume"
destination_type = "volume"
}
}
# Create cadb instance
resource "openstack_compute_instance_v2" "dtcadb" {
name = "${var.cadbname}.sunet.se"
flavor_id = data.openstack_compute_flavor_v2.b2c2r4.id
key_pair = data.openstack_compute_keypair_v2.manderssonpub.id
security_groups = [
data.openstack_networking_secgroup_v2.sshfromjumphosts.name,
data.openstack_networking_secgroup_v2.allegress.name
]
network {
port = resource.openstack_networking_port_v2.dtcadbport.id
}
block_device {
uuid = resource.openstack_blockstorage_volume_v3.cadbvolumeboot.id
source_type = "volume"
destination_type = "volume"
}
}