Move impl files under mysql -module.

This commit is contained in:
Petri Autero
2019-02-05 10:33:24 +02:00
parent cbb1111204
commit bdca995e24
4 changed files with 0 additions and 0 deletions

View File

@@ -1,61 +0,0 @@
# Cloud SQL Module
This module creates a [Google Cloud SQL](https://cloud.google.com/sql/) cluster. The cluster is managed by Google,
automating backups, replication, patches, and updates.
You can use Cloud SQL with either [MySQL](https://cloud.google.com/sql/docs/mysql/) or [PostgreSQL](https://cloud.google.com/sql/docs/postgres/).
## How do you use this module?
See the [examples](/examples) folder for an example.
## How do you configure this module?
This module allows you to configure a number of parameters, such as backup windows, maintenance window, replicas
and encryption. For a list of all available variables and their descriptions, see [variables.tf](./variables.tf).
## How do you connect to the database?
**Cloud SQL instances are created in a producer network (a VPC network internal to Google). They are not created in your VPC network.**
You can use both [public IP](https://cloud.google.com/sql/docs/mysql/connect-admin-ip) and [private IP](https://cloud.google.com/sql/docs/mysql/private-ip) to connect to a Cloud SQL instance.
Neither connection method affects the other; you must protect the public IP connection whether the instance is configured to use private IP or not.
You can also use the [Cloud SQL Proxy](https://cloud.google.com/sql/docs/mysql/connect-admin-proxy) to connect to an instance that is also configured to use private IP. The proxy can connect using either the private IP address or a public IP address.
This module provides the connection details as [Terraform output
variables](https://www.terraform.io/intro/getting-started/outputs.html):
**TODO**: Connectivity and outputs below
1. **Public IP** `private_ip`: The public endpoint for the cluster.
1. **Public IP** `public_ip`: The public endpoint for the cluster.
1. **Connection name** `connection_name`: The private endpoint for the cluster.
1. **Replica endpoints** `replica_endpoints`: A comma-separated list of all DB instance URLs in the cluster, including the primary and all
read replicas. Use these URLs for reads (see "How do you scale this DB?" below).
You can programmatically extract these variables in your Terraform templates and pass them to other resources.
You'll also see the variables at the end of each `terraform apply` call or if you run `terraform output`.
For full connectivity options and detailed documentation, see [Connecting to Cloud SQL from External Applications](https://cloud.google.com/sql/docs/mysql/connect-external-app).
## How do you scale this database?
* **Storage**: Cloud SQL manages storage for you, automatically growing cluster volume up to 10TB.
* **Vertical scaling**: To scale vertically (i.e. bigger DB instances with more CPU and RAM), use the `machine_type`
input variable. For a list of Cloud SQL Machine Types, see [Cloud SQL Pricing](https://cloud.google.com/sql/pricing#2nd-gen-pricing).
* **Horizontal scaling**: To scale horizontally, you can add more replicas using the `instance_count` input variable,
and Aurora will automatically deploy the new instances, sync them to the master, and make them available as read
replicas.
## Known Issues
### Instance Recovery
Due to limitations on the current `terraform` provider for Google, it is not possible to restore backups with `terraform`.
See https://github.com/terraform-providers/terraform-provider-google/issues/2446

View File

@@ -1,61 +0,0 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# DEPLOY A CLOUD SQL CLUSTER
# This module deploys an Cloud SQL cluster. The cluster is managed by Google and automatically handles leader
# election, replication, failover, backups, patching, and encryption.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ------------------------------------------------------------------------------
# CREATE THE CLOUD SQL CLUSTER
#
# NOTE: We have multiple google_sql_database_instance resources, based on
# HA, encryption and replication configuration options.
# ------------------------------------------------------------------------------
resource "google_sql_database_instance" "default" {
name = "${var.name}"
project = "${var.project}"
region = "${var.region}"
database_version = "${var.engine}"
master_instance_name = "${var.master_instance_name}"
settings {
tier = "${var.machine_type}"
activation_policy = "${var.activation_policy}"
authorized_gae_applications = ["${var.authorized_gae_applications}"]
disk_autoresize = "${var.disk_autoresize}"
backup_configuration = ["${var.backup_configuration}"]
ip_configuration = ["${var.ip_configuration}"]
location_preference = ["${var.location_preference}"]
maintenance_window = ["${var.maintenance_window}"]
disk_size = "${var.disk_size}"
disk_type = "${var.disk_type}"
pricing_plan = "${var.pricing_plan}"
replication_type = "${var.replication_type}"
database_flags = ["${var.flags}"]
availability_type = "${var.availability_type}"
}
replica_configuration = ["${var.replica_configuration}"]
}
# ------------------------------------------------------------------------------
# CREATE A DATABASE
# ------------------------------------------------------------------------------
resource "google_sql_database" "default" {
count = "${var.master_instance_name == "" ? 1 : 0}"
name = "${var.db_name}"
project = "${var.project}"
instance = "${google_sql_database_instance.default.name}"
charset = "${var.db_charset}"
collation = "${var.db_collation}"
}
resource "google_sql_user" "default" {
count = "${var.master_instance_name == "" ? 1 : 0}"
name = "${var.db_name}"
project = "${var.project}"
instance = "${google_sql_database_instance.default.name}"
host = "${var.db_user_host}"
password = "${var.db_password}"
}

View File

@@ -1,19 +0,0 @@
output instance_name {
description = "The name of the database instance"
value = "${google_sql_database_instance.default.name}"
}
output instance_address {
description = "The IPv4 address of the master database instance"
value = "${google_sql_database_instance.default.ip_address.0.ip_address}"
}
output instance_address_time_to_retire {
description = "The time the master instance IP address will be reitred. RFC 3339 format."
value = "${google_sql_database_instance.default.ip_address.0.time_to_retire}"
}
output self_link {
description = "Self link to the master instance"
value = "${google_sql_database_instance.default.self_link}"
}

View File

@@ -1,145 +0,0 @@
# ---------------------------------------------------------------------------------------------------------------------
# REQUIRED PARAMETERS
# These variables are expected to be passed in by the operator
# ---------------------------------------------------------------------------------------------------------------------
variable "project" {
description = "The project ID to host the database in."
}
variable "region" {
description = "The region to host the database in."
}
variable "name" {
description = "The name of the database instance."
}
variable "engine" {
description = "The engine version of the database, e.g. `MYSQL_5_7` or `POSTGRES_9_6`."
}
variable "master_instance_name" {
description = "The name of the instance that will act as the master in the replication setup. Note, this requires the master to have binary_log_enabled set, as well as existing backups."
default = ""
}
variable "machine_type" {
description = "The machine tier (First Generation) or type (Second Generation). See this page for supported tiers and pricing: https://cloud.google.com/sql/pricing"
default = "db-f1-micro"
}
variable "availability_type" {
description = "This specifies whether a PostgreSQL instance should be set up for high availability (REGIONAL) or single zone (ZONAL)."
default = "ZONAL"
}
variable "db_name" {
description = "Name of the default database to create"
default = "default"
}
variable "db_charset" {
description = "The charset for the default database"
default = ""
}
variable "db_collation" {
description = "The collation for the default database. Example for MySQL databases: 'utf8_general_ci', and Postgres: 'en_US.UTF8'"
default = ""
}
variable "db_user" {
description = "The name of the default user"
default = "default"
}
variable "db_user_host" {
description = "The host for the default user"
default = "%"
}
variable "db_password" {
description = "The password for the default user."
default = ""
}
variable "activation_policy" {
description = "This specifies when the instance should be active. Can be either `ALWAYS`, `NEVER` or `ON_DEMAND`."
default = "ALWAYS"
}
variable "authorized_gae_applications" {
description = "A list of Google App Engine (GAE) project names that are allowed to access this instance."
type = "list"
default = []
}
variable "disk_autoresize" {
description = "Second Generation only. Configuration to increase storage size automatically."
default = true
}
variable "disk_size" {
description = "Second generation only. The size of data disk, in GB. Size of a running instance cannot be reduced but can be increased."
default = 10
}
variable "disk_type" {
description = "Second generation only. The type of data disk: `PD_SSD` or `PD_HDD`."
default = "PD_SSD"
}
variable "pricing_plan" {
description = "First generation only. Pricing plan for this instance, can be one of `PER_USE` or `PACKAGE`."
default = "PER_USE"
}
variable "replication_type" {
description = "Replication type for this instance, can be one of `ASYNCHRONOUS` or `SYNCHRONOUS`."
default = "SYNCHRONOUS"
}
variable "flags" {
description = "List of Cloud SQL flags that are applied to the database server"
default = []
type = "list"
}
# IGNORE EVERYTHING BELOW
variable backup_configuration {
description = "The backup_configuration settings subblock for the database setings"
type = "map"
default = {}
}
variable ip_configuration {
description = "The ip_configuration settings subblock"
type = "list"
default = [{}]
}
variable location_preference {
description = "The location_preference settings subblock"
type = "list"
default = []
}
variable maintenance_window {
description = "The maintenance_window settings subblock"
type = "list"
default = []
}
variable replica_configuration {
description = "The optional replica_configuration block for the database instance"
type = "list"
default = []
}
# ---------------------------------------------------------------------------------------------------------------------
# OPTIONAL PARAMETERS
# Generally, these values won't need to be changed.
# ---------------------------------------------------------------------------------------------------------------------
# TODO: