Skip to content

Commit 3e91e2e

Browse files
committed
Added simple example with one instance
1 parent ee34660 commit 3e91e2e

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

examples/prod-and-dev/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ variable "gcp_sql_root_user_pw" {}
77
variable "authorized_network" {}
88

99
module "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

1717
module "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}"

examples/simple/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
```

examples/simple/main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+

0 commit comments

Comments
 (0)