Move vars to json
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
bt-autoscaler/.terraform/
|
||||
esoteric-parsec*json
|
||||
*.tfstate*
|
||||
*.tfstate*
|
||||
bt-autoscaler/terraform/roots/psql/.terraform/
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"registry.terraform.io/hashicorp/google": {
|
||||
"hash": "h1:57PSAprG+Z4LymWA4ZY6kcTzxu+VTgwjpBGUy70g+9g=",
|
||||
"version": "3.10.0"
|
||||
},
|
||||
"registry.terraform.io/hashicorp/null": {
|
||||
"hash": "h1:CFnENdqQu4g3LJNevA32aDxcUz2qGkRGQpFfkI8TCdE=",
|
||||
"version": "2.1.2"
|
||||
},
|
||||
"registry.terraform.io/hashicorp/random": {
|
||||
"hash": "h1:nFL6uiwsQFLiP8QCr35sPfWe9LpXI3/c7gP9tYnih+k=",
|
||||
"version": "2.3.0"
|
||||
},
|
||||
"registry.terraform.io/hashicorp/template": {
|
||||
"hash": "h1:8NcPRk3yxQtUlAT/YGfjBEJ76rQI2ljARYeIEjhtWho=",
|
||||
"version": "2.1.2"
|
||||
},
|
||||
"registry.terraform.io/terraform-providers/postgresql": {
|
||||
"hash": "h1:XoFYBv4TT44nddycaurd4lYzIuWBx9JJzmrvcTDYX9A=",
|
||||
"version": "1.7.1"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
provider "google" {
|
||||
version = "3.10.0"
|
||||
version = "3.10.0"
|
||||
credentials = file("esoteric-parsec-243510-a8f93bb5a906.json")
|
||||
project = ${var.project}
|
||||
region = ${var.region}
|
||||
zone = ${var.zone}
|
||||
project = var.project_id
|
||||
region = var.region
|
||||
zone = var.zone
|
||||
}
|
||||
|
||||
# Create random ID for DB suffix
|
||||
@@ -13,11 +13,11 @@ resource "random_id" "db_suffix" {
|
||||
|
||||
# Create res for Cloud SQL DB config
|
||||
resource "google_sql_database_instance" "qseow-psql" {
|
||||
name = "qseow-psql-${random_id.db_suffix.hex}"
|
||||
database_version = "POSTGRES_9_6"
|
||||
settings{
|
||||
tier = "db-g1-small"
|
||||
availability_type = "REGIONAL"
|
||||
name = "qseow-psql-${random_id.db_suffix.hex}"
|
||||
database_version = var.database_version
|
||||
settings {
|
||||
tier = var.tier
|
||||
availability_type = var.availability_type
|
||||
backup_configuration {
|
||||
enabled = "true"
|
||||
}
|
||||
@@ -26,9 +26,17 @@ resource "google_sql_database_instance" "qseow-psql" {
|
||||
ip_configuration {
|
||||
ipv4_enabled = "true"
|
||||
authorized_networks {
|
||||
name = "Network ACL"
|
||||
value = ${var.aclCIDR}
|
||||
name = "Network ACL A"
|
||||
value = var.authorized_networks_a
|
||||
}
|
||||
authorized_networks {
|
||||
name = "Network ACL B"
|
||||
value = var.authorized_networks_b
|
||||
}
|
||||
# authorized_networks {
|
||||
# name = "Network ACL C"
|
||||
# value = var.authorized_networks_c
|
||||
# }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,9 +52,9 @@ output "psql_name" {
|
||||
|
||||
# Configure postgres user
|
||||
resource "google_sql_user" "users" {
|
||||
name = "postgres"
|
||||
instance = google_sql_database_instance.qseow-psql.name
|
||||
password = ${var.postgresPwd}
|
||||
name = var.user_name
|
||||
password = var.user_password
|
||||
}
|
||||
|
||||
# Proto-section for setting up DBs/executing .sql file
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
project = "esoteric-parsec-243510"
|
||||
region = "us-central1"
|
||||
zone = "us-central1-a"
|
||||
aclCIDR = "71.164.77.198/32"
|
||||
postgresPwd = "Qlik1234!"
|
||||
12
bt-autoscaler/terraform/roots/psql/terraform.tfvars.json
Normal file
12
bt-autoscaler/terraform/roots/psql/terraform.tfvars.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"project_id": "esoteric-parsec-243510",
|
||||
"region": "us-central1",
|
||||
"zone": "us-central1-a",
|
||||
"database_version": "POSTGRES_9_6",
|
||||
"tier": "db-g1-small",
|
||||
"availability_type": "REGIONAL",
|
||||
"authorized_networks_a": "71.164.77.198/32",
|
||||
"authorized_networks_b": "34.71.18.199/32",
|
||||
"user_name": "postgres",
|
||||
"user_password": "Qlik1234!"
|
||||
}
|
||||
277
bt-autoscaler/terraform/roots/psql/variables.tf
Normal file
277
bt-autoscaler/terraform/roots/psql/variables.tf
Normal file
@@ -0,0 +1,277 @@
|
||||
/**
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
variable "project_id" {
|
||||
type = string
|
||||
description = "The project ID to manage the Cloud SQL resources"
|
||||
}
|
||||
|
||||
// required
|
||||
variable "database_version" {
|
||||
description = "The database version to use"
|
||||
type = string
|
||||
}
|
||||
|
||||
// required
|
||||
variable "region" {
|
||||
type = string
|
||||
description = "The region of the Cloud SQL resources"
|
||||
default = "us-central1"
|
||||
}
|
||||
|
||||
variable "tier" {
|
||||
description = "The tier for the master instance."
|
||||
type = string
|
||||
default = "db-f1-micro"
|
||||
}
|
||||
|
||||
variable "zone" {
|
||||
type = string
|
||||
description = "The zone for the master instance, it should be something like: `a`, `c`."
|
||||
}
|
||||
|
||||
variable "availability_type" {
|
||||
description = "The availability type for the master instance.This is only used to set up high availability for the PostgreSQL instance. Can be either `ZONAL` or `REGIONAL`."
|
||||
type = string
|
||||
default = "ZONAL"
|
||||
}
|
||||
|
||||
# variable "disk_autoresize" {
|
||||
# description = "Configuration to increase storage size."
|
||||
# type = bool
|
||||
# default = true
|
||||
# }
|
||||
|
||||
# variable "disk_size" {
|
||||
# description = "The disk size for the master instance."
|
||||
# default = 10
|
||||
# }
|
||||
|
||||
# variable "disk_type" {
|
||||
# description = "The disk type for the master instance."
|
||||
# type = string
|
||||
# default = "PD_SSD"
|
||||
# }
|
||||
|
||||
# variable "pricing_plan" {
|
||||
# description = "The pricing plan for the master instance."
|
||||
# type = string
|
||||
# default = "PER_USE"
|
||||
# }
|
||||
|
||||
# variable "maintenance_window_day" {
|
||||
# description = "The day of week (1-7) for the master instance maintenance."
|
||||
# type = number
|
||||
# default = 1
|
||||
# }
|
||||
|
||||
# variable "maintenance_window_hour" {
|
||||
# description = "The hour of day (0-23) maintenance window for the master instance maintenance."
|
||||
# type = number
|
||||
# default = 23
|
||||
# }
|
||||
|
||||
# variable "maintenance_window_update_track" {
|
||||
# description = "The update track of maintenance window for the master instance maintenance.Can be either `canary` or `stable`."
|
||||
# type = string
|
||||
# default = "canary"
|
||||
# }
|
||||
|
||||
# variable "database_flags" {
|
||||
# description = "The database flags for the master instance. See [more details](https://cloud.google.com/sql/docs/postgres/flags)"
|
||||
# type = list(object({
|
||||
# name = string
|
||||
# value = string
|
||||
# }))
|
||||
# default = []
|
||||
# }
|
||||
|
||||
# variable "user_labels" {
|
||||
# description = "The key/value labels for the master instances."
|
||||
# type = map(string)
|
||||
# default = {}
|
||||
# }
|
||||
|
||||
variable "backup_configuration" {
|
||||
description = "The backup_configuration settings subblock for the database setings"
|
||||
type = object({
|
||||
enabled = bool
|
||||
start_time = string
|
||||
location = string
|
||||
})
|
||||
default = {
|
||||
enabled = false
|
||||
start_time = null
|
||||
location = null
|
||||
}
|
||||
}
|
||||
|
||||
# variable "ip_configuration" {
|
||||
# description = "The ip configuration for the master instances."
|
||||
# type = object({
|
||||
# authorized_networks = list(map(string))
|
||||
# ipv4_enabled = bool
|
||||
# private_network = string
|
||||
# require_ssl = bool
|
||||
# })
|
||||
# default = {
|
||||
# authorized_networks = []
|
||||
# ipv4_enabled = true
|
||||
# private_network = null
|
||||
# require_ssl = null
|
||||
# }
|
||||
# }
|
||||
|
||||
# "authorized_networks": [
|
||||
# {
|
||||
# "name": "home",
|
||||
# "value": "71.164.77.198/32"
|
||||
# },
|
||||
# {
|
||||
# "name": "GCE",
|
||||
# "value": "34.71.18.199/32"
|
||||
# }
|
||||
# ],
|
||||
|
||||
variable "authorized_networks_a" {
|
||||
description = "CIDR Block to add to network ACL"
|
||||
type = string
|
||||
default = "71.164.77.198/32"
|
||||
}
|
||||
|
||||
variable "authorized_networks_b" {
|
||||
description = "CIDR Block to add to network ACL"
|
||||
type = string
|
||||
default = "127.0.0.1/32"
|
||||
}
|
||||
|
||||
variable "authorized_networks_c" {
|
||||
description = "CIDR Block to add to network ACL"
|
||||
type = string
|
||||
default = "127.0.0.1/32"
|
||||
}
|
||||
|
||||
|
||||
// Read Replicas
|
||||
variable "read_replicas" {
|
||||
description = "List of read replicas to create"
|
||||
type = list(object({
|
||||
name = string
|
||||
tier = string
|
||||
zone = string
|
||||
disk_type = string
|
||||
disk_autoresize = bool
|
||||
disk_size = string
|
||||
user_labels = map(string)
|
||||
database_flags = list(object({
|
||||
name = string
|
||||
value = string
|
||||
}))
|
||||
ip_configuration = object({
|
||||
authorized_networks = list(map(string))
|
||||
ipv4_enabled = bool
|
||||
private_network = string
|
||||
require_ssl = bool
|
||||
})
|
||||
}))
|
||||
default = []
|
||||
}
|
||||
|
||||
# variable "read_replica_name_suffix" {
|
||||
# description = "The optional suffix to add to the read instance name"
|
||||
# type = string
|
||||
# default = ""
|
||||
# }
|
||||
|
||||
# variable "db_name" {
|
||||
# description = "The name of the default database to create"
|
||||
# type = string
|
||||
# default = "default"
|
||||
# }
|
||||
|
||||
# variable "db_charset" {
|
||||
# description = "The charset for the default database"
|
||||
# type = string
|
||||
# default = ""
|
||||
# }
|
||||
|
||||
# variable "db_collation" {
|
||||
# description = "The collation for the default database. Example: 'en_US.UTF8'"
|
||||
# type = string
|
||||
# default = ""
|
||||
# }
|
||||
|
||||
variable "additional_databases" {
|
||||
description = "A list of databases to be created in your cluster"
|
||||
type = list(object({
|
||||
name = string
|
||||
charset = string
|
||||
collation = string
|
||||
}))
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "user_name" {
|
||||
description = "The name of the default user"
|
||||
type = string
|
||||
default = "default"
|
||||
}
|
||||
|
||||
variable "user_password" {
|
||||
description = "The password for the default user. If not set, a random one will be generated and available in the generated_user_password output variable."
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "additional_users" {
|
||||
description = "A list of users to be created in your cluster"
|
||||
type = list(object({
|
||||
name = string
|
||||
password = string
|
||||
}))
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "create_timeout" {
|
||||
description = "The optional timout that is applied to limit long database creates."
|
||||
type = string
|
||||
default = "10m"
|
||||
}
|
||||
|
||||
variable "update_timeout" {
|
||||
description = "The optional timout that is applied to limit long database updates."
|
||||
type = string
|
||||
default = "10m"
|
||||
}
|
||||
|
||||
variable "delete_timeout" {
|
||||
description = "The optional timout that is applied to limit long database deletes."
|
||||
type = string
|
||||
default = "10m"
|
||||
}
|
||||
|
||||
variable "encryption_key_name" {
|
||||
description = "The full path to the encryption key used for the CMEK disk encryption"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "module_depends_on" {
|
||||
description = "List of modules or resources this module depends on."
|
||||
type = list(any)
|
||||
default = []
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ terraform {
|
||||
template = {
|
||||
source = "hashicorp/template"
|
||||
}
|
||||
null = {
|
||||
source = "hashicorp/null"
|
||||
}
|
||||
}
|
||||
required_version = ">= 0.13"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user