From 08ca1455798d94d862190bdb8b6e3464d073f671 Mon Sep 17 00:00:00 2001 From: Soren Martius Date: Fri, 25 Nov 2022 09:34:46 -0600 Subject: [PATCH 1/2] feat: add disk_autoresize_limit to google_sql_database_instance resource --- CHANGELOG.md | 1 + README.md | 6 ++++++ README.tfdoc.hcl | 8 ++++++++ main.tf | 11 ++++++----- test/unit-complete/main.tf | 23 ++++++++++++----------- variables.tf | 6 ++++++ 6 files changed, 39 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e419b23..64eb2aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Added +- Add `disk_autoresize_limit` to `google_sql_database_instance` resource - Validation added for `database_version` string input variable ## [0.0.5] diff --git a/README.md b/README.md index 1b473ac..e2f662d 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,12 @@ See [variables.tf] and [examples/] for details and use-cases. Default is `true`. +- [**`disk_autoresize_limit`**](#var-disk_autoresize_limit): *(Optional `number`)* + + The maximum size in GB to which storage capacity can be automatically increased. The default value is 0, which specifies that there is no limit. + + Default is `0`. + - [**`disk_size`**](#var-disk_size): *(Optional `number`)* The size of data disk, in GB. Size of a running instance cannot be reduced but can be increased. diff --git a/README.tfdoc.hcl b/README.tfdoc.hcl index fa7bccd..30f44e9 100644 --- a/README.tfdoc.hcl +++ b/README.tfdoc.hcl @@ -184,6 +184,14 @@ section { END } + variable "disk_autoresize_limit" { + type = number + default = 0 + description = <<-END + The maximum size in GB to which storage capacity can be automatically increased. The default value is 0, which specifies that there is no limit. + END + } + variable "disk_size" { type = number default = 10 diff --git a/main.tf b/main.tf index f3f2bb7..0fc4c55 100644 --- a/main.tf +++ b/main.tf @@ -25,11 +25,12 @@ resource "google_sql_database_instance" "instance" { availability_type = var.availability_type # disable disk_autoresize if the user requested a specific disk_size - disk_autoresize = var.disk_size != null ? false : var.disk_autoresize - disk_size = var.disk_size - disk_type = var.disk_type - pricing_plan = var.pricing_plan - user_labels = var.user_labels + disk_autoresize = var.disk_size != null ? false : var.disk_autoresize + disk_autoresize_limit = var.disk_autoresize_limit + disk_size = var.disk_size + disk_type = var.disk_type + pricing_plan = var.pricing_plan + user_labels = var.user_labels dynamic "database_flags" { for_each = var.database_flags diff --git a/test/unit-complete/main.tf b/test/unit-complete/main.tf index c8443ab..b930733 100644 --- a/test/unit-complete/main.tf +++ b/test/unit-complete/main.tf @@ -6,17 +6,18 @@ module "test" { tier = "db-n1-standard-1" # add all optional arguments that create additional/extended resources - name = "unit-complete-main-${local.random_suffix}" - region = var.gcp_region - master_instance_name = "unit-complete-main-master-${local.random_suffix}" - project = local.project_id - deletion_protection = true - activation_policy = "ALWAYS" - availability_type = "REGIONAL" - disk_autoresize = true - disk_size = 10 - disk_type = "PD_SSD" - pricing_plan = "PER_USE" + name = "unit-complete-main-${local.random_suffix}" + region = var.gcp_region + master_instance_name = "unit-complete-main-master-${local.random_suffix}" + project = local.project_id + deletion_protection = true + activation_policy = "ALWAYS" + availability_type = "REGIONAL" + disk_autoresize = true + disk_autoresize_limit = 100 + disk_size = 10 + disk_type = "PD_SSD" + pricing_plan = "PER_USE" user_labels = { "key1" = "value1" diff --git a/variables.tf b/variables.tf index 8968c55..7c4b208 100644 --- a/variables.tf +++ b/variables.tf @@ -81,6 +81,12 @@ variable "disk_autoresize" { default = true } +variable "disk_autoresize_limit" { + description = "(Optional) The maximum size in GB to which storage capacity can be automatically increased. The default value is 0, which specifies that there is no limit." + type = number + default = 0 +} + variable "disk_size" { description = "(Optional) The size of data disk, in GB. Size of a running instance cannot be reduced but can be increased. If `disk_size` is set `var.disk_autoresize` will be disbaled as terraform can not handle both." type = number From e3d71311aec1b8f6b4936cc2336b0fe71293997e Mon Sep 17 00:00:00 2001 From: Soren Martius Date: Fri, 25 Nov 2022 09:35:54 -0600 Subject: [PATCH 2/2] chore: prepare v0.1.0 release --- CHANGELOG.md | 5 ++++- README.md | 2 +- README.tfdoc.hcl | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64eb2aa..56330d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1.0] + ## Added - Add `disk_autoresize_limit` to `google_sql_database_instance` resource @@ -55,7 +57,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial Implementation -[unreleased]: https://github.com/mineiros-io/terraform-google-cloud-sql/compare/v0.0.5...HEAD +[unreleased]: https://github.com/mineiros-io/terraform-google-cloud-sql/compare/v0.1.0...HEAD +[0.1.0]: https://github.com/mineiros-io/terraform-google-cloud-sql/compare/v0.0.5...v0.1.0 [0.0.5]: https://github.com/mineiros-io/terraform-google-cloud-sql/compare/v0.0.4...v0.0.5 [0.0.4]: https://github.com/mineiros-io/terraform-google-cloud-sql/compare/v0.0.3...v0.0.4 [0.0.3]: https://github.com/mineiros-io/terraform-google-cloud-sql/compare/v0.0.2...v0.0.3 diff --git a/README.md b/README.md index e2f662d..9e461bd 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Most basic usage just setting required arguments: ```hcl module "terraform-google-cloud-sql" { - source = "github.com/mineiros-io/terraform-google-cloud-sql.git?ref=v0.0.5" + source = "github.com/mineiros-io/terraform-google-cloud-sql.git?ref=v0.1.0" tier = "db-f1-micro" database_version = "MYSQL_5_6" diff --git a/README.tfdoc.hcl b/README.tfdoc.hcl index 30f44e9..f1cecf4 100644 --- a/README.tfdoc.hcl +++ b/README.tfdoc.hcl @@ -68,7 +68,7 @@ section { ```hcl module "terraform-google-cloud-sql" { - source = "github.com/mineiros-io/terraform-google-cloud-sql.git?ref=v0.0.5" + source = "github.com/mineiros-io/terraform-google-cloud-sql.git?ref=v0.1.0" tier = "db-f1-micro" database_version = "MYSQL_5_6"