Skip to content

snowplow-devops/terraform-google-cloud-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Release CI License Registry

terraform-google-cloud-sql

A Terraform module for deploying a simple CloudSQL instance. This module only allows deployment of an internet facing database and has no out of the box support for configuring VPC Peering for a Private VPC only deployment.

It is therefore recommended to connect to deployed instances using the Cloud SQL Proxy.

Note: If you intend to have many concurrent connections it is recommended to bump the tier to at least a db-g1-small if not bigger as the default db-f1-micro only allows for 20 concurrent connections with a Postgres database.

Note: The deployment of a Cloud SQL database can take upwards of 20 minutes as default - the timeouts are set to 60m for creation and deletion to allow for plenty of time.

Usage

module "instance" {
  source = "snowplow-devops/cloud-sql/google"

  name = "test-db-instance"

  region      = local.region
  db_name     = "snowplow"
  db_username = "snowplow"
  db_password = "$N0wPL0W"
}

Requirements

Name Version
terraform >= 1.0.0
google >= 3.44.0
random >= 3

Providers

Name Version
google >= 3.44.0
random >= 3

Modules

No modules.

Resources

Name Type
google_sql_database.db resource
google_sql_database_instance.instance resource
google_sql_user.user resource
random_id.db_name_suffix resource

Inputs

Name Description Type Default Required
db_name The name of the database to create string n/a yes
db_password The password of the administration user to create string n/a yes
db_username The name of the administration user to create string n/a yes
name A name which will be pre-pended to the resources created string n/a yes
region The name of the region to deploy within string n/a yes
authorized_networks The list of CIDR ranges to allow access to the instance over
list(object({
name = string
value = string
}))
[] no
database_version The database version to use (https://cloud.google.com/sql/docs/db-versions) string "POSTGRES_9_6" no
deletion_protection Whether to protect the instance from accidental termination bool false no
labels The labels to append to this resource map(string) {} no
tier The tier of database to deploy string "db-f1-micro" no

Outputs

Name Description
connection_name The connection name to be used when using things like Cloud SQL Proxy
first_ip_address The first IP Address attached to the instance
port The port that the instance is available over
self_link The URI of the instance
service_account_email_address The SA email address assigned to the instance

Copyright and license

The Terraform Google CloudSQL project is Copyright 2021-present Snowplow Analytics Ltd.

Licensed under the Snowplow Community License. (If you are uncertain how it applies to your use case, check our answers to frequently asked questions.)

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.