Skip to content

Commit b34ad38

Browse files
committed
terraform/AWS: Make the EBS volume type selectable
We can get better throughput with the newer device types, helping tests run to completion more quickly. The default is left at gp2, which is free in many configurations. The "io1" and "io2" types can be added as well, but they require additional aws_ebs_volume attributes (iops, for example), and do not support volume size smaller than 4GiB. (ie, there is a little more complexity). Signed-off-by: Chuck Lever <[email protected]>
1 parent f23f009 commit b34ad38

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

playbooks/roles/gen_tfvars/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ terraform_aws_instance_type: "invalid"
2727
terraform_aws_enable_ebs: False
2828
terraform_aws_ebs_num_volumes_per_instance: 0
2929
terraform_aws_ebs_volume_size: 0
30+
terraform_aws_ebs_volume_type: "invalid"
3031

3132
terraform_azure_resource_location: "invalid"
3233
terraform_azure_vm_size: "invalid"

playbooks/roles/gen_tfvars/templates/aws/terraform.tfvars.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ aws_instance_type = "{{ terraform_aws_instance_type }}"
88
aws_enable_ebs = "{{ terraform_aws_enable_ebs | lower }}"
99
aws_ebs_num_volumes_per_instance = "{{ terraform_aws_ebs_num_volumes_per_instance }}"
1010
aws_ebs_volume_size = "{{ terraform_aws_ebs_volume_size }}"
11+
aws_ebs_volume_type = "{{ terraform_aws_ebs_volume_type }}"
1112

1213
ssh_config_pubkey_file = "{{ kdevops_terraform_ssh_config_pubkey_file }}"
1314
ssh_config_user = "{{ kdevops_terraform_ssh_config_user }}"

scripts/terraform.Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ ifeq (y,$(CONFIG_TERRAFORM_AWS_ENABLE_EBS_VOLUMES))
5959
TERRAFORM_EXTRA_VARS += terraform_aws_enable_ebs='True'
6060
TERRAFORM_EXTRA_VARS += terraform_aws_ebs_num_volumes_per_instance=$(subst ",,$(CONFIG_TERRAFORM_AWS_EBS_NUM_VOLUMES_PER_INSTANCE))
6161
TERRAFORM_EXTRA_VARS += terraform_aws_ebs_volume_size=$(subst ",,$(CONFIG_TERRAFORM_TERRAFORM_AWS_EBS_VOLUME_SIZE))
62+
TERRAFORM_EXTRA_VARS += terraform_aws_ebs_volume_type=$(subst ",,$(CONFIG_TERRAFORM_AWS_EBS_VOLUME_TYPE))
6263
endif # CONFIG_TERRAFORM_AWS_ENABLE_EBS_VOLUMES
6364

6465
endif

terraform/aws/Kconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,29 @@ config TERRAFORM_AWS_EBS_NUM_VOLUMES_PER_INSTANCE
687687
default 9 if TERRAFORM_AWS_EBS_NUM_VOLUMES_PER_INSTANCE_9
688688
default 10 if TERRAFORM_AWS_EBS_NUM_VOLUMES_PER_INSTANCE_10
689689

690+
choice
691+
prompt "Type for all EBS volumes"
692+
default TERRAFORM_AWS_EBS_VOLUME_TYPE_GP2
693+
694+
config TERRAFORM_AWS_EBS_VOLUME_TYPE_GP2
695+
bool "gp2"
696+
help
697+
All extra EBS volumes are "General Purpose SSD volumes",
698+
version 2.
699+
700+
config TERRAFORM_AWS_EBS_VOLUME_TYPE_GP3
701+
bool "gp3"
702+
help
703+
All extra EBS volumes are "General Purpose SSD volumes",
704+
version 3.
705+
706+
endchoice
707+
708+
config TERRAFORM_AWS_EBS_VOLUME_TYPE
709+
string
710+
default "gp2" if TERRAFORM_AWS_EBS_VOLUME_TYPE_GP2
711+
default "gp3" if TERRAFORM_AWS_EBS_VOLUME_TYPE_GP3
712+
690713
choice
691714
prompt "Volume size to for all EBS volumes"
692715
default TERRAFORM_AWS_EBS_VOLUME_SIZE_32G

terraform/aws/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ resource "aws_instance" "kdevops_instance" {
145145
resource "aws_ebs_volume" "kdevops_vols" {
146146
count = var.aws_enable_ebs == "true" ? local.kdevops_num_boxes * var.aws_ebs_num_volumes_per_instance : 0
147147
availability_zone = var.aws_availability_region
148-
size = var.aws_ebs_volume_size
148+
size = var.aws_ebs_volume_size
149+
type = var.aws_ebs_volume_type
149150
}
150151

151152
resource "aws_volume_attachment" "kdevops_att" {

terraform/aws/vars.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ variable "aws_ebs_volume_size" {
104104
default = "4"
105105
}
106106

107+
variable "aws_ebs_volume_type" {
108+
description = "Type of each of the EBS volumes"
109+
default = "gp2"
110+
}
111+
107112
# We had to use this as aws terraform provider doesn't have a way to set
108113
# the hostname. local-exec works too, but this is what we went with.
109114
variable "user_data_enabled" {

0 commit comments

Comments
 (0)