Skip to content

Commit

Permalink
feat: add deletion_protection.enabled for read replicas (#437)
Browse files Browse the repository at this point in the history
Co-authored-by: g-awmalik <malik.awais@gmail.com>
Co-authored-by: Andrew Peabody <andrewpeabody@google.com>
Co-authored-by: Awais Malik <awmalik@google.com>
  • Loading branch information
4 people authored Apr 12, 2023
1 parent ce3446a commit 4cdb81c
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 205 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ docker_test_lint:
.PHONY: docker_generate_docs
docker_generate_docs:
docker run --rm -it \
-e ENABLE_BPMETADATA \
-v "$(CURDIR)":/workspace \
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'
Expand Down
1 change: 1 addition & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ spec:
source:
repo: https://github.com/terraform-google-modules/terraform-google-sql-db
sourceType: git
description: {}
subBlueprints:
- name: backup
location: modules/backup
Expand Down
12 changes: 1 addition & 11 deletions modules/backup/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
actuationTool:
type: Terraform
version: '>= 0.13'
description: {}
examples:
- name: mssql-public
location: examples/mssql-public
Expand All @@ -50,37 +51,30 @@ spec:
description: The number of days backups should be kept
type: number
default: 30
required: false
- name: backup_schedule
description: The cron schedule to execute the internal backup
type: string
default: 45 2 * * *
required: false
- name: compress_export
description: Whether or not to compress the export when storing in the bucket; Only valid for MySQL and PostgreSQL
type: bool
default: true
required: false
- name: enable_export_backup
description: Weather to create exports to GCS Buckets with this module
type: bool
default: true
required: false
- name: enable_internal_backup
description: Wether to create internal backups with this module
type: bool
default: true
required: false
- name: export_databases
description: The list of databases that should be exported - if is an empty set all databases will be exported
type: set(string)
default: []
required: false
- name: export_schedule
description: The cron schedule to execute the export to GCS
type: string
default: 15 3 * * *
required: false
- name: export_uri
description: The bucket and path uri for exporting to GCS
type: string
Expand All @@ -93,16 +87,13 @@ spec:
description: The region where to run the workflow
type: string
default: us-central1
required: false
- name: scheduler_timezone
description: The Timezone in which the Scheduler Jobs are triggered
type: string
default: Etc/GMT
required: false
- name: service_account
description: The service account to use for running the workflow and triggering the workflow by Cloud Scheduler - If empty or null a service account will be created. If you have provided a service account you need to grant the Cloud SQL Admin and the Workflows Invoker role to that
type: string
required: false
- name: sql_instance
description: The name of the SQL instance to backup
type: string
Expand All @@ -111,7 +102,6 @@ spec:
description: Unique suffix to add to scheduler jobs and workflows names.
type: string
default: ""
required: false
outputs:
- name: backup_workflow_name
description: The name for internal backup workflow
Expand Down
40 changes: 1 addition & 39 deletions modules/mssql/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
actuationTool:
type: Terraform
version: '>= 0.13'
description: {}
examples:
- name: mssql-public
location: examples/mssql-public
Expand All @@ -51,12 +52,10 @@ spec:
description: The activation policy for the master instance.Can be either `ALWAYS`, `NEVER` or `ON_DEMAND`.
type: string
default: ALWAYS
required: false
- name: active_directory_config
description: Active domain that the SQL instance will join.
type: map(string)
default: {}
required: false
- name: additional_databases
description: A list of databases to be created in your cluster
type: |-
Expand All @@ -66,7 +65,6 @@ spec:
collation = string
}))
default: []
required: false
- name: additional_users
description: A list of users to be created in your cluster. A random password would be set for the user if the `random_password` variable is set.
type: |-
Expand All @@ -76,12 +74,10 @@ spec:
random_password = bool
}))
default: []
required: false
- name: availability_type
description: The availability type for the master instance.This is only used to set up high availability for the MSSQL instance. Can be either `ZONAL` or `REGIONAL`.
type: string
default: ZONAL
required: false
- name: backup_configuration
description: The database backup configuration.
type: |-
Expand All @@ -102,12 +98,10 @@ spec:
retention_unit: null
start_time: null
transaction_log_retention_days: null
required: false
- name: create_timeout
description: The optional timeout that is applied to limit long database creates.
type: string
default: 30m
required: false
- name: database_flags
description: The database flags for the master instance. See [more details](https://cloud.google.com/sql/docs/sqlserver/flags)
type: |-
Expand All @@ -116,42 +110,34 @@ spec:
value = string
}))
default: []
required: false
- name: database_version
description: 'The database version to use: SQLSERVER_2017_STANDARD, SQLSERVER_2017_ENTERPRISE, SQLSERVER_2017_EXPRESS, or SQLSERVER_2017_WEB'
type: string
default: SQLSERVER_2017_STANDARD
required: false
- name: db_charset
description: The charset for the default database
type: string
default: ""
required: false
- name: db_collation
description: 'The collation for the default database. Example: ''en_US.UTF8'''
type: string
default: ""
required: false
- name: db_name
description: The name of the default database to create
type: string
default: default
required: false
- name: delete_timeout
description: The optional timeout that is applied to limit long database deletes.
type: string
default: 30m
required: false
- name: deletion_protection
description: Used to block Terraform from deleting a SQL Instance.
type: bool
default: true
required: false
- name: deletion_protection_enabled
description: Enables protection of an instance from accidental deletion protection across all surfaces (API, gcloud, Cloud Console and Terraform).
type: bool
default: false
required: false
- name: deny_maintenance_period
description: The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/sqlserver/maintenance)
type: |-
Expand All @@ -161,35 +147,28 @@ spec:
time = string
}))
default: []
required: false
- name: disk_autoresize
description: Configuration to increase storage size.
type: bool
default: true
required: false
- name: disk_autoresize_limit
description: The maximum size to which storage can be auto increased.
type: number
default: 0
required: false
- name: disk_size
description: The disk size for the master instance.
type: number
default: 10
required: false
- name: disk_type
description: The disk type for the master instance.
type: string
default: PD_SSD
required: false
- name: encryption_key_name
description: The full path to the encryption key used for the CMEK disk encryption
type: string
required: false
- name: follow_gae_application
description: A Google App Engine application whose zone to remain in. Must be in the same region as this instance.
type: string
required: false
- name: ip_configuration
description: The ip configuration for the master instances.
type: |-
Expand All @@ -206,27 +185,22 @@ spec:
ipv4_enabled: true
private_network: null
require_ssl: null
required: false
- name: maintenance_window_day
description: The day of week (1-7) for the master instance maintenance.
type: number
default: 1
required: false
- name: maintenance_window_hour
description: The hour of day (0-23) maintenance window for the master instance maintenance.
type: number
default: 23
required: false
- name: maintenance_window_update_track
description: The update track of maintenance window for the master instance maintenance.Can be either `canary` or `stable`.
type: string
default: canary
required: false
- name: module_depends_on
description: List of modules or resources this module depends on.
type: list(any)
default: []
required: false
- name: name
description: The name of the Cloud SQL resources
type: string
Expand All @@ -235,7 +209,6 @@ spec:
description: The pricing plan for the master instance.
type: string
default: PER_USE
required: false
- name: project_id
description: The project ID to manage the Cloud SQL resources
type: string
Expand All @@ -244,56 +217,45 @@ spec:
description: Sets random suffix at the end of the Cloud SQL resource name
type: bool
default: false
required: false
- name: region
description: The region of the Cloud SQL resources
type: string
default: us-central1
required: false
- name: root_password
description: MSSERVER password for the root user. If not set, a random one will be generated and available in the root_password output variable.
type: string
default: ""
required: false
- name: secondary_zone
description: 'The preferred zone for the secondary/failover instance, it should be something like: `us-central1-a`, `us-east1-c`.'
type: string
required: false
- name: sql_server_audit_config
description: SQL server audit config settings.
type: map(string)
default: {}
required: false
- name: tier
description: The tier for the master instance.
type: string
default: db-custom-2-3840
required: false
- name: update_timeout
description: The optional timeout that is applied to limit long database updates.
type: string
default: 30m
required: false
- name: user_labels
description: The key/value labels for the master instances.
type: map(string)
default: {}
required: false
- name: user_name
description: The name of the default user
type: string
default: default
required: false
- name: user_password
description: The password for the default user. If not set, a random one will be generated and available in the generated_user_password output variable.
type: string
default: ""
required: false
- name: zone
description: The zone for the master instance.
type: string
default: us-central1-a
required: false
outputs:
- name: additional_users
description: List of maps of additional users and passwords
Expand Down
3 changes: 2 additions & 1 deletion modules/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| db\_name | The name of the default database to create | `string` | `"default"` | no |
| delete\_timeout | The optional timout that is applied to limit long database deletes. | `string` | `"30m"` | no |
| deletion\_protection | Used to block Terraform from deleting a SQL Instance. | `bool` | `true` | no |
| deletion\_protection\_enabled | Enables protection of an instance from accidental deletion protection across all surfaces (API, gcloud, Cloud Console and Terraform). | `bool` | `false` | no |
| deletion\_protection\_enabled | Enables protection of an instance from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform). | `bool` | `false` | no |
| deny\_maintenance\_period | The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/mysql/maintenance) | <pre>list(object({<br> end_date = string<br> start_date = string<br> time = string<br> }))</pre> | `[]` | no |
| disk\_autoresize | Configuration to increase storage size | `bool` | `true` | no |
| disk\_autoresize\_limit | The maximum size to which storage can be auto increased. | `number` | `0` | no |
Expand All @@ -44,6 +44,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| project\_id | The project ID to manage the Cloud SQL resources | `string` | n/a | yes |
| random\_instance\_name | Sets random suffix at the end of the Cloud SQL resource name | `bool` | `false` | no |
| read\_replica\_deletion\_protection | Used to block Terraform from deleting replica SQL Instances. | `bool` | `false` | no |
| read\_replica\_deletion\_protection\_enabled | Enables protection of a read replica from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform). | `bool` | `false` | no |
| read\_replica\_name\_suffix | The optional suffix to add to the read instance name | `string` | `""` | no |
| read\_replicas | List of read replicas to create. Encryption key is required for replica in different region. For replica in same region as master set encryption\_key\_name = null | <pre>list(object({<br> name = string<br> name_override = optional(string)<br> tier = string<br> zone = string<br> availability_type = string<br> disk_type = string<br> disk_autoresize = bool<br> disk_autoresize_limit = number<br> disk_size = string<br> user_labels = map(string)<br> database_flags = list(object({<br> name = string<br> value = string<br> }))<br> ip_configuration = object({<br> authorized_networks = list(map(string))<br> ipv4_enabled = bool<br> private_network = string<br> require_ssl = bool<br> allocated_ip_range = string<br> })<br> encryption_key_name = string<br> }))</pre> | `[]` | no |
| region | The region of the Cloud SQL resources | `string` | `"us-central1"` | no |
Expand Down
Loading

0 comments on commit 4cdb81c

Please sign in to comment.