|
| 1 | +provider "aws" { |
| 2 | + region = local.region |
| 3 | +} |
| 4 | + |
| 5 | +provider "kubernetes" { |
| 6 | + host = module.eks_blueprints.eks_cluster_endpoint |
| 7 | + cluster_ca_certificate = base64decode(module.eks_blueprints.eks_cluster_certificate_authority_data) |
| 8 | + token = data.aws_eks_cluster_auth.this.token |
| 9 | +} |
| 10 | + |
| 11 | +provider "helm" { |
| 12 | + kubernetes { |
| 13 | + host = module.eks_blueprints.eks_cluster_endpoint |
| 14 | + cluster_ca_certificate = base64decode(module.eks_blueprints.eks_cluster_certificate_authority_data) |
| 15 | + token = data.aws_eks_cluster_auth.this.token |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +module "vpc" { |
| 20 | + source = "terraform-aws-modules/vpc/aws" |
| 21 | + version = "~> 3.0" |
| 22 | + |
| 23 | + name = local.name |
| 24 | + cidr = local.vpc_cidr |
| 25 | + |
| 26 | + azs = local.azs |
| 27 | + public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)] |
| 28 | + private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 10)] |
| 29 | + |
| 30 | + enable_nat_gateway = true |
| 31 | + single_nat_gateway = true |
| 32 | + enable_dns_hostnames = true |
| 33 | + |
| 34 | + # Manage so we can name |
| 35 | + manage_default_network_acl = true |
| 36 | + default_network_acl_tags = { Name = "${local.name}-default" } |
| 37 | + manage_default_route_table = true |
| 38 | + default_route_table_tags = { Name = "${local.name}-default" } |
| 39 | + manage_default_security_group = true |
| 40 | + default_security_group_tags = { Name = "${local.name}-default" } |
| 41 | + |
| 42 | + public_subnet_tags = { |
| 43 | + "kubernetes.io/cluster/${local.name}" = "shared" |
| 44 | + "kubernetes.io/role/elb" = 1 |
| 45 | + } |
| 46 | + |
| 47 | + private_subnet_tags = { |
| 48 | + "kubernetes.io/cluster/${local.name}" = "shared" |
| 49 | + "kubernetes.io/role/internal-elb" = 1 |
| 50 | + } |
| 51 | + |
| 52 | + tags = local.tags |
| 53 | +} |
| 54 | + |
| 55 | +module "eks_blueprints" { |
| 56 | + source = "github.com/aws-ia/terraform-aws-eks-blueprints" |
| 57 | + |
| 58 | + cluster_name = local.name |
| 59 | + cluster_version = "1.22" |
| 60 | + |
| 61 | + vpc_id = module.vpc.vpc_id |
| 62 | + private_subnet_ids = module.vpc.private_subnets |
| 63 | + |
| 64 | + managed_node_groups = { |
| 65 | + t3_l = { |
| 66 | + node_group_name = "managed-ondemand" |
| 67 | + instance_types = ["t3.large"] |
| 68 | + min_size = 2 |
| 69 | + subnet_ids = module.vpc.private_subnets |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + tags = local.tags |
| 74 | +} |
| 75 | + |
| 76 | + |
| 77 | +module "observability_accelerator" { |
| 78 | + source = "../../" |
| 79 | + |
| 80 | + aws_region = local.region |
| 81 | + eks_cluster_id = module.eks_blueprints.eks_cluster_id |
| 82 | + |
| 83 | + enable_alertmanager = true |
| 84 | + enable_managed_grafana = false |
| 85 | + |
| 86 | + managed_grafana_workspace_id = var.managed_grafana_workspace_id |
| 87 | + managed_grafana_region = var.managed_grafana_region |
| 88 | + |
| 89 | + grafana_api_key = var.grafana_api_key |
| 90 | + |
| 91 | + tags = { |
| 92 | + Source = "aws-observability-accelerator" |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | +module "infra" { |
| 97 | + source = "../../modules/workloads/infra" |
| 98 | + |
| 99 | + dashboards_folder_id = module.observability_accelerator.dashboards_folder_id |
| 100 | + eks_cluster_id = module.eks_blueprints.eks_cluster_id |
| 101 | + enable_alerting_rules = false |
| 102 | + |
| 103 | + managed_prometheus_workspace_id = module.observability_accelerator.managed_prometheus_workspace_id |
| 104 | + managed_prometheus_workspace_region = module.observability_accelerator.managed_prometheus_workspace_region |
| 105 | + |
| 106 | + tags = { |
| 107 | + Source = "aws-observability-accelerator" |
| 108 | + } |
| 109 | +} |
| 110 | + |
0 commit comments