mirror of
https://gitlab.sarex.io/infra/terraform-contour-mirror.git
synced 2026-08-05 18:31:00 +03:00
74 lines
2.8 KiB
HCL
74 lines
2.8 KiB
HCL
include "root" {
|
|
path = find_in_parent_folders()
|
|
}
|
|
|
|
include "env" {
|
|
path = find_in_parent_folders("env.hcl")
|
|
expose = true
|
|
merge_strategy = "deep"
|
|
}
|
|
|
|
locals {
|
|
repo_root = try(get_repo_root(), "${get_terragrunt_dir()}/../../..")
|
|
infra_config = yamldecode(file("${local.repo_root}/infrastructure.yaml"))
|
|
env_name = basename(dirname(get_terragrunt_dir()))
|
|
env_config = local.infra_config.environments[local.env_name]
|
|
|
|
manifest_repo = get_env("TOPIC_MANIFEST_REPO", "local")
|
|
manifest_path = get_env("TOPIC_MANIFEST_PATH", "")
|
|
manifest_slug = replace(replace(replace(replace("${local.manifest_repo}:${local.manifest_path}", "/", "__"), ":", "__"), ".", "_"), " ", "_")
|
|
|
|
topic_manifest_path = get_env(
|
|
"TOPIC_MANIFEST_LOCAL_PATH",
|
|
"${local.repo_root}/.generated/kafka-topics/${local.env_name}/manifest.yaml"
|
|
)
|
|
|
|
kafka_cluster_refs = {
|
|
for ref, cfg in local.env_config.kafka_cluster_refs : ref => merge(cfg, {
|
|
cluster_id = startswith(tostring(cfg.cluster_id), "env:") ? get_env(trimprefix(tostring(cfg.cluster_id), "env:"), "") : tostring(cfg.cluster_id)
|
|
})
|
|
}
|
|
}
|
|
|
|
terraform {
|
|
source = "${get_terragrunt_dir()}/../../../modules//kafka-topics-yc"
|
|
}
|
|
|
|
remote_state {
|
|
backend = "s3"
|
|
generate = {
|
|
path = "backend.tf"
|
|
if_exists = "overwrite_terragrunt"
|
|
}
|
|
config = {
|
|
endpoint = "https://storage.yandexcloud.net"
|
|
bucket = get_env("S3_STATE_BUCKET", get_env("S3_PROD_STATE_BUCKET", "tfstate-terragrunt-prod"))
|
|
key = "live/${local.env_name}/kafka-topics/${local.manifest_slug}/terraform.tfstate"
|
|
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
|
|
force_path_style = true
|
|
skip_bucket_root_access = true
|
|
}
|
|
}
|
|
|
|
inputs = {
|
|
environment = local.env_name
|
|
topic_manifest_path = local.topic_manifest_path
|
|
kafka_cluster_refs = local.kafka_cluster_refs
|
|
kafka_policy = local.env_config.kafka_policy
|
|
create_users = true
|
|
default_user_roles = ["ACCESS_ROLE_PRODUCER", "ACCESS_ROLE_CONSUMER"]
|
|
user_password_length = 32
|
|
|
|
yc_token = get_env("YC_TOKEN", "")
|
|
yc_service_account_key_file = get_env("YC_SERVICE_ACCOUNT_KEY_FILE", "")
|
|
yc_cloud_id = get_env("YC_CLOUD_ID", "")
|
|
yc_folder_id = get_env("YC_PROD_FOLDER_ID", get_env("YC_FOLDER_ID", ""))
|
|
kubeconfig_path = get_env("KUBECONFIG", "")
|
|
kube_context = get_env("KUBE_CONTEXT", "")
|
|
}
|