Merge pull request #331 from caiotavaresdito/feature/cloudsql-backup_configuration

Feature/cloudsql backup configuration
This commit is contained in:
Julio Castillo 2021-10-18 17:56:52 +02:00 committed by GitHub
commit 3b2de4921e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

View File

@ -104,7 +104,7 @@ module "db" {
| tier | The machine type to use for the instances. | <code title="">string</code> | ✓ | |
| *authorized_networks* | Map of NAME=>CIDR_RANGE to allow to connect to the database(s). | <code title="map&#40;string&#41;">map(string)</code> | | <code title="">null</code> |
| *availability_type* | Availability type for the primary replica. Either `ZONAL` or `REGIONAL` | <code title="">string</code> | | <code title="">ZONAL</code> |
| *backup_configuration* | Backup settings for primary instance. Will be automatically enabled if using MySQL with one or more replicas | <code title="object&#40;&#123;&#10;enabled &#61; bool&#10;binary_log_enabled &#61; bool&#10;&#125;&#41;">object({...})</code> | | <code title="&#123;&#10;enabled &#61; false&#10;binary_log_enabled &#61; false&#10;&#125;">...</code> |
| *backup_configuration* | Backup settings for primary instance. Will be automatically enabled if using MySQL with one or more replicas | <code title="object&#40;&#123;&#10;enabled &#61; bool&#10;binary_log_enabled &#61; bool&#10;start_time &#61; string&#10;location &#61; string&#10;log_retention_days &#61; number&#10;retention_count &#61; number&#10;&#125;&#41;">object({...})</code> | | <code title="&#123;&#10;enabled &#61; false&#10;binary_log_enabled &#61; false&#10;start_time &#61; &#34;23:00&#34;&#10;location &#61; &#34;EU&#34;&#10;log_retention_days &#61; 7&#10;retention_count &#61; 7&#10;&#125;">...</code> |
| *databases* | Databases to create once the primary instance is created. | <code title="list&#40;string&#41;">list(string)</code> | | <code title="">null</code> |
| *deletion_protection* | Allow terraform to delete instances. | <code title="">bool</code> | | <code title="">false</code> |
| *disk_size* | Disk size in GB. Set to null to enable autoresize. | <code title="">number</code> | | <code title="">null</code> |

View File

@ -77,6 +77,13 @@ resource "google_sql_database_instance" "primary" {
? var.backup_configuration.binary_log_enabled || local.has_replicas
: null
)
start_time = var.backup_configuration.start_time
location = var.backup_configuration.location
transaction_log_retention_days = var.backup_configuration.log_retention_days
backup_retention_settings {
retained_backups = var.backup_configuration.retention_count
retention_unit = "COUNT"
}
}
dynamic "database_flags" {

View File

@ -31,13 +31,22 @@ variable "backup_configuration" {
type = object({
enabled = bool
binary_log_enabled = bool
start_time = string
location = string
log_retention_days = number
retention_count = number
})
default = {
enabled = false
binary_log_enabled = false
start_time = "23:00"
location = "EU"
log_retention_days = 7
retention_count = 7
}
}
variable "database_version" {
description = "Database type and version to create."
type = string

View File

@ -28,10 +28,18 @@ variable "backup_configuration" {
type = object({
enabled = bool
binary_log_enabled = bool
start_time = string
location = string
log_retention_days = number
retention_count = number
})
default = {
enabled = false
binary_log_enabled = false
start_time = "23:00"
location = "EU"
log_retention_days = 7
retention_count = 7
}
}