avx-pmarie-aws-infra/infra/ingress-controller/terragrunt.hcl

155 lines
4.4 KiB
HCL
Raw Permalink Normal View History

2022-07-01 14:12:11 +02:00
include "root" {
path = find_in_parent_folders()
}
terraform {
source = "${get_repo_root()}//modules/eks-ingress-controller"
}
2022-12-09 18:08:49 +01:00
dependencies {
paths = ["../eks-kube-prometheus-stack"]
}
2022-07-01 14:12:11 +02:00
dependency "vpc" {
config_path = "../vpc"
# Configure mock outputs for the `validate` and `plan` commands that are returned when there are no outputs available
# (e.g the module hasn't been applied yet)
mock_outputs_allowed_terraform_commands = ["validate", "plan"]
mock_outputs = {
vpc_id = "fake-vpc-id"
private_subnets = ["fake-private-subnet-id-1", "fake-sprivate-ubnet-id-2"]
2022-12-09 18:08:49 +01:00
vpc_cidr_block = "10.88.0.0/24"
2022-07-01 14:12:11 +02:00
}
}
dependency "eks" {
config_path = "../eks"
# Configure mock outputs for the `validate` and `plan` commands that are returned when there are no outputs available
# (e.g the module hasn't been applied yet)
mock_outputs_allowed_terraform_commands = ["validate", "plan"]
mock_outputs = {
cluster_id = "fake-cluster-id"
cluster_endpoint = "https://fake-cluster-endpoint.eks.amazonaws.com"
cluster_certificate_authority_data = "ZmFrZS1jYS1jZXJ0LWRhdGE="
}
}
dependency "public_dns" {
config_path = "../dns-public"
mock_outputs_allowed_terraform_commands = ["validate", "plan"]
mock_outputs = {
dns_zone = {
2022-12-09 18:08:49 +01:00
name = "xxx"
2022-07-01 14:12:11 +02:00
zone_id = "ZXXXXXXXXXXXXXXXXXXX"
}
sub_zones = {
"fake.sub.zone.com" = {
2022-12-09 18:08:49 +01:00
name = "xxx"
2022-07-01 14:12:11 +02:00
zone_id = "ZXXXXXXXXXXXXXXXXXXX"
}
}
}
}
dependency "private_dns" {
config_path = "../dns-private"
mock_outputs_allowed_terraform_commands = ["validate", "plan"]
mock_outputs = {
dns_zone = {
2022-12-09 18:08:49 +01:00
name = "xxx"
2022-07-01 14:12:11 +02:00
zone_id = "ZXXXXXXXXXXXXXXXXXXX"
}
sub_zones = {
"fake.sub.zone.com" = {
2022-12-09 18:08:49 +01:00
name = "xxx"
2022-07-01 14:12:11 +02:00
zone_id = "ZXXXXXXXXXXXXXXXXXXX"
}
}
}
}
2022-07-12 22:32:18 +02:00
dependency "eips" {
config_path = "../elastic-ips"
mock_outputs_allowed_terraform_commands = ["validate", "plan"]
mock_outputs = {
eip_groups = {
eks_public_nlb = {
eips = [
{ allocation_id = "eipalloc-xxxxxxxxxxxxxxxxx" },
{ allocation_id = "eipalloc-yyyyyyyyyyyyyyyyy" }
]
}
}
}
}
2022-07-01 14:12:11 +02:00
locals {
config_vars = read_terragrunt_config(find_in_parent_folders("config.hcl"))
environment = local.config_vars.locals.environment
eks_ingress_controller = local.config_vars.locals.eks_ingress_controller
lb_config_public = merge(
local.eks_ingress_controller.load_balancer_config.public,
{
2022-07-12 22:32:18 +02:00
type = "external"
enable-proxy-protocol = true
nlb-target-type = "instance"
2022-07-01 14:12:11 +02:00
}
)
lb_config_internal = merge(
local.eks_ingress_controller.load_balancer_config.internal,
{
2022-07-12 22:32:18 +02:00
type = "external"
enable-proxy-protocol = true
nlb-target-type = "instance"
2022-07-01 14:12:11 +02:00
}
)
}
generate = local.config_vars.generate
inputs = {
cluster_id = dependency.eks.outputs.cluster_id
cluster_endpoint = dependency.eks.outputs.cluster_endpoint
cluster_certificate_authority_data = dependency.eks.outputs.cluster_certificate_authority_data
namespace = local.eks_ingress_controller.namespace
create_namespace = local.eks_ingress_controller.create_namespace
ingress_config = {
use-proxy-protocol = true
proxy-real-ip-cidr = dependency.vpc.outputs.vpc_cidr_block
use-forwarded-headers = true
compute-full-forwarded-for = true
}
load_balancer_config = {
public = local.lb_config_public,
internal = local.lb_config_internal,
2022-07-12 22:32:18 +02:00
public = merge(local.lb_config_public, {
"eip-allocations" = join(", ", dependency.eips.outputs.eip_groups.eks_public_nlb.eips.*.allocation_id),
"name" = "${dependency.eks.outputs.cluster_id}-public"
})
internal = merge(local.lb_config_internal, {
"name" = "${dependency.eks.outputs.cluster_id}-internal"
})
2022-07-01 14:12:11 +02:00
}
enable_internal_lb = local.eks_ingress_controller.enable_internal_lb
public_dns_record = {
zone_id = dependency.public_dns.outputs.dns_zone.zone_id
name = "${local.lb_config_public.dns_record}.${dependency.public_dns.outputs.dns_zone.name}"
}
internal_dns_record = {
zone_id = dependency.private_dns.outputs.dns_zone.zone_id
name = "${local.lb_config_internal.dns_record}.${dependency.private_dns.outputs.dns_zone.name}"
}
}