Init
This commit is contained in:
commit
c3bc6ab806
40 changed files with 1069 additions and 0 deletions
48
mongodb/mongodb.tf
Normal file
48
mongodb/mongodb.tf
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// MongoDB Instance
|
||||
resource "stackit_mongodbflex_instance" "this" {
|
||||
project_id = var.stackit_project_id
|
||||
name = var.mongodb_instance_name
|
||||
acl = var.mongodb_instance_acl
|
||||
backup_schedule = var.mongodb_instance_backup_schedule
|
||||
flavor = var.mongodb_instance_flavor
|
||||
options = var.mongodb_instance_options
|
||||
replicas = var.mongodb_instance_replicas
|
||||
storage = var.mongodb_instance_storage
|
||||
version = var.mongodb_instance_version
|
||||
}
|
||||
|
||||
// MongoDB User
|
||||
resource "stackit_mongodbflex_user" "this" {
|
||||
project_id = var.stackit_project_id
|
||||
instance_id = stackit_mongodbflex_instance.this.instance_id
|
||||
username = var.mongodb_user_name
|
||||
roles = var.mongodb_user_roles
|
||||
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
|
||||
# }
|
||||
# )
|
||||
# }
|
||||
29
mongodb/outputs.tf
Normal file
29
mongodb/outputs.tf
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
# MongoDB Instance
|
||||
output "mongodb_instance_id" {
|
||||
value = stackit_mongodbflex_instance.this.instance_id
|
||||
}
|
||||
|
||||
# MongoDB User
|
||||
output "mongodb_host" {
|
||||
value = stackit_mongodbflex_user.this.host
|
||||
}
|
||||
|
||||
output "mongodb_password" {
|
||||
value = stackit_mongodbflex_user.this.password
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "mongodb_port" {
|
||||
value = stackit_mongodbflex_user.this.port
|
||||
}
|
||||
|
||||
output "mongodb_uri" {
|
||||
#value = format("mongodb://%s:%s@%s:%s/%s", stackit_mongodbflex_user.this.username, stackit_mongodbflex_user.this.password, stackit_mongodbflex_instance.mongodb_instance.host, stackit_mongodbflex_instance.mongodb_instance.port
|
||||
value = stackit_mongodbflex_user.this.uri
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "mongodb_user_id" {
|
||||
value = stackit_mongodbflex_user.this.user_id
|
||||
}
|
||||
8
mongodb/providers.tf
Normal file
8
mongodb/providers.tf
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
stackit = {
|
||||
source = "stackitcloud/stackit"
|
||||
version = "~> 0.50.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
68
mongodb/variables.tf
Normal file
68
mongodb/variables.tf
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# STACKIT Project
|
||||
variable "stackit_project_id" {
|
||||
description = "ID of the stackit Project"
|
||||
type = string
|
||||
}
|
||||
# MongoDB Instance
|
||||
variable "mongodb_instance_name" {
|
||||
description = "name of the mongodb instance"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "mongodb_instance_acl" {
|
||||
description = "access control list for mongodb"
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "mongodb_instance_backup_schedule" {
|
||||
description = "backup schedule for mongodb as crontab expression"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "mongodb_instance_flavor" {
|
||||
description = "resources for mongodb"
|
||||
type = object({
|
||||
cpu = number
|
||||
ram = number
|
||||
})
|
||||
}
|
||||
|
||||
variable "mongodb_instance_options" {
|
||||
description = "options for mongodb"
|
||||
type = object({
|
||||
type = string
|
||||
})
|
||||
}
|
||||
|
||||
variable "mongodb_instance_replicas" {
|
||||
description = "number of replicas for mongodb"
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "mongodb_instance_storage" {
|
||||
description = "storage for mongodb"
|
||||
type = object({
|
||||
class = string
|
||||
size = number
|
||||
})
|
||||
}
|
||||
|
||||
variable "mongodb_instance_version" {
|
||||
description = "version of the mongodb instance"
|
||||
type = string
|
||||
}
|
||||
|
||||
# MongoDB User
|
||||
variable "mongodb_user_name" {
|
||||
description = "(optional) name of the user"
|
||||
type = string
|
||||
}
|
||||
variable "mongodb_user_roles" {
|
||||
description = "Database access levels for the user. Some of the possible values are: [read, readWrite, readWriteAnyDatabase]"
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "mongodb_user_database" {
|
||||
description = "name of the database for user to gain access to."
|
||||
type = string
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue