Skip to content

Commit 40f5a39

Browse files
committed
added ip_configuration block to example
1 parent 688a320 commit 40f5a39

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

examples/mysql-and-postgres/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Install the Cloud SQL Proxy: https://cloud.google.com/sql/docs/mysql/sql-proxy#i
2121
Run the Cloud SQL proxy for MySQL instance:
2222

2323
```
24-
GOOGLE_PROJECT=$(gcloud config get-value project)
24+
export GOOGLE_PROJECT=$(gcloud config get-value project)
2525
2626
MYSQL_DB_NAME=$(terraform output -module mysql-db -json | jq -r '.instance_name.value')
2727
MYSQL_CONN_NAME="${GOOGLE_PROJECT}:us-central1:${MYSQL_DB_NAME}"

examples/mysql-and-postgres/main.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ provider google {
3030
region = "${var.region}"
3131
}
3232

33+
data "google_client_config" "current" {}
34+
35+
data "google_compute_subnetwork" "default-us-central1" {
36+
project = "${data.google_client_config.current.project}"
37+
region = "${var.region}"
38+
name = "default"
39+
}
40+
3341
resource "random_id" "name" {
3442
byte_length = 2
3543
}
@@ -39,6 +47,12 @@ module "mysql-db" {
3947
source = "../../"
4048
name = "example-mysql-${random_id.name.hex}"
4149
database_version = "MYSQL_5_6"
50+
ip_configuration = [{
51+
authorized_networks = [{
52+
name = "default"
53+
value = "${data.google_compute_subnetwork.default-us-central1.ip_cidr_range}"
54+
}]
55+
}]
4256
}
4357

4458
module "postgresql-db" {
@@ -47,4 +61,10 @@ module "postgresql-db" {
4761
name = "example-postgresql-${random_id.name.hex}"
4862
user_host = ""
4963
database_version = "POSTGRES_9_6"
64+
ip_configuration = [{
65+
authorized_networks = [{
66+
name = "default"
67+
value = "${data.google_compute_subnetwork.default-us-central1.ip_cidr_range}"
68+
}]
69+
}]
5070
}

0 commit comments

Comments
 (0)