{"id":13707332,"url":"https://github.com/ryboe/private-ip-cloud-sql-db","last_synced_at":"2026-03-02T19:28:22.063Z","repository":{"id":44596786,"uuid":"256387818","full_name":"ryboe/private-ip-cloud-sql-db","owner":"ryboe","description":"An example set of terraform files for deploying a Cloud SQL DB with a private IP address only","archived":false,"fork":false,"pushed_at":"2023-03-15T20:27:42.000Z","size":29,"stargazers_count":34,"open_issues_count":1,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-22T22:21:37.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryboe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-17T03:06:59.000Z","updated_at":"2024-05-30T04:33:52.985Z","dependencies_parsed_at":"2024-05-30T04:33:51.031Z","dependency_job_id":"6d561388-63dd-4854-8dc4-e69878ebd18e","html_url":"https://github.com/ryboe/private-ip-cloud-sql-db","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryboe%2Fprivate-ip-cloud-sql-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryboe%2Fprivate-ip-cloud-sql-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryboe%2Fprivate-ip-cloud-sql-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryboe%2Fprivate-ip-cloud-sql-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryboe","download_url":"https://codeload.github.com/ryboe/private-ip-cloud-sql-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224484488,"owners_count":17318983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T22:01:27.704Z","updated_at":"2026-03-02T19:28:21.998Z","avatar_url":"https://github.com/ryboe.png","language":"HCL","funding_links":[],"categories":["HCL"],"sub_categories":[],"readme":"# Cloud SQL DB with a Private IP\n\nThis repo demonstrates how to create a Cloud SQL DB with a private IP address\nonly, and connect to it with [Cloud SQL Proxy](https://cloud.google.com/sql/docs/postgres/sql-proxy). The full explanation of how this works can be found in [this blog post](https://medium.com/@ryanboehning/how-to-deploy-a-cloud-sql-db-with-a-private-ip-only-using-terraform-e184b08eca64).\n\nTerraform v1.0.0 or higher is required.\n\n## How To Use\n\n1. Set the name of your Terraform Cloud organization in `backend.tf`.\n\n2. Deploy the db and Cloud SQL Proxy\n\n    ```bash\n    gcloud services enable \\\n        cloudresourcemanager.googleapis.com \\\n        compute.googleapis.com \\\n        iam.googleapis.com \\\n        oslogin.googleapis.com \\\n        servicenetworking.googleapis.com \\\n        sqladmin.googleapis.com\n\n    terraform init\n    terraform apply\n    ```\n\n3. Upload your public SSH key to Google's OS Login service\n\n    ```bash\n    gcloud compute os-login ssh-keys add --key-file=~/.ssh/id_rsa.pub --ttl=365d\n    ```\n\n4. Connect to the private db through Cloud SQL Proxy\n\n    ```bash\n    # get your SSH username\n    gcloud compute os-login describe-profile | grep username\n\n    # get the public IP of the instance running Cloud SQL Proxy\n    CLOUD_SQL_PROXY_IP=$(terraform output proxy_ip)\n\n    # psql into your private db\n    ssh -t \u003cusername\u003e@$CLOUD_SQL_PROXY_IP docker run --rm --network=host -it postgres:14-alpine psql -U postgres -h localhost\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryboe%2Fprivate-ip-cloud-sql-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryboe%2Fprivate-ip-cloud-sql-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryboe%2Fprivate-ip-cloud-sql-db/lists"}