Skip to content

Commit 1bc0487

Browse files
tbpoetkeTommycloudpossebotTommy
authored
Added support for gp3 and io2 both root and ebs volumes (fixed copy of #117) (#136)
* adding gp3 volume * fmt * Auto Format * fix variables * update modules * fix examples to be inline with new module versions * remove deprecated syntax * upgrade required terraform version * Auto Format * fix provider in examples Co-authored-by: Tommy <[email protected]> Co-authored-by: cloudpossebot <[email protected]> Co-authored-by: Tommy <[email protected]>
1 parent 2e8c529 commit 1bc0487

File tree

8 files changed

+47
-27
lines changed

8 files changed

+47
-27
lines changed

.github/auto-release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ version-resolver:
1717
- 'bugfix'
1818
- 'bug'
1919
- 'hotfix'
20-
- 'no-release'
2120
default: 'minor'
2221

2322
categories:

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Available targets:
200200

201201
| Name | Version |
202202
|------|---------|
203-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
203+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
204204
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.0 |
205205
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
206206

@@ -270,12 +270,13 @@ Available targets:
270270
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
271271
| <a name="input_disable_api_termination"></a> [disable\_api\_termination](#input\_disable\_api\_termination) | Enable EC2 Instance Termination Protection | `bool` | `false` | no |
272272
| <a name="input_ebs_device_name"></a> [ebs\_device\_name](#input\_ebs\_device\_name) | Name of the EBS device to mount | `list(string)` | <pre>[<br> "/dev/xvdb",<br> "/dev/xvdc",<br> "/dev/xvdd",<br> "/dev/xvde",<br> "/dev/xvdf",<br> "/dev/xvdg",<br> "/dev/xvdh",<br> "/dev/xvdi",<br> "/dev/xvdj",<br> "/dev/xvdk",<br> "/dev/xvdl",<br> "/dev/xvdm",<br> "/dev/xvdn",<br> "/dev/xvdo",<br> "/dev/xvdp",<br> "/dev/xvdq",<br> "/dev/xvdr",<br> "/dev/xvds",<br> "/dev/xvdt",<br> "/dev/xvdu",<br> "/dev/xvdv",<br> "/dev/xvdw",<br> "/dev/xvdx",<br> "/dev/xvdy",<br> "/dev/xvdz"<br>]</pre> | no |
273-
| <a name="input_ebs_iops"></a> [ebs\_iops](#input\_ebs\_iops) | Amount of provisioned IOPS. This must be set with a volume\_type of io1 | `number` | `0` | no |
273+
| <a name="input_ebs_iops"></a> [ebs\_iops](#input\_ebs\_iops) | Amount of provisioned IOPS. This must be set with a volume\_type of `io1`, `io2` or `gp3` | `number` | `0` | no |
274274
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | Launched EC2 instance will be EBS-optimized | `bool` | `false` | no |
275+
| <a name="input_ebs_throughput"></a> [ebs\_throughput](#input\_ebs\_throughput) | Amount of throughput. This must be set if volume\_type is set to `gp3` | `number` | `0` | no |
275276
| <a name="input_ebs_volume_count"></a> [ebs\_volume\_count](#input\_ebs\_volume\_count) | Count of EBS volumes that will be attached to the instance | `number` | `0` | no |
276277
| <a name="input_ebs_volume_encrypted"></a> [ebs\_volume\_encrypted](#input\_ebs\_volume\_encrypted) | Whether to encrypt the additional EBS volumes | `bool` | `true` | no |
277278
| <a name="input_ebs_volume_size"></a> [ebs\_volume\_size](#input\_ebs\_volume\_size) | Size of the additional EBS volumes in gigabytes | `number` | `10` | no |
278-
| <a name="input_ebs_volume_type"></a> [ebs\_volume\_type](#input\_ebs\_volume\_type) | The type of the additional EBS volumes. Can be standard, gp2 or io1 | `string` | `"gp2"` | no |
279+
| <a name="input_ebs_volume_type"></a> [ebs\_volume\_type](#input\_ebs\_volume\_type) | The type of the additional EBS volumes. Can be standard, gp2, gp3, io1 or io2 | `string` | `"gp2"` | no |
279280
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
280281
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
281282
| <a name="input_evaluation_periods"></a> [evaluation\_periods](#input\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold. | `number` | `5` | no |
@@ -306,9 +307,10 @@ Available targets:
306307
| <a name="input_region"></a> [region](#input\_region) | AWS Region the instance is launched in | `string` | `""` | no |
307308
| <a name="input_root_block_device_encrypted"></a> [root\_block\_device\_encrypted](#input\_root\_block\_device\_encrypted) | Whether to encrypt the root block device | `bool` | `true` | no |
308309
| <a name="input_root_block_device_kms_key_id"></a> [root\_block\_device\_kms\_key\_id](#input\_root\_block\_device\_kms\_key\_id) | KMS key ID used to encrypt EBS volume. When specifying root\_block\_device\_kms\_key\_id, root\_block\_device\_encrypted needs to be set to true | `string` | `null` | no |
309-
| <a name="input_root_iops"></a> [root\_iops](#input\_root\_iops) | Amount of provisioned IOPS. This must be set if root\_volume\_type is set to `io1` | `number` | `0` | no |
310+
| <a name="input_root_iops"></a> [root\_iops](#input\_root\_iops) | Amount of provisioned IOPS. This must be set if root\_volume\_type is set of `io1`, `io2` or `gp3` | `number` | `0` | no |
311+
| <a name="input_root_throughput"></a> [root\_throughput](#input\_root\_throughput) | Amount of throughput. This must be set if root\_volume\_type is set to `gp3` | `number` | `0` | no |
310312
| <a name="input_root_volume_size"></a> [root\_volume\_size](#input\_root\_volume\_size) | Size of the root volume in gigabytes | `number` | `10` | no |
311-
| <a name="input_root_volume_type"></a> [root\_volume\_type](#input\_root\_volume\_type) | Type of root volume. Can be standard, gp2 or io1 | `string` | `"gp2"` | no |
313+
| <a name="input_root_volume_type"></a> [root\_volume\_type](#input\_root\_volume\_type) | Type of root volume. Can be standard, gp2, gp3, io1 or io2 | `string` | `"gp2"` | no |
312314
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | The Security Group description. | `string` | `"EC2 Security Group"` | no |
313315
| <a name="input_security_group_enabled"></a> [security\_group\_enabled](#input\_security\_group\_enabled) | Whether to create default Security Group for EC2. | `bool` | `true` | no |
314316
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | A list of maps of Security Group rules.<br>The values of map is fully complated with `aws_security_group_rule` resource.<br>To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . | `list(any)` | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": "Allow all outbound traffic",<br> "from_port": 0,<br> "protocol": "-1",<br> "to_port": 65535,<br> "type": "egress"<br> }<br>]</pre> | no |
@@ -539,7 +541,7 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
539541

540542
[![README Footer][readme_footer_img]][readme_footer_link]
541543
[![Beacon][beacon]][website]
542-
544+
<!-- markdownlint-disable -->
543545
[logo]: https://cloudposse.com/logo-300x69.svg
544546
[docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-ec2-instance&utm_content=docs
545547
[website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-ec2-instance&utm_content=website
@@ -570,3 +572,4 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
570572
[share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/terraform-aws-ec2-instance
571573
[share_email]: mailto:?subject=terraform-aws-ec2-instance&body=https://github.com/cloudposse/terraform-aws-ec2-instance
572574
[beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-ec2-instance?pixel&cs=github&cm=readme&an=terraform-aws-ec2-instance
575+
<!-- markdownlint-restore -->

docs/terraform.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
| Name | Version |
55
|------|---------|
6-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
77
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.0 |
88
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
99

@@ -73,12 +73,13 @@
7373
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
7474
| <a name="input_disable_api_termination"></a> [disable\_api\_termination](#input\_disable\_api\_termination) | Enable EC2 Instance Termination Protection | `bool` | `false` | no |
7575
| <a name="input_ebs_device_name"></a> [ebs\_device\_name](#input\_ebs\_device\_name) | Name of the EBS device to mount | `list(string)` | <pre>[<br> "/dev/xvdb",<br> "/dev/xvdc",<br> "/dev/xvdd",<br> "/dev/xvde",<br> "/dev/xvdf",<br> "/dev/xvdg",<br> "/dev/xvdh",<br> "/dev/xvdi",<br> "/dev/xvdj",<br> "/dev/xvdk",<br> "/dev/xvdl",<br> "/dev/xvdm",<br> "/dev/xvdn",<br> "/dev/xvdo",<br> "/dev/xvdp",<br> "/dev/xvdq",<br> "/dev/xvdr",<br> "/dev/xvds",<br> "/dev/xvdt",<br> "/dev/xvdu",<br> "/dev/xvdv",<br> "/dev/xvdw",<br> "/dev/xvdx",<br> "/dev/xvdy",<br> "/dev/xvdz"<br>]</pre> | no |
76-
| <a name="input_ebs_iops"></a> [ebs\_iops](#input\_ebs\_iops) | Amount of provisioned IOPS. This must be set with a volume\_type of io1 | `number` | `0` | no |
76+
| <a name="input_ebs_iops"></a> [ebs\_iops](#input\_ebs\_iops) | Amount of provisioned IOPS. This must be set with a volume\_type of `io1`, `io2` or `gp3` | `number` | `0` | no |
7777
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | Launched EC2 instance will be EBS-optimized | `bool` | `false` | no |
78+
| <a name="input_ebs_throughput"></a> [ebs\_throughput](#input\_ebs\_throughput) | Amount of throughput. This must be set if volume\_type is set to `gp3` | `number` | `0` | no |
7879
| <a name="input_ebs_volume_count"></a> [ebs\_volume\_count](#input\_ebs\_volume\_count) | Count of EBS volumes that will be attached to the instance | `number` | `0` | no |
7980
| <a name="input_ebs_volume_encrypted"></a> [ebs\_volume\_encrypted](#input\_ebs\_volume\_encrypted) | Whether to encrypt the additional EBS volumes | `bool` | `true` | no |
8081
| <a name="input_ebs_volume_size"></a> [ebs\_volume\_size](#input\_ebs\_volume\_size) | Size of the additional EBS volumes in gigabytes | `number` | `10` | no |
81-
| <a name="input_ebs_volume_type"></a> [ebs\_volume\_type](#input\_ebs\_volume\_type) | The type of the additional EBS volumes. Can be standard, gp2 or io1 | `string` | `"gp2"` | no |
82+
| <a name="input_ebs_volume_type"></a> [ebs\_volume\_type](#input\_ebs\_volume\_type) | The type of the additional EBS volumes. Can be standard, gp2, gp3, io1 or io2 | `string` | `"gp2"` | no |
8283
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
8384
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
8485
| <a name="input_evaluation_periods"></a> [evaluation\_periods](#input\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold. | `number` | `5` | no |
@@ -109,9 +110,10 @@
109110
| <a name="input_region"></a> [region](#input\_region) | AWS Region the instance is launched in | `string` | `""` | no |
110111
| <a name="input_root_block_device_encrypted"></a> [root\_block\_device\_encrypted](#input\_root\_block\_device\_encrypted) | Whether to encrypt the root block device | `bool` | `true` | no |
111112
| <a name="input_root_block_device_kms_key_id"></a> [root\_block\_device\_kms\_key\_id](#input\_root\_block\_device\_kms\_key\_id) | KMS key ID used to encrypt EBS volume. When specifying root\_block\_device\_kms\_key\_id, root\_block\_device\_encrypted needs to be set to true | `string` | `null` | no |
112-
| <a name="input_root_iops"></a> [root\_iops](#input\_root\_iops) | Amount of provisioned IOPS. This must be set if root\_volume\_type is set to `io1` | `number` | `0` | no |
113+
| <a name="input_root_iops"></a> [root\_iops](#input\_root\_iops) | Amount of provisioned IOPS. This must be set if root\_volume\_type is set of `io1`, `io2` or `gp3` | `number` | `0` | no |
114+
| <a name="input_root_throughput"></a> [root\_throughput](#input\_root\_throughput) | Amount of throughput. This must be set if root\_volume\_type is set to `gp3` | `number` | `0` | no |
113115
| <a name="input_root_volume_size"></a> [root\_volume\_size](#input\_root\_volume\_size) | Size of the root volume in gigabytes | `number` | `10` | no |
114-
| <a name="input_root_volume_type"></a> [root\_volume\_type](#input\_root\_volume\_type) | Type of root volume. Can be standard, gp2 or io1 | `string` | `"gp2"` | no |
116+
| <a name="input_root_volume_type"></a> [root\_volume\_type](#input\_root\_volume\_type) | Type of root volume. Can be standard, gp2, gp3, io1 or io2 | `string` | `"gp2"` | no |
115117
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | The Security Group description. | `string` | `"EC2 Security Group"` | no |
116118
| <a name="input_security_group_enabled"></a> [security\_group\_enabled](#input\_security\_group\_enabled) | Whether to create default Security Group for EC2. | `bool` | `true` | no |
117119
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | A list of maps of Security Group rules.<br>The values of map is fully complated with `aws_security_group_rule` resource.<br>To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . | `list(any)` | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": "Allow all outbound traffic",<br> "from_port": 0,<br> "protocol": "-1",<br> "to_port": 65535,<br> "type": "egress"<br> }<br>]</pre> | no |

examples/complete/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ provider "aws" {
44

55
module "aws_key_pair" {
66
source = "cloudposse/key-pair/aws"
7-
version = "0.16.1"
7+
version = "0.18.3"
88
namespace = module.this.namespace
99
stage = module.this.stage
1010
name = module.this.name
@@ -15,21 +15,21 @@ module "aws_key_pair" {
1515

1616
module "vpc" {
1717
source = "cloudposse/vpc/aws"
18-
version = "0.18.2"
18+
version = "1.1.1"
1919

20-
cidr_block = "172.16.0.0/16"
20+
ipv4_primary_cidr_block = "172.16.0.0/16"
2121

2222
context = module.this.context
2323
}
2424

2525
module "subnets" {
2626
source = "cloudposse/dynamic-subnets/aws"
27-
version = "0.34.0"
27+
version = "2.0.3"
2828

2929
availability_zones = var.availability_zones
3030
vpc_id = module.vpc.vpc_id
31-
igw_id = module.vpc.igw_id
32-
cidr_block = module.vpc.vpc_cidr_block
31+
igw_id = [module.vpc.igw_id]
32+
ipv4_cidr_block = [module.vpc.vpc_cidr_block]
3333
nat_gateway_enabled = false
3434
nat_instance_enabled = false
3535

@@ -38,7 +38,7 @@ module "subnets" {
3838

3939
module "instance_profile_label" {
4040
source = "cloudposse/label/null"
41-
version = "0.22.1"
41+
version = "0.25.0"
4242

4343
attributes = distinct(compact(concat(module.this.attributes, ["profile"])))
4444

examples/complete/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 0.13.0"
2+
required_version = ">= 1.0"
33

44
required_providers {
55
aws = {

main.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ locals {
77
instance_profile = local.instance_profile_count == 0 ? var.instance_profile : join("", aws_iam_instance_profile.default.*.name)
88
security_group_enabled = module.this.enabled && var.security_group_enabled
99
region = var.region != "" ? var.region : data.aws_region.default.name
10-
root_iops = var.root_volume_type == "io1" ? var.root_iops : "0"
11-
ebs_iops = var.ebs_volume_type == "io1" ? var.ebs_iops : "0"
10+
root_iops = contains(["io1", "io2", "gp3"], var.root_volume_type) ? var.root_iops : "0"
11+
ebs_iops = contains(["io1", "io2", "gp3"], var.ebs_volume_type) ? var.ebs_iops : "0"
12+
root_throughput = var.root_volume_type == "gp3" ? var.root_throughput : "0"
13+
ebs_throughput = var.ebs_volume_type == "gp3" ? var.ebs_throughput : "0"
1214
availability_zone = var.availability_zone != "" ? var.availability_zone : data.aws_subnet.default.availability_zone
1315
ami = var.ami != "" ? var.ami : join("", data.aws_ami.default.*.image_id)
1416
ami_owner = var.ami != "" ? var.ami_owner : join("", data.aws_ami.default.*.owner_id)
@@ -139,6 +141,7 @@ resource "aws_instance" "default" {
139141
volume_type = local.root_volume_type
140142
volume_size = var.root_volume_size
141143
iops = local.root_iops
144+
throughput = local.root_throughput
142145
delete_on_termination = var.delete_on_termination
143146
encrypted = var.root_block_device_encrypted
144147
kms_key_id = var.root_block_device_kms_key_id
@@ -172,6 +175,7 @@ resource "aws_ebs_volume" "default" {
172175
availability_zone = local.availability_zone
173176
size = var.ebs_volume_size
174177
iops = local.ebs_iops
178+
throughput = local.ebs_throughput
175179
type = var.ebs_volume_type
176180
tags = module.this.tags
177181
encrypted = var.ebs_volume_encrypted

variables.tf

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ variable "ipv6_addresses" {
161161

162162
variable "root_volume_type" {
163163
type = string
164-
description = "Type of root volume. Can be standard, gp2 or io1"
164+
description = "Type of root volume. Can be standard, gp2, gp3, io1 or io2"
165165
default = "gp2"
166166
}
167167

@@ -173,7 +173,13 @@ variable "root_volume_size" {
173173

174174
variable "root_iops" {
175175
type = number
176-
description = "Amount of provisioned IOPS. This must be set if root_volume_type is set to `io1`"
176+
description = "Amount of provisioned IOPS. This must be set if root_volume_type is set of `io1`, `io2` or `gp3`"
177+
default = 0
178+
}
179+
180+
variable "root_throughput" {
181+
type = number
182+
description = "Amount of throughput. This must be set if root_volume_type is set to `gp3`"
177183
default = 0
178184
}
179185

@@ -185,7 +191,7 @@ variable "ebs_device_name" {
185191

186192
variable "ebs_volume_type" {
187193
type = string
188-
description = "The type of the additional EBS volumes. Can be standard, gp2 or io1"
194+
description = "The type of the additional EBS volumes. Can be standard, gp2, gp3, io1 or io2"
189195
default = "gp2"
190196
}
191197

@@ -203,7 +209,13 @@ variable "ebs_volume_encrypted" {
203209

204210
variable "ebs_iops" {
205211
type = number
206-
description = "Amount of provisioned IOPS. This must be set with a volume_type of io1"
212+
description = "Amount of provisioned IOPS. This must be set with a volume_type of `io1`, `io2` or `gp3`"
213+
default = 0
214+
}
215+
216+
variable "ebs_throughput" {
217+
type = number
218+
description = "Amount of throughput. This must be set if volume_type is set to `gp3`"
207219
default = 0
208220
}
209221

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 0.13.0"
2+
required_version = ">= 1.0"
33

44
required_providers {
55
aws = {

0 commit comments

Comments
 (0)