From 401d2f1bb9fb81901f076884d8851b5a7364d9b7 Mon Sep 17 00:00:00 2001 From: Nacho Valera Date: Mon, 3 Apr 2023 12:19:51 +0100 Subject: [PATCH] Support multiple EBS volume types & set default to less-expensive gp3. PR #77 --- main.tf | 1 + variables.tf | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/main.tf b/main.tf index 02599aa..f16e9c8 100644 --- a/main.tf +++ b/main.tf @@ -84,6 +84,7 @@ resource "aws_instance" "default" { content { encrypted = var.ebs_block_device_encrypted volume_size = var.ebs_block_device_volume_size + volume_type = var.root_block_device_volume_type delete_on_termination = var.ebs_delete_on_termination device_name = var.ebs_device_name } diff --git a/variables.tf b/variables.tf index ae614c2..6521ad4 100644 --- a/variables.tf +++ b/variables.tf @@ -56,6 +56,16 @@ variable "root_block_device_volume_size" { description = "The volume size (in GiB) to provision for the root block device. It cannot be smaller than the AMI it refers to." } +variable "root_block_device_volume_type" { + type = string + default = "gp3" + description = "The volume type for the EBS root volume" + validation { + condition = contains(["standard", "gp2", "gp3", "io1", "io2", "sc1", "st1"], var.root_block_device_volume_type) + error_message = "The root volume must specify a supported EBS type" + } +} + variable "disable_api_termination" { type = bool description = "Enable EC2 Instance Termination Protection"