Init
This commit is contained in:
commit
c3bc6ab806
40 changed files with 1069 additions and 0 deletions
41
postgres/outputs.tf
Normal file
41
postgres/outputs.tf
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# Postgres Instance Output
|
||||
output "postgres_instance_id" {
|
||||
value = stackit_postgresflex_instance.this.instance_id
|
||||
}
|
||||
|
||||
# Postgres Database Output
|
||||
output "postgres_database_id" {
|
||||
value = stackit_postgresflex_database.this.database_id
|
||||
}
|
||||
|
||||
# Postgres User Output
|
||||
output "postgres_host" {
|
||||
value = stackit_postgresflex_user.this.host
|
||||
}
|
||||
|
||||
output "postgres_password" {
|
||||
value = stackit_postgresflex_user.this.password
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "postgres_user" {
|
||||
value = stackit_postgresflex_user.this.username
|
||||
}
|
||||
|
||||
output "postgres_port" {
|
||||
value = stackit_postgresflex_user.this.port
|
||||
}
|
||||
|
||||
output "postgres_db_name" {
|
||||
value = stackit_postgresflex_database.this.name
|
||||
}
|
||||
|
||||
output "postgres_uri" {
|
||||
value = stackit_postgresflex_user.this.uri
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "postgres_user_id" {
|
||||
value = stackit_postgresflex_user.this.user_id
|
||||
}
|
||||
|
||||
29
postgres/postgres.tf
Normal file
29
postgres/postgres.tf
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// Postgres Instance
|
||||
resource "stackit_postgresflex_instance" "this" {
|
||||
project_id = var.stackit_project_id
|
||||
name = var.postgres_instance_name
|
||||
acl = var.postgres_instance_acl
|
||||
backup_schedule = var.postgres_instance_backup_schedule
|
||||
flavor = var.postgres_instance_flavor
|
||||
replicas = var.postgres_instance_replicas
|
||||
storage = var.postgres_instance_storage
|
||||
version = var.postgres_instance_version
|
||||
}
|
||||
|
||||
// Postgres User
|
||||
resource "stackit_postgresflex_user" "this" {
|
||||
depends_on = [ stackit_postgresflex_instance.this ]
|
||||
project_id = var.stackit_project_id
|
||||
instance_id = stackit_postgresflex_instance.this.instance_id
|
||||
username = var.postgres_db_user_name
|
||||
roles = var.postgres_db_user_roles
|
||||
}
|
||||
|
||||
// Postgres Database
|
||||
resource "stackit_postgresflex_database" "this" {
|
||||
depends_on = [ stackit_postgresflex_user.this ]
|
||||
project_id = var.stackit_project_id
|
||||
instance_id = stackit_postgresflex_instance.this.instance_id
|
||||
name = var.postgres_db_name
|
||||
owner = var.postgres_db_user_name
|
||||
}
|
||||
8
postgres/providers.tf
Normal file
8
postgres/providers.tf
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
stackit = {
|
||||
source = "stackitcloud/stackit"
|
||||
version = "~> 0.50.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
76
postgres/variables.tf
Normal file
76
postgres/variables.tf
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# STACKIT Project
|
||||
variable "stackit_project_id" {
|
||||
description = "ID of the stackit Project"
|
||||
type = string
|
||||
}
|
||||
|
||||
# Postgres Instance Config
|
||||
variable "postgres_instance_name" {
|
||||
description = "postgres instance name"
|
||||
type = string
|
||||
}
|
||||
|
||||
# variable "postegres_instance_id" {
|
||||
# description = "postgres instance id"
|
||||
# type = string
|
||||
# }
|
||||
|
||||
variable "postgres_instance_replicas" {
|
||||
description = "number of replicas for postgres instance"
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "postgres_instance_flavor" {
|
||||
description = "resources for postgres"
|
||||
type = object({
|
||||
cpu = number
|
||||
ram = number
|
||||
})
|
||||
}
|
||||
|
||||
variable "postgres_instance_storage" {
|
||||
description = "storage definition for postgres instance"
|
||||
type = object({
|
||||
class = string # note: value can be any of (premium-perfX-stackit) where X = (2,4,6,8,10,12). Higher number is faster
|
||||
size = number
|
||||
})
|
||||
}
|
||||
|
||||
variable "postgres_instance_acl" {
|
||||
description = "acl for postgres instance"
|
||||
type = list(string)
|
||||
default = ["193.148.160.0/19", "45.129.40.0/21"] # todo: revisit IP list and set VPN IP range as default
|
||||
}
|
||||
|
||||
variable "postgres_instance_backup_schedule" {
|
||||
description = "backup schedule as crontab for postgres instance"
|
||||
type = string
|
||||
default = "00 02 * * *" # todo: set default based on your needs
|
||||
}
|
||||
|
||||
variable "postgres_instance_version" {
|
||||
description = "postgres version for instance"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "postgres_instance_region" {
|
||||
description = "region for postgres instance"
|
||||
type = string
|
||||
}
|
||||
|
||||
# Postgres User Configs
|
||||
variable "postgres_db_user_name" {
|
||||
description = "username and owner for postgres db"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "postgres_db_user_roles" {
|
||||
description = "List of database access levels for the user. Supported values are: login, createdb."
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
# Postgres Database Configs
|
||||
variable "postgres_db_name" {
|
||||
description = "db name inside the instance"
|
||||
type = string
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue