File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -7,15 +7,15 @@ variable "gcp_sql_root_user_pw" {}
77variable "authorized_network" {}
88
99module "prod-gcp-cloudsql" {
10- source = " ../../ "
10+ source = " github.com/kawsark-git-org/terraform-gcp-cloudsql "
1111 region = " ${ var . region } "
1212 database_name = " prod-gcp-cloudsql"
1313 gcp_sql_root_user_pw = " ${ var . gcp_sql_root_user_pw } "
1414 authorized_network = " ${ var . authorized_network } "
1515}
1616
1717module "dev-gcp-cloudsql" {
18- source = " ../../ "
18+ source = " github.com/kawsark-git-org/terraform-gcp-cloudsql "
1919 region = " ${ var . region } "
2020 database_name = " dev-gcp-cloudsql"
2121 gcp_sql_root_user_pw = " ${ var . gcp_sql_root_user_pw } "
Original file line number Diff line number Diff line change 1+ # terraform-gcp-cloudsql
2+ Provisions a GCP CloudSQL POSTGRES instances in GCP for demo purposes using ` terraform-gcp-cloudsql ` module
3+
4+ Please the following environment variables appropriately:
5+ ```
6+ export GOOGLE_CLOUD_KEYFILE_JSON=<path/to/keyfile>
7+ export GOOGLE_PROJECT=<project>
8+ export TF_VAR_gcp_sql_root_user_pw=<pw>
9+ export TF_VAR_authorized_network="$(curl whatismyip.akamai.com)/32"
10+ ```
11+ Run the terraform commands below to create the sql instance:
12+ ```
13+ terraform get --update=true
14+ terraform init
15+ terraform plan
16+ terraform apply
17+ ```
18+ View module outputs:
19+ ```
20+ terraform output -json -module=example-gcp-cloudsql | jq .
21+ ```
22+ Connect using psql CLI:
23+ ```
24+ terraform output -json -module=example-gcp-cloudsql | jq -r .ip.value > /tmp/example-sql-ip
25+ psql "sslmode=disable dbname=postgres user=root hostaddr=$(cat /tmp/example-sql-ip)"
26+ ```
Original file line number Diff line number Diff line change 1+ variable "region" {
2+ default = " us-central1"
3+ }
4+
5+ variable "gcp_sql_root_user_pw" {}
6+
7+ variable "authorized_network" {}
8+
9+ module "example-gcp-cloudsql" {
10+ source = " github.com/kawsark-git-org/terraform-gcp-cloudsql"
11+ region = " ${ var . region } "
12+ database_name = " example-gcp-cloudsql"
13+ gcp_sql_root_user_pw = " ${ var . gcp_sql_root_user_pw } "
14+ authorized_network = " ${ var . authorized_network } "
15+ }
16+
You can’t perform that action at this time.
0 commit comments