mirror of
https://gitlab.sarex.io/infra/terraform-contour-mirror.git
synced 2026-08-05 18:31:00 +03:00
51 lines
1.8 KiB
HCL
51 lines
1.8 KiB
HCL
include "root" {
|
|
path = find_in_parent_folders()
|
|
}
|
|
|
|
locals {
|
|
repo_root = try(get_repo_root(), "${get_terragrunt_dir()}/../..")
|
|
infra_config = yamldecode(file("${local.repo_root}/infrastructure.yaml"))
|
|
|
|
env_override = trimspace(get_env("INFRA_ENV", ""))
|
|
env_from_file = try(trimspace(local.infra_config.current_environment), "")
|
|
available_envs = sort(keys(try(local.infra_config.environments, {})))
|
|
env_fallback = try(local.available_envs[0], "")
|
|
|
|
env_name = local.env_override != "" ? local.env_override : (
|
|
local.env_from_file != "" ? local.env_from_file : local.env_fallback
|
|
)
|
|
|
|
env_config = try(local.infra_config.environments[local.env_name], {})
|
|
}
|
|
|
|
remote_state {
|
|
backend = "s3"
|
|
generate = {
|
|
path = "backend.tf"
|
|
if_exists = "overwrite_terragrunt"
|
|
}
|
|
config = {
|
|
endpoint = get_env("TF_STATE_S3_ENDPOINT", "")
|
|
bucket = get_env("TF_STATE_S3_BUCKET", "")
|
|
key = "${local.env_name}/database/terraform.tfstate"
|
|
region = get_env("TF_STATE_S3_REGION", "ru-central1")
|
|
access_key = get_env("S3_ACCESS_KEY", get_env("AWS_ACCESS_KEY_ID", ""))
|
|
secret_key = get_env("S3_SECRET_KEY", get_env("AWS_SECRET_ACCESS_KEY", ""))
|
|
skip_region_validation = true
|
|
skip_credentials_validation = true
|
|
skip_metadata_api_check = true
|
|
skip_bucket_root_access = true
|
|
force_path_style = true
|
|
}
|
|
}
|
|
|
|
terraform {
|
|
source = "${get_terragrunt_dir()}/../../modules//pg-incluster"
|
|
}
|
|
|
|
inputs = {
|
|
databases = try(local.env_config.databases, [])
|
|
default_host = try(local.env_config.postgresql.default_host, "postgresql.postgresql.svc.cluster.local")
|
|
default_port = try(local.env_config.postgresql.default_port, 5432)
|
|
}
|