Started to add disks modules.
This commit is contained in:
@@ -32,9 +32,9 @@ locals {
|
|||||||
},
|
},
|
||||||
"k8s-wrkr" = {
|
"k8s-wrkr" = {
|
||||||
base-image = var.ubuntu-ami
|
base-image = var.ubuntu-ami
|
||||||
aws-ec2-type = var.t2-medium-4gib-2vcpu
|
aws-ec2-type = var.c5a-xlarge-amd-8gib-4vcpu
|
||||||
subnet-ids = local.k8s-subnets-ids
|
subnet-ids = local.k8s-subnets-ids
|
||||||
disk-size = 20
|
disk-size = 32
|
||||||
num = 2
|
num = 2
|
||||||
},
|
},
|
||||||
"test" = {
|
"test" = {
|
||||||
@@ -46,7 +46,7 @@ locals {
|
|||||||
},
|
},
|
||||||
"nfs" = {
|
"nfs" = {
|
||||||
base-image = var.ubuntu-ami
|
base-image = var.ubuntu-ami
|
||||||
aws-ec2-type = var.t2-micro-1gib-1vcpu
|
aws-ec2-type = var.t3a-medium-amd-4gib-2vcpu
|
||||||
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
|
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
|
||||||
subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_4"].id]
|
subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_4"].id]
|
||||||
num = 1
|
num = 1
|
||||||
@@ -62,6 +62,27 @@ locals {
|
|||||||
num = 1
|
num = 1
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disks = {
|
||||||
|
"zfs-64g" = {
|
||||||
|
num = 1,
|
||||||
|
size = 64
|
||||||
|
availability_zone = local.nfs-subnets[0].availability_zone
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
disk-mounts = [
|
||||||
|
{
|
||||||
|
# TODO make this attach field work.
|
||||||
|
attach = false
|
||||||
|
ec2-id = module.nodes["nfs"].nodes[0].id,
|
||||||
|
disk-group = "zfs-64g"
|
||||||
|
# TODO also make sure that get drive letters or whetever still works. did
|
||||||
|
# it ever work?
|
||||||
|
drive-letters = ["g"]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
install-qemu-agent = false
|
install-qemu-agent = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +150,23 @@ resource "aws_key_pair" "key" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module "disks" {
|
||||||
|
for_each = local.disks
|
||||||
|
source = "./modules/aws-disks"
|
||||||
|
availability_zone = each.value.availability_zone
|
||||||
|
size = each.value.size
|
||||||
|
num = each.value.num
|
||||||
|
prefix = each.key
|
||||||
|
}
|
||||||
|
|
||||||
|
module "disk-mounts" {
|
||||||
|
source = "./modules/aws-disk-mounts"
|
||||||
|
disks = module.disks[element(local.disk-mounts, count.index).disk-group].disks
|
||||||
|
ec2-id = element(local.disk-mounts, count.index).ec2-id
|
||||||
|
drive-letters = try(element(local.disk-mounts, count.index).drive-letters, null)
|
||||||
|
count = length(local.disk-mounts)
|
||||||
|
}
|
||||||
|
|
||||||
resource "aws_ebs_volume" "zfs" {
|
resource "aws_ebs_volume" "zfs" {
|
||||||
# TODO REM look at types.
|
# TODO REM look at types.
|
||||||
availability_zone = local.nfs-subnets[0].availability_zone
|
availability_zone = local.nfs-subnets[0].availability_zone
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
resource "aws_volume_attachment" "mount-volume" {
|
||||||
|
device_name = "/dev/sd${element(var.drive-letters, count.index)}"
|
||||||
|
instance_id = var.ec2-id
|
||||||
|
count = length(var.disks)
|
||||||
|
volume_id = element(var.disks, count.index).id
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
variable "drive-letters" {
|
||||||
|
default = ["f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
|
||||||
|
description = "These drive letters will be used when arraching disks to EC2 instance with `ec2-id'"
|
||||||
|
type = list(string)
|
||||||
|
nullable = false
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "disks" {
|
||||||
|
description = "An array of disks to attach to the EC2 isntance with `ec2-id`"
|
||||||
|
type = list
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ec2-id" {
|
||||||
|
description = "The ID of the EC@ instance to attach the drives to."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
resource "aws_ebs_volume" "disks" {
|
||||||
|
availability_zone = var.availability_zone
|
||||||
|
size = var.size
|
||||||
|
count = var.num
|
||||||
|
encrypted = true
|
||||||
|
tags = {
|
||||||
|
Name = "${var.prefix}-${count.index}"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
output "disks" {
|
||||||
|
value = aws_ebs_volume.disks
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
variable "availability_zone" {
|
||||||
|
description = "The availability zone this disk will reside in. This AZ is applied to all 'num' disks."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "num" {
|
||||||
|
description = "The number of disks to be created with this config."
|
||||||
|
type = number
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "prefix" {
|
||||||
|
description = "This prefix will be used in the name of each disk created with this module. If the prefix is 'zfs', then it will create disks with names, zfs-0 and zfs-1."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "size" {
|
||||||
|
description = "The size of the disk in GB."
|
||||||
|
type = number
|
||||||
|
}
|
||||||
@@ -200,6 +200,21 @@ variable "t2-xlarge-16gib-4vcpu" {
|
|||||||
default = "t2.xlarge"
|
default = "t2.xlarge"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "t3a-medium-amd-4gib-2vcpu" {
|
||||||
|
description = "t3a.medium EC2 instance on AMD with GiB mem and 2 vCPUs."
|
||||||
|
default = "t3a.medium"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "t3a-large-amd-8gib-2vcpu" {
|
||||||
|
description = "t3a.large EC2 instance on AMD with 8 GiB mem and 2 vCPUs."
|
||||||
|
default = "t3a.large"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "c5a-xlarge-amd-8gib-4vcpu" {
|
||||||
|
description = "c5a.xlarge EC2 instance on AMD with 8 GiB mem and 4 vCPUs."
|
||||||
|
default = "c5a.xlarge"
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Libvirt Images
|
# Libvirt Images
|
||||||
# These variables are really more like constants. Using variables improves
|
# These variables are really more like constants. Using variables improves
|
||||||
|
|||||||
Reference in New Issue
Block a user