Skip to content

Commit

Permalink
Added: random_instance_name variable
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantin-recurly committed May 27, 2020
1 parent 43d8ddd commit 7346498
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
| name | The name of the Cloud SQL resources | string | n/a | yes |
| pricing\_plan | The pricing plan for the master instance. | string | `"PER_USE"` | no |
| project\_id | The project ID to manage the Cloud SQL resources | string | n/a | yes |
| random\_instance\_name | To use a random prefix at the end of the Cloud SQL resource | bool | `"false"` | no |
| read\_replica\_activation\_policy | The activation policy for the read replica instances. Can be either `ALWAYS`, `NEVER` or `ON_DEMAND`. | string | `"ALWAYS"` | no |
| read\_replica\_configuration | The replica configuration for use in all read replica instances. | object | `<map>` | no |
| read\_replica\_crash\_safe\_replication | The crash safe replication is to indicates when crash-safe replication flags are enabled. | bool | `"true"` | no |
Expand Down
2 changes: 1 addition & 1 deletion modules/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "random_id" "prefix" {
resource "google_sql_database_instance" "default" {
provider = google-beta
project = var.project_id
name = "${var.name}-${random_id.prefix.hex}"
name = var.random_instance_name ? "${var.name}-${random_id.prefix.hex}" : var.name
database_version = var.database_version
region = var.region
encryption_key_name = var.encryption_key_name
Expand Down
6 changes: 6 additions & 0 deletions modules/mysql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ variable "name" {
description = "The name of the Cloud SQL resources"
}

variable "random_instance_name" {
type = bool
description = "To use a random prefix at the end of the Cloud SQL resource"
default = false
}

// required
variable "database_version" {
description = "The database version to use"
Expand Down

0 comments on commit 7346498

Please sign in to comment.