diff --git a/CHANGELOG.md b/CHANGELOG.md index e419b23..56330d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,11 @@ 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 - Validation added for `database_version` string input variable ## [0.0.5] @@ -54,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 1b473ac..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" @@ -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..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" @@ -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