Skip to content

Commit

Permalink
add(tf): #42 - codebase with default database
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-delaloy committed May 3, 2022
1 parent 066ef1f commit 6179f74
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 0 deletions.
34 changes: 34 additions & 0 deletions deploy/terraform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
43 changes: 43 additions & 0 deletions deploy/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions deploy/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

resource "random_password" "instance_password" {
length = 16
min_numeric = 4
min_upper = 4
min_special = 4
override_special = var.override_special
}

resource "scaleway_rdb_instance" "rdb_instance" {
provider = scaleway.p1
name = var.rdb_instance.name
node_type = var.rdb_instance.type
engine = var.rdb_instance.engine
user_name = var.rdb_instance.user_name
is_ha_cluster = var.rdb_instance.is_ha_cluster
disable_backup = var.rdb_instance.disable_backup
password = random_password.instance_password.result
}

# module "cluster" {
# source = "./modules/cluster"

# project_id = var.project_id
# access_key = var.access_key
# secret_key = var.secret_key
# cluster_name = var.cluster_name
# cluster_version = var.cluster_version
# cluster_tags = var.cluster_tags
# node_pool_name = var.node_pool_name
# node_pool_node_type = var.node_pool_node_type
# node_pool_min_size = var.node_pool_min_size
# node_pool_max_size = var.node_pool_max_size
# node_pool_tags = var.node_pool_tags
# install_ingress = var.install_ingress
# install_cert_manager = var.install_cert_manager
# }

# module "environments" {
# source = "./modules/environment"
# depends_on = [scaleway_rdb_instance.rdb_instance]
# for_each = var.environments

# rdb_instance_id = scaleway_rdb_instance.rdb_instance.id
# environment_name = each.value
# override_special = var.override_special
# }
17 changes: 17 additions & 0 deletions deploy/terraform/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
terraform {
required_version = ">= 0.13"

required_providers {
scaleway = {
source = "scaleway/scaleway"
version = "2.2.0"
}
}
}

provider "scaleway" {
zone = "fr-par-1"
region = "fr-par"
alias = "p1"
profile = "goyave"
}
134 changes: 134 additions & 0 deletions deploy/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# variable "project_id" {
# type = string
# description = "Your project ID."
# }

# variable "access_key" {
# type = string
# description = "Access key for scaleway authentication"
# }

# variable "secret_key" {
# type = string
# description = "Secret key for scaleway authentication"
# }

variable "cluster_name" {
type = string
description = "Cluster name"
}
variable "cluster_version" {
type = string
description = "Kubernetes version"
default = "1.22"
}
variable "cluster_tags" {
type = set(string)
description = "Labels of the cluster"
}

variable "node_pool_name" {
type = string
description = "Node pool type"
default = "workload"
}

variable "node_pool_node_type" {
type = string
description = "Node pool type"
default = "DEV1-M"
}

variable "node_pool_min_size" {
type = number
description = "Node pool min size"
default = 1
}

variable "node_pool_max_size" {
type = number
description = "Node pool max size"
default = 6
}

variable "node_pool_tags" {
type = set(string)
description = "Node labels and taints"
default = []
}


variable "install_ingress" {
type = bool
description = "Install Ingress"
default = true
}

variable "install_cert_manager" {
type = bool
description = "Install Cert Manager"
default = true
}


# variable "install_argocd" {
# type = bool
# description = "Install ArgoCD"
# default = true
# }

# variable "install_vault" {
# type = bool
# description = "Install Vault"
# default = true
# }

# variable "vault_node_pool_node_type" {
# type = string
# default = "DEV1-L"
# }

# variable "install_external_secrets" {
# type = bool
# description = "Install External Secrets"
# default = true
# }

# variable "install_backup" {
# type = bool
# description = "Install Velero"
# default = true
# }

# variable "backup_bucket_name" {
# type = string
# description = "Backup bucket name"
# }

# variable "install_keycloak" {
# type = bool
# description = "Install Keycloak"
# default = false
# }

variable "environments" {
type = set(string)
description = "List of environments to be created"
}

variable "rdb_instance" {
type = object({
name = string
type = string
engine = string
user_name = string
is_ha_cluster = bool
disable_backup = bool
})
}

variable "override_special" {
type = string
description = "Special characters for random password"
default = "!#*()-_+"
}

0 comments on commit 6179f74

Please sign in to comment.