Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable_private_path_for_google_cloud_services added to CloudSQL #2726

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions modules/cloudsql-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,10 @@ module "db" {
|---|---|:---:|:---:|:---:|
| [database_version](variables.tf#L75) | Database type and version to create. | <code>string</code> | ✓ | |
| [name](variables.tf#L179) | Name of primary instance. | <code>string</code> | ✓ | |
| [network_config](variables.tf#L184) | Network configuration for the instance. Only one between private_network and psc_config can be used. | <code title="object&#40;&#123;&#10; authorized_networks &#61; optional&#40;map&#40;string&#41;&#41;&#10; connectivity &#61; object&#40;&#123;&#10; public_ipv4 &#61; optional&#40;bool, false&#41;&#10; psa_config &#61; optional&#40;object&#40;&#123;&#10; private_network &#61; string&#10; allocated_ip_ranges &#61; optional&#40;object&#40;&#123;&#10; primary &#61; optional&#40;string&#41;&#10; replica &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;&#10; psc_allowed_consumer_projects &#61; optional&#40;list&#40;string&#41;&#41;&#10; &#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | |
| [project_id](variables.tf#L217) | The ID of the project where this instances will be created. | <code>string</code> | ✓ | |
| [region](variables.tf#L222) | Region of the primary instance. | <code>string</code> | ✓ | |
| [tier](variables.tf#L265) | The machine type to use for the instances. | <code>string</code> | ✓ | |
| [network_config](variables.tf#L184) | Network configuration for the instance. Only one between private_network and psc_config can be used. | <code title="object&#40;&#123;&#10; authorized_networks &#61; optional&#40;map&#40;string&#41;&#41;&#10; connectivity &#61; object&#40;&#123;&#10; public_ipv4 &#61; optional&#40;bool, false&#41;&#10; psa_config &#61; optional&#40;object&#40;&#123;&#10; private_network &#61; string&#10; allocated_ip_ranges &#61; optional&#40;object&#40;&#123;&#10; primary &#61; optional&#40;string&#41;&#10; replica &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;&#10; psc_allowed_consumer_projects &#61; optional&#40;list&#40;string&#41;&#41;&#10; enable_private_path_for_services &#61; optional&#40;bool, false&#41;&#10; &#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | |
| [project_id](variables.tf#L218) | The ID of the project where this instances will be created. | <code>string</code> | ✓ | |
| [region](variables.tf#L223) | Region of the primary instance. | <code>string</code> | ✓ | |
| [tier](variables.tf#L266) | The machine type to use for the instances. | <code>string</code> | ✓ | |
| [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. | <code>string</code> | | <code>&#34;ALWAYS&#34;</code> |
| [availability_type](variables.tf#L27) | Availability type for the primary replica. Either `ZONAL` or `REGIONAL`. | <code>string</code> | | <code>&#34;ZONAL&#34;</code> |
| [backup_configuration](variables.tf#L33) | 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; optional&#40;bool, false&#41;&#10; binary_log_enabled &#61; optional&#40;bool, false&#41;&#10; start_time &#61; optional&#40;string, &#34;23:00&#34;&#41;&#10; location &#61; optional&#40;string&#41;&#10; log_retention_days &#61; optional&#40;number, 7&#41;&#10; point_in_time_recovery_enabled &#61; optional&#40;bool&#41;&#10; retention_count &#61; optional&#40;number, 7&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</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; null&#10; log_retention_days &#61; 7&#10; point_in_time_recovery_enabled &#61; null&#10; retention_count &#61; 7&#10;&#125;">&#123;&#8230;&#125;</code> |
Expand All @@ -389,13 +389,13 @@ module "db" {
| [insights_config](variables.tf#L129) | Query Insights configuration. Defaults to null which disables Query Insights. | <code title="object&#40;&#123;&#10; query_string_length &#61; optional&#40;number, 1024&#41;&#10; record_application_tags &#61; optional&#40;bool, false&#41;&#10; record_client_address &#61; optional&#40;bool, false&#41;&#10; query_plans_per_minute &#61; optional&#40;number, 5&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [labels](variables.tf#L140) | Labels to be attached to all instances. | <code>map&#40;string&#41;</code> | | <code>null</code> |
| [maintenance_config](variables.tf#L146) | Set maintenance window configuration and maintenance deny period (up to 90 days). Date format: 'yyyy-mm-dd'. | <code title="object&#40;&#123;&#10; maintenance_window &#61; optional&#40;object&#40;&#123;&#10; day &#61; number&#10; hour &#61; number&#10; update_track &#61; optional&#40;string, null&#41;&#10; &#125;&#41;, null&#41;&#10; deny_maintenance_period &#61; optional&#40;object&#40;&#123;&#10; start_date &#61; string&#10; end_date &#61; string&#10; start_time &#61; optional&#40;string, &#34;00:00:00&#34;&#41;&#10; &#125;&#41;, null&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [prefix](variables.tf#L207) | Optional prefix used to generate instance names. | <code>string</code> | | <code>null</code> |
| [replicas](variables.tf#L227) | Map of NAME=> {REGION, KMS_KEY} for additional read replicas. Set to null to disable replica creation. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; encryption_key_name &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [root_password](variables.tf#L237) | Root password of the Cloud SQL instance. Required for MS SQL Server. | <code>string</code> | | <code>null</code> |
| [ssl](variables.tf#L243) | Setting to enable SSL, set config and certificates. | <code title="object&#40;&#123;&#10; client_certificates &#61; optional&#40;list&#40;string&#41;&#41;&#10; ssl_mode &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [terraform_deletion_protection](variables.tf#L258) | Prevent terraform from deleting instances. | <code>bool</code> | | <code>true</code> |
| [time_zone](variables.tf#L270) | The time_zone to be used by the database engine (supported only for SQL Server), in SQL Server timezone format. | <code>string</code> | | <code>null</code> |
| [users](variables.tf#L276) | 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'. | <code title="map&#40;object&#40;&#123;&#10; password &#61; optional&#40;string&#41;&#10; type &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>null</code> |
| [prefix](variables.tf#L208) | Optional prefix used to generate instance names. | <code>string</code> | | <code>null</code> |
| [replicas](variables.tf#L228) | Map of NAME=> {REGION, KMS_KEY} for additional read replicas. Set to null to disable replica creation. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; encryption_key_name &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [root_password](variables.tf#L238) | Root password of the Cloud SQL instance. Required for MS SQL Server. | <code>string</code> | | <code>null</code> |
| [ssl](variables.tf#L244) | Setting to enable SSL, set config and certificates. | <code title="object&#40;&#123;&#10; client_certificates &#61; optional&#40;list&#40;string&#41;&#41;&#10; ssl_mode &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [terraform_deletion_protection](variables.tf#L259) | Prevent terraform from deleting instances. | <code>bool</code> | | <code>true</code> |
| [time_zone](variables.tf#L271) | The time_zone to be used by the database engine (supported only for SQL Server), in SQL Server timezone format. | <code>string</code> | | <code>null</code> |
| [users](variables.tf#L277) | 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'. | <code title="map&#40;object&#40;&#123;&#10; password &#61; optional&#40;string&#41;&#10; type &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>null</code> |

## Outputs

Expand Down
16 changes: 9 additions & 7 deletions modules/cloudsql-instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ resource "google_sql_database_instance" "primary" {
time_zone = var.time_zone

ip_configuration {
ipv4_enabled = var.network_config.connectivity.public_ipv4
private_network = try(var.network_config.connectivity.psa_config.private_network, null)
allocated_ip_range = try(var.network_config.connectivity.psa_config.allocated_ip_ranges.primary, null)
ssl_mode = var.ssl.ssl_mode
ipv4_enabled = var.network_config.connectivity.public_ipv4
private_network = try(var.network_config.connectivity.psa_config.private_network, null)
allocated_ip_range = try(var.network_config.connectivity.psa_config.allocated_ip_ranges.primary, null)
ssl_mode = var.ssl.ssl_mode
enable_private_path_for_google_cloud_services = var.network_config.connectivity.enable_private_path_for_services
dynamic "authorized_networks" {
for_each = var.network_config.authorized_networks != null ? var.network_config.authorized_networks : {}
iterator = network
Expand Down Expand Up @@ -182,9 +183,10 @@ resource "google_sql_database_instance" "replicas" {
activation_policy = var.activation_policy

ip_configuration {
ipv4_enabled = var.network_config.connectivity.public_ipv4
private_network = try(var.network_config.connectivity.psa_config.private_network, null)
allocated_ip_range = try(var.network_config.connectivity.psa_config.allocated_ip_ranges.replica, null)
ipv4_enabled = var.network_config.connectivity.public_ipv4
private_network = try(var.network_config.connectivity.psa_config.private_network, null)
allocated_ip_range = try(var.network_config.connectivity.psa_config.allocated_ip_ranges.replica, null)
enable_private_path_for_google_cloud_services = var.network_config.connectivity.enable_private_path_for_services
dynamic "authorized_networks" {
for_each = var.network_config.authorized_networks != null ? var.network_config.authorized_networks : {}
iterator = network
Expand Down
3 changes: 2 additions & 1 deletion modules/cloudsql-instance/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ variable "network_config" {
replica = optional(string)
}))
}))
psc_allowed_consumer_projects = optional(list(string))
psc_allowed_consumer_projects = optional(list(string))
enable_private_path_for_services = optional(bool, false)
})
})
validation {
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/cloudsql_instance/examples/simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ values:
ip_configuration:
- allocated_ip_range: null
authorized_networks: []
enable_private_path_for_google_cloud_services: null
enable_private_path_for_google_cloud_services: false
ipv4_enabled: false
psc_config: []
maintenance_window: []
Expand Down