File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
examples/mysql-and-postgres Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Install the Cloud SQL Proxy: https://cloud.google.com/sql/docs/mysql/sql-proxy#i
2121Run 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
2626MYSQL_DB_NAME=$(terraform output -module mysql-db -json | jq -r '.instance_name.value')
2727MYSQL_CONN_NAME="${GOOGLE_PROJECT}:us-central1:${MYSQL_DB_NAME}"
Original file line number Diff line number Diff 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+
3341resource "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
4458module "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}
You can’t perform that action at this time.
0 commit comments