diff --git a/modules/cloudsql-instance/README.md b/modules/cloudsql-instance/README.md index 4ef16cecc..e0ceb2992 100644 --- a/modules/cloudsql-instance/README.md +++ b/modules/cloudsql-instance/README.md @@ -409,11 +409,11 @@ module "db" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| | [database_version](variables.tf#L82) | Database type and version to create. | string | ✓ | | -| [name](variables.tf#L196) | Name of primary instance. | string | ✓ | | -| [network_config](variables.tf#L201) | Network configuration for the instance. Only one between private_network and psc_config can be used. | object({…}) | ✓ | | -| [project_id](variables.tf#L244) | The ID of the project where this instances will be created. | string | ✓ | | -| [region](variables.tf#L249) | Region of the primary instance. | string | ✓ | | -| [tier](variables.tf#L301) | The machine type to use for the instances. | string | ✓ | | +| [name](variables.tf#L198) | Name of primary instance. | string | ✓ | | +| [network_config](variables.tf#L203) | Network configuration for the instance. Only one between private_network and psc_config can be used. | object({…}) | ✓ | | +| [project_id](variables.tf#L246) | The ID of the project where this instances will be created. | string | ✓ | | +| [region](variables.tf#L251) | Region of the primary instance. | string | ✓ | | +| [tier](variables.tf#L303) | The machine type to use for the instances. | string | ✓ | | | [activation_policy](variables.tf#L16) | This variable specifies when the instance should be active. Can be either ALWAYS, NEVER or ON_DEMAND. Default is ALWAYS. | string | | "ALWAYS" | | [availability_type](variables.tf#L27) | Availability type for the primary replica. Either `ZONAL` or `REGIONAL`. | string | | "ZONAL" | | [backup_configuration](variables.tf#L33) | Backup settings for primary instance. Will be automatically enabled if using MySQL with one or more replicas. | object({…}) | | {…} | @@ -430,16 +430,16 @@ module "db" { | [gcp_deletion_protection](variables.tf#L129) | Set Google's deletion protection attribute which applies across all surfaces (UI, API, & Terraform). | bool | | true | | [insights_config](variables.tf#L136) | Query Insights configuration. Defaults to null which disables Query Insights. | object({…}) | | null | | [labels](variables.tf#L147) | Labels to be attached to all instances. | map(string) | | null | -| [maintenance_config](variables.tf#L153) | Set maintenance window configuration and maintenance deny period (up to 90 days). Date format: 'yyyy-mm-dd'. | object({…}) | | {} | -| [managed_connection_pooling_config](variables.tf#L186) | Configuration for Managed Connection Pooling. NOTE: This feature is only available for PostgreSQL on Enterprise Plus edition instances. | object({…}) | | {} | -| [password_validation_policy](variables.tf#L220) | Password validation policy configuration for instances. | object({…}) | | null | -| [prefix](variables.tf#L234) | Optional prefix used to generate instance names. | string | | null | -| [replicas](variables.tf#L254) | Map of NAME=> {REGION, KMS_KEY, AVAILABILITY_TYPE} for additional read replicas. Set to null to disable replica creation. | map(object({…})) | | {} | -| [root_password](variables.tf#L265) | Root password of the Cloud SQL instance, or flag to create a random password. Required for MS SQL Server. | object({…}) | | {} | -| [ssl](variables.tf#L279) | Setting to enable SSL, set config and certificates. | object({…}) | | {} | -| [terraform_deletion_protection](variables.tf#L294) | Prevent terraform from deleting instances. | bool | | true | -| [time_zone](variables.tf#L306) | The time_zone to be used by the database engine (supported only for SQL Server), in SQL Server timezone format. | string | | null | -| [users](variables.tf#L312) | Map of users to create in the primary instance (and replicated to other replicas). For MySQL, anything after the first `@` (if present) will be used as the user's host. Set PASSWORD to null if you want to get an autogenerated password. The user types available are: 'BUILT_IN', 'CLOUD_IAM_USER' or 'CLOUD_IAM_SERVICE_ACCOUNT'. | map(object({…})) | | {} | +| [maintenance_config](variables.tf#L153) | Set maintenance window configuration and maintenance deny period (up to 90 days). Date format: 'yyyy-mm-dd'. | object({…}) | | {} | +| [managed_connection_pooling_config](variables.tf#L188) | Configuration for Managed Connection Pooling. NOTE: This feature is only available for PostgreSQL on Enterprise Plus edition instances. | object({…}) | | {} | +| [password_validation_policy](variables.tf#L222) | Password validation policy configuration for instances. | object({…}) | | null | +| [prefix](variables.tf#L236) | Optional prefix used to generate instance names. | string | | null | +| [replicas](variables.tf#L256) | Map of NAME=> {REGION, KMS_KEY, AVAILABILITY_TYPE} for additional read replicas. Set to null to disable replica creation. | map(object({…})) | | {} | +| [root_password](variables.tf#L267) | Root password of the Cloud SQL instance, or flag to create a random password. Required for MS SQL Server. | object({…}) | | {} | +| [ssl](variables.tf#L281) | Setting to enable SSL, set config and certificates. | object({…}) | | {} | +| [terraform_deletion_protection](variables.tf#L296) | Prevent terraform from deleting instances. | bool | | true | +| [time_zone](variables.tf#L308) | The time_zone to be used by the database engine (supported only for SQL Server), in SQL Server timezone format. | string | | null | +| [users](variables.tf#L314) | Map of users to create in the primary instance (and replicated to other replicas). For MySQL, anything after the first `@` (if present) will be used as the user's host. Set PASSWORD to null if you want to get an autogenerated password. The user types available are: 'BUILT_IN', 'CLOUD_IAM_USER' or 'CLOUD_IAM_SERVICE_ACCOUNT'. | map(object({…})) | | {} | ## Outputs diff --git a/modules/cloudsql-instance/variables.tf b/modules/cloudsql-instance/variables.tf index af7a757cb..b6c696bf3 100644 --- a/modules/cloudsql-instance/variables.tf +++ b/modules/cloudsql-instance/variables.tf @@ -154,7 +154,7 @@ variable "maintenance_config" { description = "Set maintenance window configuration and maintenance deny period (up to 90 days). Date format: 'yyyy-mm-dd'." type = object({ maintenance_window = optional(object({ - day = number + day = optional(number) hour = number update_track = optional(string, null) }), null) @@ -169,8 +169,10 @@ variable "maintenance_config" { condition = ( try(var.maintenance_config.maintenance_window, null) == null ? true : ( # Maintenance window day validation below - var.maintenance_config.maintenance_window.day >= 1 && - var.maintenance_config.maintenance_window.day <= 7 && + var.maintenance_config.maintenance_window.day == null || ( + var.maintenance_config.maintenance_window.day >= 1 && + var.maintenance_config.maintenance_window.day <= 7 + ) && # Maintenance window hour validation below var.maintenance_config.maintenance_window.hour >= 0 && var.maintenance_config.maintenance_window.hour <= 23 && @@ -179,7 +181,7 @@ variable "maintenance_config" { contains(["canary", "stable"], var.maintenance_config.maintenance_window.update_track) ) ) - error_message = "Maintenance window day must be between 1 and 7, maintenance window hour must be between 0 and 23 and maintenance window update_track must be 'stable' or 'canary'." + error_message = "Maintenance window day must be between 1 and 7 or null, maintenance window hour must be between 0 and 23 and maintenance window update_track must be 'stable' or 'canary'." } }