{"id":21725315,"url":"https://github.com/jameswoolfenden/terraform-gcp-cloudsql","last_synced_at":"2025-04-12T22:54:05.737Z","repository":{"id":81359312,"uuid":"220215965","full_name":"JamesWoolfenden/terraform-gcp-cloudsql","owner":"JamesWoolfenden","description":"A module to create a private database setup","archived":false,"fork":false,"pushed_at":"2023-10-11T14:21:41.000Z","size":78,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T22:53:31.182Z","etag":null,"topics":["gcp","module","sql","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JamesWoolfenden.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":".github/CODEOWNERS","security":null,"support":null,"governance":null}},"created_at":"2019-11-07T10:59:21.000Z","updated_at":"2022-09-04T09:49:34.000Z","dependencies_parsed_at":"2023-07-11T10:36:23.934Z","dependency_job_id":null,"html_url":"https://github.com/JamesWoolfenden/terraform-gcp-cloudsql","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-gcp-cloudsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-gcp-cloudsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-gcp-cloudsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-gcp-cloudsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JamesWoolfenden","download_url":"https://codeload.github.com/JamesWoolfenden/terraform-gcp-cloudsql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643045,"owners_count":21138353,"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":["gcp","module","sql","terraform"],"created_at":"2024-11-26T03:17:06.181Z","updated_at":"2025-04-12T22:54:05.702Z","avatar_url":"https://github.com/JamesWoolfenden.png","language":"HCL","readme":"# terraform-gcp-cloudsql\n\n[![Build Status](https://github.com/JamesWoolfenden/terraform-gcp-cloudsql/workflows/Verify/badge.svg?branch=master)](https://github.com/JamesWoolfenden/terraform-gcp-cloudsql)\n[![Latest Release](https://img.shields.io/github/release/JamesWoolfenden/terraform-gcp-cloudsql.svg)](https://github.com/JamesWoolfenden/terraform-gcp-cloudsql/releases/latest)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![checkov](https://img.shields.io/badge/checkov-verified-brightgreen)](https://www.checkov.io/)\n\nThe beginnings of a cloudsql module for GCP, currently targeting a private endpoint.\n\n## Usage\n\nYou need to have enabled the API's for this to work if you haven't used this part of GCP before:\n\n[servicenetworking.googleapis.com](https://console.developers.google.com/apis/api/servicenetworking.googleapis.com/overview)\n\n[sqladmin.googleapis.com](https://console.developers.google.com/apis/api/sqladmin.googleapis.com/overview)\n\nAdd **module.cloudsql.tf** to your code:-\n\n```terraform\nmodule cloudsql {\n  source       = \"JamesWoolfenden/cloudsql/gcp\"\n  version      = \"0.1.13\"\n  name         = var.name\n  network_name = var.network_name\n  database     = var.database\n  users        = var.users\n}\n```\n\nYou can also create databases with this module and the variable database:\n\n```terraform\nvariable \"database\" {\n    type=list(object({\n        name = string\n    }))\n    default=[]\n}\n```\n\nSetting database to\n\n```terraform\n    database=[{\n        name= \"my-database\"\n    },\n    {\n        name= \"your-database\"\n    }]\n```\n\nWill create 2 databases.\n\nYou can then optionally create resource based on that object being populated, or not.\n\n```terraform\nresource \"google_sql_database\" \"database\" {\n  count    = length(var.database)\n  name     = var.database[count.index][\"name\"]\n  instance = google_sql_database_instance.instance.name\n}\n```\n\nThe \"Users\" variable and resource follows the same pattern.\n\n\u003c!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n## Requirements\n\nNo requirements.\n\n## Providers\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"provider_google\"\u003e\u003c/a\u003e [google](#provider\\_google) | n/a |\n\n## Modules\n\nNo modules.\n\n## Resources\n\n| Name | Type |\n|------|------|\n| [google_compute_global_address.private_ip_address](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_address) | resource |\n| [google_service_networking_connection.private_vpc_connection](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_networking_connection) | resource |\n| [google_sql_database.database](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database) | resource |\n| [google_sql_database_instance.instance](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance) | resource |\n| [google_sql_user.users](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_user) | resource |\n| [google_compute_network.private_network](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_network) | data source |\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| \u003ca name=\"input_database\"\u003e\u003c/a\u003e [database](#input\\_database) | A list of objects that describes if any databases to be created | \u003cpre\u003elist(object({\u003cbr\u003e    name = string\u003cbr\u003e  }))\u003c/pre\u003e | `[]` | no |\n| \u003ca name=\"input_instance\"\u003e\u003c/a\u003e [instance](#input\\_instance) | n/a | `map(any)` | \u003cpre\u003e{\u003cbr\u003e  \"database_version\": \"POSTGRES_14\",\u003cbr\u003e  \"region\": \"us-central1\",\u003cbr\u003e  \"tier\": \"db-custom-1-3840\"\u003cbr\u003e}\u003c/pre\u003e | no |\n| \u003ca name=\"input_mw_day\"\u003e\u003c/a\u003e [mw\\_day](#input\\_mw\\_day) | n/a | `number` | `1` | no |\n| \u003ca name=\"input_mw_hour\"\u003e\u003c/a\u003e [mw\\_hour](#input\\_mw\\_hour) | n/a | `number` | `12` | no |\n| \u003ca name=\"input_name\"\u003e\u003c/a\u003e [name](#input\\_name) | The name of the database instance | `string` | n/a | yes |\n| \u003ca name=\"input_network_name\"\u003e\u003c/a\u003e [network\\_name](#input\\_network\\_name) | The name of the VCP to provision this in to | `string` | n/a | yes |\n| \u003ca name=\"input_require_ssl\"\u003e\u003c/a\u003e [require\\_ssl](#input\\_require\\_ssl) | Require SSL connections or not. | `bool` | `true` | no |\n| \u003ca name=\"input_users\"\u003e\u003c/a\u003e [users](#input\\_users) | A list of user that belong to a database instance | \u003cpre\u003elist(object({\u003cbr\u003e    name     = string\u003cbr\u003e    password = string\u003cbr\u003e  }))\u003c/pre\u003e | `[]` | no |\n\n## Outputs\n\n| Name | Description |\n|------|-------------|\n| \u003ca name=\"output_instance\"\u003e\u003c/a\u003e [instance](#output\\_instance) | n/a |\n| \u003ca name=\"output_network\"\u003e\u003c/a\u003e [network](#output\\_network) | n/a |\n| \u003ca name=\"output_private_ip_address\"\u003e\u003c/a\u003e [private\\_ip\\_address](#output\\_private\\_ip\\_address) | n/a |\n| \u003ca name=\"output_vpc_connection\"\u003e\u003c/a\u003e [vpc\\_connection](#output\\_vpc\\_connection) | n/a |\n\u003c!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n\n## Role and Permissions\n\n\u003c!-- BEGINNING OF PRE-COMMIT-PIKE DOCS HOOK --\u003e\nThe Terraform resource required is:\n\n```golang\n\nresource \"google_project_iam_custom_role\" \"terraform_pike\" {\n  project     = \"pike\"\n  role_id     = \"terraform_pike\"\n  title       = \"terraform_pike\"\n  description = \"A user with least privileges\"\n  permissions = [\n    \"cloudsql.databases.create\",\n    \"cloudsql.databases.delete\",\n    \"cloudsql.databases.get\",\n    \"cloudsql.databases.update\",\n    \"cloudsql.instances.create\",\n    \"cloudsql.instances.delete\",\n    \"cloudsql.instances.get\",\n    \"cloudsql.instances.update\",\n    \"cloudsql.users.create\",\n    \"cloudsql.users.delete\",\n    \"cloudsql.users.list\",\n    \"cloudsql.users.update\",\n    \"compute.globalAddresses.create\",\n    \"compute.globalAddresses.createInternal\",\n    \"compute.globalAddresses.delete\",\n    \"compute.globalAddresses.deleteInternal\",\n    \"compute.globalAddresses.get\",\n    \"compute.networks.get\",\n    \"compute.networks.removePeering\",\n    \"compute.networks.use\",\n    \"resourcemanager.projects.get\",\n    \"servicenetworking.services.addPeering\",\n    \"servicenetworking.services.get\"\n  ]\n}\n\n\n```\n\u003c!-- END OF PRE-COMMIT-PIKE DOCS HOOK --\u003e\n\n## Related Projects\n\nCheck out these related projects.\n\n- [terraform-aws-codecommit](https://github.com/jameswoolfenden/terraform-aws-codebuild) - Storing ones code\n\n## Help\n\n**Got a question?**\n\nFile a GitHub [issue](https://github.com/jameswoolfenden/terraform-gcp-cloudsql/issues).\n\n## Contributing\n\n### Bug Reports \u0026 Feature Requests\n\nPlease use the [issue tracker](https://github.com/jameswoolfenden/terraform-gcp-cloudsql/issues) to report any bugs or file feature requests.\n\n## Copyrights\n\nCopyright © 2019-2023 James Woolfenden\n\n## License\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nSee [LICENSE](LICENSE) for full details.\n\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements. See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership. The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License. You may obtain a copy of the License at\n\n\u003chttps://www.apache.org/licenses/LICENSE-2.0\u003e\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied. See the License for the\nspecific language governing permissions and limitations\nunder the License.\n\n### Contributors\n\n[![James Woolfenden][jameswoolfenden_avatar]][jameswoolfenden_homepage]\u003cbr/\u003e[James Woolfenden][jameswoolfenden_homepage]\n\n[jameswoolfenden_homepage]: https://github.com/jameswoolfenden\n[jameswoolfenden_avatar]: https://github.com/jameswoolfenden.png?size=150\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameswoolfenden%2Fterraform-gcp-cloudsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjameswoolfenden%2Fterraform-gcp-cloudsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameswoolfenden%2Fterraform-gcp-cloudsql/lists"}