From 5208242680451f9b723e49e06e3682d73cd3c3d8 Mon Sep 17 00:00:00 2001 From: Rupinder S Date: Thu, 16 Jun 2022 14:41:26 -0700 Subject: [PATCH] Support for storage variables (#141) * storage variables storage_type,iops and allocated_storage * Fixing failing test, doublequotes issue with terratest. Issue fixed in v0.31.0. Upgrading terratest to latest version Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com> Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> --- README.md | 7 +++++-- docs/terraform.md | 7 +++++-- examples/complete/main.tf | 3 +++ examples/complete/outputs.tf | 6 ------ examples/complete/variables.tf | 18 ++++++++++++++++++ examples/complete/versions.tf | 2 +- main.tf | 3 +++ test/src/go.sum | 2 +- variables.tf | 18 ++++++++++++++++++ versions.tf | 2 +- 10 files changed, 55 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 4d20957f..7c8f1ad7 100644 --- a/README.md +++ b/README.md @@ -356,14 +356,14 @@ Available targets: | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0.0 | -| [aws](#requirement\_aws) | >= 3.63.0 | +| [aws](#requirement\_aws) | >= 4.17.0 | | [null](#requirement\_null) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.63.0 | +| [aws](#provider\_aws) | >= 4.17.0 | ## Modules @@ -402,6 +402,7 @@ Available targets: | [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no | | [admin\_password](#input\_admin\_password) | Password for the master DB user. Ignored if snapshot\_identifier or replication\_source\_identifier is provided | `string` | `""` | no | | [admin\_user](#input\_admin\_user) | Username for the master DB user. Ignored if snapshot\_identifier or replication\_source\_identifier is provided | `string` | `"admin"` | no | +| [allocated\_storage](#input\_allocated\_storage) | The allocated storage in GBs | `number` | `null` | no | | [allow\_major\_version\_upgrade](#input\_allow\_major\_version\_upgrade) | Enable to allow major engine version upgrades when changing engine versions. Defaults to false. | `bool` | `false` | no | | [allowed\_cidr\_blocks](#input\_allowed\_cidr\_blocks) | List of CIDR blocks allowed to access the cluster | `list(string)` | `[]` | no | | [apply\_immediately](#input\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window | `bool` | `true` | no | @@ -448,6 +449,7 @@ Available targets: | [instance\_availability\_zone](#input\_instance\_availability\_zone) | Optional parameter to place cluster instances in a specific availability zone. If left empty, will place randomly | `string` | `""` | no | | [instance\_parameters](#input\_instance\_parameters) | List of DB instance parameters to apply |
list(object({
apply_method = string
name = string
value = string
}))
| `[]` | no | | [instance\_type](#input\_instance\_type) | Instance type to use | `string` | `"db.t2.small"` | no | +| [iops](#input\_iops) | The amount of provisioned IOPS. Setting this implies a storage\_type of 'io1'. This setting is required to create a Multi-AZ DB cluster. Check TF docs for values based on db engine | `number` | `null` | no | | [kms\_key\_arn](#input\_kms\_key\_arn) | The ARN for the KMS encryption key. When specifying `kms_key_arn`, `storage_encrypted` needs to be set to `true` | `string` | `""` | no | | [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | | [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no | @@ -476,6 +478,7 @@ Available targets: | [source\_region](#input\_source\_region) | Source Region of primary cluster, needed when using encrypted storage and region replicas | `string` | `""` | no | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | | [storage\_encrypted](#input\_storage\_encrypted) | Specifies whether the DB cluster is encrypted. The default is `false` for `provisioned` `engine_mode` and `true` for `serverless` `engine_mode` | `bool` | `false` | no | +| [storage\_type](#input\_storage\_type) | One of 'standard' (magnetic), 'gp2' (general purpose SSD), or 'io1' (provisioned IOPS SSD) | `string` | `null` | no | | [subnet\_group\_name](#input\_subnet\_group\_name) | Database subnet group name. Will use generated label ID if not supplied. | `string` | `""` | no | | [subnets](#input\_subnets) | List of VPC subnet IDs | `list(string)` | n/a | yes | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 485e7695..47e8edf7 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -4,14 +4,14 @@ | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0.0 | -| [aws](#requirement\_aws) | >= 3.63.0 | +| [aws](#requirement\_aws) | >= 4.17.0 | | [null](#requirement\_null) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.63.0 | +| [aws](#provider\_aws) | >= 4.17.0 | ## Modules @@ -50,6 +50,7 @@ | [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no | | [admin\_password](#input\_admin\_password) | Password for the master DB user. Ignored if snapshot\_identifier or replication\_source\_identifier is provided | `string` | `""` | no | | [admin\_user](#input\_admin\_user) | Username for the master DB user. Ignored if snapshot\_identifier or replication\_source\_identifier is provided | `string` | `"admin"` | no | +| [allocated\_storage](#input\_allocated\_storage) | The allocated storage in GBs | `number` | `null` | no | | [allow\_major\_version\_upgrade](#input\_allow\_major\_version\_upgrade) | Enable to allow major engine version upgrades when changing engine versions. Defaults to false. | `bool` | `false` | no | | [allowed\_cidr\_blocks](#input\_allowed\_cidr\_blocks) | List of CIDR blocks allowed to access the cluster | `list(string)` | `[]` | no | | [apply\_immediately](#input\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window | `bool` | `true` | no | @@ -96,6 +97,7 @@ | [instance\_availability\_zone](#input\_instance\_availability\_zone) | Optional parameter to place cluster instances in a specific availability zone. If left empty, will place randomly | `string` | `""` | no | | [instance\_parameters](#input\_instance\_parameters) | List of DB instance parameters to apply |
list(object({
apply_method = string
name = string
value = string
}))
| `[]` | no | | [instance\_type](#input\_instance\_type) | Instance type to use | `string` | `"db.t2.small"` | no | +| [iops](#input\_iops) | The amount of provisioned IOPS. Setting this implies a storage\_type of 'io1'. This setting is required to create a Multi-AZ DB cluster. Check TF docs for values based on db engine | `number` | `null` | no | | [kms\_key\_arn](#input\_kms\_key\_arn) | The ARN for the KMS encryption key. When specifying `kms_key_arn`, `storage_encrypted` needs to be set to `true` | `string` | `""` | no | | [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | | [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no | @@ -124,6 +126,7 @@ | [source\_region](#input\_source\_region) | Source Region of primary cluster, needed when using encrypted storage and region replicas | `string` | `""` | no | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | | [storage\_encrypted](#input\_storage\_encrypted) | Specifies whether the DB cluster is encrypted. The default is `false` for `provisioned` `engine_mode` and `true` for `serverless` `engine_mode` | `bool` | `false` | no | +| [storage\_type](#input\_storage\_type) | One of 'standard' (magnetic), 'gp2' (general purpose SSD), or 'io1' (provisioned IOPS SSD) | `string` | `null` | no | | [subnet\_group\_name](#input\_subnet\_group\_name) | Database subnet group name. Will use generated label ID if not supplied. | `string` | `""` | no | | [subnets](#input\_subnets) | List of VPC subnet IDs | `list(string)` | n/a | yes | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 949815c4..f3f39c01 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -41,6 +41,9 @@ module "rds_cluster" { security_groups = [module.vpc.vpc_default_security_group_id] deletion_protection = var.deletion_protection autoscaling_enabled = var.autoscaling_enabled + storage_type = var.storage_type + iops = var.iops + allocated_storage = var.allocated_storage cluster_parameters = [ { diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf index 67b55b0b..6e863008 100644 --- a/examples/complete/outputs.tf +++ b/examples/complete/outputs.tf @@ -3,12 +3,6 @@ output "database_name" { description = "Database name" } -output "master_username" { - value = module.rds_cluster.master_username - description = "Username for the master DB user" - sensitive = true -} - output "cluster_identifier" { value = module.rds_cluster.cluster_identifier description = "Cluster Identifier" diff --git a/examples/complete/variables.tf b/examples/complete/variables.tf index 3a23bfa2..a85865f3 100644 --- a/examples/complete/variables.tf +++ b/examples/complete/variables.tf @@ -66,3 +66,21 @@ variable "rds_monitoring_interval" { type = number description = "The interval, in seconds, between points when enhanced monitoring metrics are collected for the DB instance. To disable collecting Enhanced Monitoring metrics, specify 0. The default is 0. Valid Values: 0, 1, 5, 10, 15, 30, 60" } + +variable "storage_type" { + type = string + description = "One of 'standard' (magnetic), 'gp2' (general purpose SSD), or 'io1' (provisioned IOPS SSD)" + default = null +} + +variable "iops" { + type = number + description = "The amount of provisioned IOPS. Setting this implies a storage_type of 'io1'. This setting is required to create a Multi-AZ DB cluster. Check TF docs for values based on db engine" + default = null +} + +variable "allocated_storage" { + type = number + description = "The allocated storage in GBs" + default = null +} diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 7ae9ce43..67af3b93 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 2.0" + version = ">= 4.17.0" } null = { source = "hashicorp/null" diff --git a/main.tf b/main.tf index 9f5c8f4a..ce55ea8b 100644 --- a/main.tf +++ b/main.tf @@ -70,6 +70,9 @@ resource "aws_rds_cluster" "primary" { skip_final_snapshot = var.skip_final_snapshot apply_immediately = var.apply_immediately storage_encrypted = local.is_serverless ? null : var.storage_encrypted + storage_type = var.storage_type + iops = var.iops + allocated_storage = var.allocated_storage kms_key_id = var.kms_key_arn source_region = var.source_region snapshot_identifier = var.snapshot_identifier diff --git a/test/src/go.sum b/test/src/go.sum index c4bdd790..12b7108c 100644 --- a/test/src/go.sum +++ b/test/src/go.sum @@ -755,4 +755,4 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.3 h1:4oyYo8NREp49LBBhKxEqCulFjg26rawYK sigs.k8s.io/structured-merge-diff/v4 v4.0.3/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= +sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= \ No newline at end of file diff --git a/variables.tf b/variables.tf index 2fe9f415..08d38a16 100644 --- a/variables.tf +++ b/variables.tf @@ -213,6 +213,24 @@ variable "storage_encrypted" { default = false } +variable "storage_type" { + type = string + description = "One of 'standard' (magnetic), 'gp2' (general purpose SSD), or 'io1' (provisioned IOPS SSD)" + default = null +} + +variable "iops" { + type = number + description = "The amount of provisioned IOPS. Setting this implies a storage_type of 'io1'. This setting is required to create a Multi-AZ DB cluster. Check TF docs for values based on db engine" + default = null +} + +variable "allocated_storage" { + type = number + description = "The allocated storage in GBs" + default = null +} + variable "kms_key_arn" { type = string description = "The ARN for the KMS encryption key. When specifying `kms_key_arn`, `storage_encrypted` needs to be set to `true`" diff --git a/versions.tf b/versions.tf index ff9ecc21..b6483d5a 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.63.0" + version = ">= 4.17.0" } null = { source = "hashicorp/null"