Skip to content

Commit ab8c768

Browse files
authored
feat: Add allocated_ip_range property to CloudSQL modules (#277)
BREAKING CHANGE: Minimum provider version increased to 4.4. BREAKING CHANGE: `allocated_ip_range` must now be specified for instances; `allocated_ip_range = null` can be used to preserve old default.
1 parent 3d0e73d commit ab8c768

File tree

24 files changed

+73
-42
lines changed

24 files changed

+73
-42
lines changed

examples/mysql-ha/main.tf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
locals {
1818
read_replica_ip_configuration = {
19-
ipv4_enabled = true
20-
require_ssl = false
21-
private_network = null
19+
ipv4_enabled = true
20+
require_ssl = false
21+
private_network = null
22+
allocated_ip_range = null
2223
authorized_networks = [
2324
{
2425
name = "${var.project_id}-cidr"
@@ -55,9 +56,10 @@ module "mysql" {
5556
}
5657

5758
ip_configuration = {
58-
ipv4_enabled = true
59-
require_ssl = true
60-
private_network = null
59+
ipv4_enabled = true
60+
require_ssl = true
61+
private_network = null
62+
allocated_ip_range = null
6163
authorized_networks = [
6264
{
6365
name = "${var.project_id}-cidr"

examples/mysql-private/main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ locals {
2929

3030
module "network-safer-mysql-simple" {
3131
source = "terraform-google-modules/network/google"
32-
version = "~> 2.5"
32+
version = "~> 4.0"
3333

3434
project_id = var.project_id
3535
network_name = local.network_name
@@ -73,8 +73,9 @@ module "safer-mysql-db" {
7373
},
7474
]
7575

76-
assign_public_ip = "true"
77-
vpc_network = module.network-safer-mysql-simple.network_self_link
76+
assign_public_ip = "true"
77+
vpc_network = module.network-safer-mysql-simple.network_self_link
78+
allocated_ip_range = module.private-service-access.google_compute_global_address_name
7879

7980
// Optional: used to enforce ordering in the creation of resources.
8081
module_depends_on = [module.private-service-access.peering_completed]

examples/mysql-public/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module "mysql-db" {
3434
ipv4_enabled = true
3535
private_network = null
3636
require_ssl = true
37+
allocated_ip_range = null
3738
authorized_networks = var.authorized_networks
3839
}
3940

examples/postgresql-ha/main.tf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717

1818
locals {
1919
read_replica_ip_configuration = {
20-
ipv4_enabled = true
21-
require_ssl = false
22-
private_network = null
20+
ipv4_enabled = true
21+
require_ssl = false
22+
private_network = null
23+
allocated_ip_range = null
2324
authorized_networks = [
2425
{
2526
name = "${var.project_id}-cidr"
@@ -54,9 +55,10 @@ module "pg" {
5455
}
5556

5657
ip_configuration = {
57-
ipv4_enabled = true
58-
require_ssl = true
59-
private_network = null
58+
ipv4_enabled = true
59+
require_ssl = true
60+
private_network = null
61+
allocated_ip_range = null
6062
authorized_networks = [
6163
{
6264
name = "${var.project_id}-cidr"

examples/postgresql-public-iam/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module "postgresql-db" {
3131
ipv4_enabled = true
3232
private_network = null
3333
require_ssl = true
34+
allocated_ip_range = null
3435
authorized_networks = var.authorized_networks
3536
}
3637

examples/postgresql-public/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module "postgresql-db" {
3131
ipv4_enabled = true
3232
private_network = null
3333
require_ssl = true
34+
allocated_ip_range = null
3435
authorized_networks = var.authorized_networks
3536
}
3637
}

modules/mssql/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The following dependency must be available for SQL Server module:
2626
| disk\_size | The disk size for the master instance. | `number` | `10` | no |
2727
| disk\_type | The disk type for the master instance. | `string` | `"PD_SSD"` | no |
2828
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
29-
| ip\_configuration | The ip configuration for the master instances. | <pre>object({<br> authorized_networks = list(map(string))<br> ipv4_enabled = bool<br> private_network = string<br> require_ssl = bool<br> })</pre> | <pre>{<br> "authorized_networks": [],<br> "ipv4_enabled": true,<br> "private_network": null,<br> "require_ssl": null<br>}</pre> | no |
29+
| ip\_configuration | The ip configuration for the master instances. | <pre>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> })</pre> | <pre>{<br> "allocated_ip_range": null,<br> "authorized_networks": [],<br> "ipv4_enabled": true,<br> "private_network": null,<br> "require_ssl": null<br>}</pre> | no |
3030
| maintenance\_window\_day | The day of week (1-7) for the master instance maintenance. | `number` | `1` | no |
3131
| maintenance\_window\_hour | The hour of day (0-23) maintenance window for the master instance maintenance. | `number` | `23` | no |
3232
| maintenance\_window\_update\_track | The update track of maintenance window for the master instance maintenance.Can be either `canary` or `stable`. | `string` | `"canary"` | no |

modules/mssql/main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ resource "google_sql_database_instance" "default" {
7575
dynamic "ip_configuration" {
7676
for_each = [local.ip_configurations[local.ip_configuration_enabled ? "enabled" : "disabled"]]
7777
content {
78-
ipv4_enabled = lookup(ip_configuration.value, "ipv4_enabled", null)
79-
private_network = lookup(ip_configuration.value, "private_network", null)
80-
require_ssl = lookup(ip_configuration.value, "require_ssl", null)
78+
ipv4_enabled = lookup(ip_configuration.value, "ipv4_enabled", null)
79+
private_network = lookup(ip_configuration.value, "private_network", null)
80+
require_ssl = lookup(ip_configuration.value, "require_ssl", null)
81+
allocated_ip_range = lookup(ip_configuration.value, "allocated_ip_range", null)
8182

8283
dynamic "authorized_networks" {
8384
for_each = lookup(ip_configuration.value, "authorized_networks", [])

modules/mssql/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,14 @@ variable "ip_configuration" {
131131
ipv4_enabled = bool
132132
private_network = string
133133
require_ssl = bool
134+
allocated_ip_range = string
134135
})
135136
default = {
136137
authorized_networks = []
137138
ipv4_enabled = true
138139
private_network = null
139140
require_ssl = null
141+
allocated_ip_range = null
140142
}
141143
}
142144

modules/mssql/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ terraform {
2020

2121
google-beta = {
2222
source = "hashicorp/google-beta"
23-
version = ">= 3.60, < 5.0"
23+
version = ">= 4.4.0, < 5.0"
2424
}
2525
}
2626

0 commit comments

Comments
 (0)