terraform-google-sql makes it easy to create Google CloudSQL instance and implement high availability settings. This module consists of the following submodules:
See more details in each module's README.
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.6+.
If you find incompatibilities using Terraform >=1.13
, please open an issue.
The current version is 20.X. The following guides are available to assist with upgrades:
The root module has been deprecated. Please switch to using one of the submodules.
In order to execute this module you must have a Service Account with the following:
roles/cloudsql.admin
roles/compute.networkAdmin
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
sqladmin.googleapis.com
In order to use Private Service Access, required for using Private IPs, you must activate the following APIs on the project where your VPC resides:
sqladmin.googleapis.com
compute.googleapis.com
servicenetworking.googleapis.com
cloudresourcemanager.googleapis.com
You can pass the service account credentials into this module by setting the following environment variables:
GOOGLE_CREDENTIALS
GOOGLE_CLOUD_KEYFILE_JSON
GCLOUD_KEYFILE_JSON
See more details.
This module has no root configuration. A module with no root configuration cannot be used directly.
Copy and paste into your Terraform configuration, insert the variables, and run terraform init :
For MySQL :
module "sql-db" {
source = "GoogleCloudPlatform/sql-db/google//modules/mysql"
version = "~> 21.0"
}
or for PostgreSQL :
module "sql-db" {
source = "GoogleCloudPlatform/sql-db/google//modules/postgresql"
version = "~> 20.0"
}
or for MSSQL Server :
module "sql-db" {
source = "GoogleCloudPlatform/sql-db/google//modules/mssql"
version = "~> 20.0"
}
Refer to the contribution guidelines for information on contributing to this module.