Started to add disks modules.
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user