Compare commits
16 commits
add-k8s-ve
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| d361fa8da9 | |||
| 6909208505 | |||
| 06e9a5a586 | |||
| c23b03d9c5 | |||
| 68a6e7b5a8 | |||
| a558573190 | |||
| 3909eeab7b | |||
| 4db34d12d8 | |||
| 2cade4eba2 | |||
| 3eed77d451 | |||
| 09bff53f30 | |||
| d928465802 | |||
| 9539b43f7d | |||
| 3318babf7c | |||
| a6c34ee9bc | |||
| a668f3ad93 |
18 changed files with 116 additions and 97 deletions
|
|
@ -2,7 +2,7 @@ terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
stackit = {
|
stackit = {
|
||||||
source = "stackitcloud/stackit"
|
source = "stackitcloud/stackit"
|
||||||
version = "~> 0.61.0"
|
version = "~> 0.68.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
resource "grafana_contact_point" "this" {
|
resource "grafana_contact_point" "this" {
|
||||||
name = var.contact_point_name
|
name = var.contact_point_name
|
||||||
|
disable_provenance = true
|
||||||
|
|
||||||
googlechat {
|
googlechat {
|
||||||
url = var.gchat_url
|
url = var.gchat_url
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
resource "grafana_notification_policy" "this" {
|
resource "grafana_notification_policy" "this" {
|
||||||
contact_point = var.default_contact_point_uid
|
contact_point = var.default_contact_point_uid
|
||||||
group_by = var.group_by
|
group_by = var.group_by
|
||||||
|
disable_provenance = true
|
||||||
|
|
||||||
dynamic "policy" {
|
dynamic "policy" {
|
||||||
for_each = var.folder_policies
|
for_each = var.folder_policies
|
||||||
|
|
|
||||||
|
|
@ -19,30 +19,3 @@ resource "stackit_mongodbflex_user" "this" {
|
||||||
roles = var.mongodb_user_roles
|
roles = var.mongodb_user_roles
|
||||||
database = var.mongodb_user_database
|
database = var.mongodb_user_database
|
||||||
}
|
}
|
||||||
|
|
||||||
# // Configure Secret Manager Provider
|
|
||||||
# provider "vault" {
|
|
||||||
# address = "https://prod.sm.eu01.stackit.cloud"
|
|
||||||
# skip_child_token = true
|
|
||||||
# auth_login_userpass {
|
|
||||||
# username = var.secret_manager_username
|
|
||||||
# password = var.secret_manager_password
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# // Store MongoDB Credentials in Secret Manager
|
|
||||||
# resource "vault_kv_secret_v2" "mongodb_cred_save" {
|
|
||||||
# mount = var.secret_manager_instance_id
|
|
||||||
# name = var.mongodb_secrets_path
|
|
||||||
# cas = 1
|
|
||||||
# delete_all_versions = true
|
|
||||||
# data_json = jsonencode(
|
|
||||||
# {
|
|
||||||
# username = stackit_mongodbflex_user.mongodb_user.username,
|
|
||||||
# password = stackit_mongodbflex_user.mongodb_user.password,
|
|
||||||
# host = stackit_mongodbflex_user.mongodb_user.host,
|
|
||||||
# port = stackit_mongodbflex_user.mongodb_user.port,
|
|
||||||
# uri = stackit_mongodbflex_user.mongodb_user.uri
|
|
||||||
# }
|
|
||||||
# )
|
|
||||||
# }
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
stackit = {
|
stackit = {
|
||||||
source = "stackitcloud/stackit"
|
source = "stackitcloud/stackit"
|
||||||
version = "~> 0.50.0"
|
version = "~> 0.68.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,9 @@ variable "mongodb_instance_flavor" {
|
||||||
variable "mongodb_instance_options" {
|
variable "mongodb_instance_options" {
|
||||||
description = "options for mongodb"
|
description = "options for mongodb"
|
||||||
type = object({
|
type = object({
|
||||||
type = string
|
type = string
|
||||||
|
snapshot_retention_days = number
|
||||||
|
point_in_time_window_hours = number
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
stackit = {
|
stackit = {
|
||||||
source = "stackitcloud/stackit"
|
source = "stackitcloud/stackit"
|
||||||
version = "~> 0.50.0"
|
version = "~> 0.68.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
stackit = {
|
stackit = {
|
||||||
source = "stackitcloud/stackit"
|
source = "stackitcloud/stackit"
|
||||||
version = "~> 0.50.0"
|
version = "~> 0.68.0"
|
||||||
}
|
}
|
||||||
grafana = {
|
grafana = {
|
||||||
source = "grafana/grafana"
|
source = "grafana/grafana"
|
||||||
|
|
|
||||||
|
|
@ -2,40 +2,19 @@
|
||||||
output "postgres_instance_id" {
|
output "postgres_instance_id" {
|
||||||
value = stackit_postgresflex_instance.this.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
|
# Postgres Credential Output
|
||||||
output "postgres_host" {
|
output "postgres_credentials" {
|
||||||
value = stackit_postgresflex_user.this.host
|
value = {
|
||||||
}
|
for k, u in stackit_postgresflex_user.this :
|
||||||
|
k => {
|
||||||
output "postgres_password" {
|
host = u.host
|
||||||
value = stackit_postgresflex_user.this.password
|
username = u.username
|
||||||
|
password = u.password
|
||||||
|
port = u.port
|
||||||
|
db_name = stackit_postgresflex_database.this[u.username].name
|
||||||
|
uri = u.uri
|
||||||
|
}
|
||||||
|
}
|
||||||
sensitive = true
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -12,18 +12,24 @@ resource "stackit_postgresflex_instance" "this" {
|
||||||
|
|
||||||
// Postgres User
|
// Postgres User
|
||||||
resource "stackit_postgresflex_user" "this" {
|
resource "stackit_postgresflex_user" "this" {
|
||||||
|
for_each = {
|
||||||
|
for db in var.postgres_databases : db.user_name => db
|
||||||
|
}
|
||||||
depends_on = [ stackit_postgresflex_instance.this ]
|
depends_on = [ stackit_postgresflex_instance.this ]
|
||||||
project_id = var.stackit_project_id
|
project_id = var.stackit_project_id
|
||||||
instance_id = stackit_postgresflex_instance.this.instance_id
|
instance_id = stackit_postgresflex_instance.this.instance_id
|
||||||
username = var.postgres_db_user_name
|
username = each.value.user_name
|
||||||
roles = var.postgres_db_user_roles
|
roles = each.value.user_roles
|
||||||
}
|
}
|
||||||
|
|
||||||
// Postgres Database
|
// Postgres Database
|
||||||
resource "stackit_postgresflex_database" "this" {
|
resource "stackit_postgresflex_database" "this" {
|
||||||
depends_on = [ stackit_postgresflex_user.this ]
|
for_each = {
|
||||||
|
for db in var.postgres_databases : db.db_name => db
|
||||||
|
}
|
||||||
|
depends_on = [stackit_postgresflex_user.this]
|
||||||
project_id = var.stackit_project_id
|
project_id = var.stackit_project_id
|
||||||
instance_id = stackit_postgresflex_instance.this.instance_id
|
instance_id = stackit_postgresflex_instance.this.instance_id
|
||||||
name = var.postgres_db_name
|
name = each.value.db_name
|
||||||
owner = var.postgres_db_user_name
|
owner = each.value.user_name
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
stackit = {
|
stackit = {
|
||||||
source = "stackitcloud/stackit"
|
source = "stackitcloud/stackit"
|
||||||
version = "~> 0.50.0"
|
version = "~> 0.68.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
67
postgres/readme.md
Normal file
67
postgres/readme.md
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
# Module for creating Postgres Flex Instance with Databases and Users
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```main.tf
|
||||||
|
|
||||||
|
# Postgres Flex Instance
|
||||||
|
module "postgres-flex" {
|
||||||
|
source = "git::https://commerce-platform.git.onstackit.cloud/commerce-platform-public/terraform-modules//postgres?ref=main
|
||||||
|
stackit_project_id = local.stackit_project_id
|
||||||
|
postgres_instance_name = "example-db"
|
||||||
|
postgres_instance_replicas = 1
|
||||||
|
postgres_instance_storage = {
|
||||||
|
class = "premium-perf2-stackit"
|
||||||
|
size = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
postgres_instance_flavor = {
|
||||||
|
cpu = 2
|
||||||
|
ram = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
postgres_instance_acl = [
|
||||||
|
"193.148.160.0/19",
|
||||||
|
"45.129.40.0/21"
|
||||||
|
]
|
||||||
|
|
||||||
|
postgres_instance_backup_schedule = "00 02 * * *"
|
||||||
|
postgres_instance_version = "17"
|
||||||
|
postgres_instance_region = "eu01"
|
||||||
|
|
||||||
|
postgres_databases = [
|
||||||
|
{
|
||||||
|
db_name = "database-a"
|
||||||
|
user_name = "user-a"
|
||||||
|
user_roles = ["createdb", "login"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
db_name = "database-b"
|
||||||
|
user_name = "user-b"
|
||||||
|
user_roles = ["createdb", "login"]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# safe credentials
|
||||||
|
module "postgres-credentials-sm-a" {
|
||||||
|
source = "git::https://commerce-platform.git.onstackit.cloud/commerce-platform-public/terraform-modules//create-secret?ref=main"
|
||||||
|
secret_manager_instance_id = local.secret_manager_instance_id
|
||||||
|
secret_manager_username = var.secret_manager_username
|
||||||
|
secret_manager_password = var.secret_manager_password
|
||||||
|
|
||||||
|
secrets_path = "service-a/postgres"
|
||||||
|
secret_data = module.postgres-flex.postgres_credentials["user-a"]
|
||||||
|
}
|
||||||
|
|
||||||
|
module "postgres-credentials-sm-b" {
|
||||||
|
source = "git::https://commerce-platform.git.onstackit.cloud/commerce-platform-public/terraform-modules//create-secret?ref=main"
|
||||||
|
secret_manager_instance_id = local.secret_manager_instance_id
|
||||||
|
secret_manager_username = var.secret_manager_username
|
||||||
|
secret_manager_password = var.secret_manager_password
|
||||||
|
|
||||||
|
secrets_path = "service-b/postgres"
|
||||||
|
secret_data = module.postgres-flex.postgres_credentials["user-b"]
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
@ -10,11 +10,6 @@ variable "postgres_instance_name" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
# variable "postegres_instance_id" {
|
|
||||||
# description = "postgres instance id"
|
|
||||||
# type = string
|
|
||||||
# }
|
|
||||||
|
|
||||||
variable "postgres_instance_replicas" {
|
variable "postgres_instance_replicas" {
|
||||||
description = "number of replicas for postgres instance"
|
description = "number of replicas for postgres instance"
|
||||||
type = number
|
type = number
|
||||||
|
|
@ -58,19 +53,12 @@ variable "postgres_instance_region" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
# Postgres User Configs
|
# Postgres User and DB Configs
|
||||||
variable "postgres_db_user_name" {
|
variable "postgres_databases" {
|
||||||
description = "username and owner for postgres db"
|
description = "list of users and databases"
|
||||||
type = string
|
type = list(object({
|
||||||
}
|
db_name = string # db name inside the instance
|
||||||
|
user_name = string # username and owner for postgres db
|
||||||
variable "postgres_db_user_roles" {
|
user_roles = list(string) # List of database access levels for the user. Supported values are: login, createdb.
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,7 @@ terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
stackit = {
|
stackit = {
|
||||||
source = "stackitcloud/stackit"
|
source = "stackitcloud/stackit"
|
||||||
version = "~> 0.50.0"
|
version = "~> 0.68.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
stackit = {
|
stackit = {
|
||||||
source = "stackitcloud/stackit"
|
source = "stackitcloud/stackit"
|
||||||
version = "~> 0.50.0"
|
version = "~> 0.68.0"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ module "ske-cluster" {
|
||||||
machine_type = "c1.2"
|
machine_type = "c1.2"
|
||||||
minimum = "2"
|
minimum = "2"
|
||||||
maximum = "3"
|
maximum = "3"
|
||||||
|
os_version_min = "4230.2.0"
|
||||||
availability_zones = ["eu01-3"]
|
availability_zones = ["eu01-3"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
stackit = {
|
stackit = {
|
||||||
source = "stackitcloud/stackit"
|
source = "stackitcloud/stackit"
|
||||||
version = "~> 0.62.0"
|
version = "~> 0.68.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ variable "ske_node_pools" {
|
||||||
machine_type = string
|
machine_type = string
|
||||||
minimum = number
|
minimum = number
|
||||||
maximum = number
|
maximum = number
|
||||||
|
os_version_min = string
|
||||||
availability_zones = list(string)
|
availability_zones = list(string)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue