145 lines
5.3 KiB
HCL

module "label" {
source = "git@github.com:cloudposse/terraform-null-label.git?ref=tags/0.24.1"
name = var.name
stage = var.stage
delimiter = var.delimiter
#attributes = compact(concat(var.attributes, list("cluster")))
attributes = compact(concat(var.attributes, tolist(["cluster"])))
tags = var.tags
}
locals {
tags = merge(module.label.tags, tomap({ "kubernetes.io/cluster/${module.label.id}" = "shared"}))
}
#module "carnext_poc-day0-deploy" {
# #source = "git::https://terraform:czf1xEsPje-nCsyuyUby@gitlab.carnext.io/infra/terraform/modules/day0-roles.git?ref=tags/0.0.2"
# source = "git@github.com:webuildyourcloud/terraform-aws-day0-roles.git"
#}
#
#module "carnext_poc-asume-role" {
# #source = "git::https://terraform:czf1xEsPje-nCsyuyUby@gitlab.carnext.io/infra/terraform/modules/asume-role.git?ref=tags/0.0.2"
# source = "git@github.com:webuildyourcloud/terraform-aws-assume-role.git"
#}
#
module "vpc" {
#source = "git@github.com:cloudposse/terraform-aws-vpc.git?ref=tags/0.25.0"
source = "cloudposse/vpc/aws"
version = "0.25.0"
stage = var.stage
name = var.name
attributes = var.attributes
cidr_block = var.vpc_cidr_block
tags = local.tags
}
#module "flow_logs" {
# #source = "git::https://terraform:czf1xEsPje-nCsyuyUby@gitlab.carnext.io/infra/terraform/modules/terraform-aws-cloudwatch-flow-logs.git?ref=tags/0.3.3"
# source = "git@github.com:webuildyourcloud/terraform-aws-cloudwatch-flow_logs.git"
# vpc_id = module.vpc.vpc_id
# stage = var.stage
#}
#
module "vpc-flow-logs" {
source = "umotif-public/vpc-flow-logs/aws"
version = "~> 1.1.2"
name_prefix = var.name
vpc_id = module.vpc.vpc_id
traffic_type = "ALL"
tags = local.tags
}
module "subnets" {
#source = "git@github.com:cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.39.0"
source = "cloudposse/dynamic-subnets/aws"
version = "0.39.0"
availability_zones = var.availability_zones
stage = var.stage
name = var.name
attributes = var.attributes
vpc_id = module.vpc.vpc_id
igw_id = module.vpc.igw_id
cidr_block = module.vpc.vpc_cidr_block
nat_gateway_enabled = true
nat_instance_enabled = false
tags = local.tags
}
#module "vpc_endpoints" {
# #count = var.enable_s3_endpoint ? 1 : 0
# source = "git@github.com:webuildyourcloud/terraform-aws-vpc_endpoints.git?ref=tags/0.0.2"
# #region = var.region
# #name = var.name
# vpc_id = module.vpc.vpc_id
# private_route_table_ids = module.subnets.private_route_table_ids
# public_route_table_ids = module.subnets.public_route_table_ids
# #tags = local.tags
#}
module "bastion" {
source = "git@github.com:webuildyourcloud/terraform-aws-bastion.git?ref=tags/0.0.6"
enable_bastion = true
environment = var.stage
project = var.prefix
aws_region = var.region
key_name = var.keyname
instance_type = var.bastion_instance_type
subnet_id = element(module.subnets.public_subnet_ids, 0)
vpc_id = module.vpc.vpc_id
tags = {
Name = "${var.prefix}-${var.stage}-bastion"
}
}
module "eks_cluster" {
source = "git@github.com:webuildyourcloud/terraform-aws-eks-cluster.git?ref=tags/0.0.3"
stage = var.stage
name = var.name
attributes = var.attributes
tags = var.tags
region = var.region
vpc_id = module.vpc.vpc_id
subnet_ids = module.subnets.private_subnet_ids
kubernetes_version = var.kubernetes_version
kubeconfig_path = var.kubeconfig_path
oidc_provider_enabled = var.oidc_provider_enabled
workers_role_arns = [module.eks_node_group.eks_node_group_role_arn]
workers_security_group_ids = [module.eks_cluster.workers_security_group_ids]
aws_eks_update_kubeconfig_additional_arguments = var.aws_eks_update_kubeconfig_additional_arguments
}
module "eks_node_group" {
source = "git@github.com:webuildyourcloud/terraform-aws-eks_node_group.git?ref=tags/0.0.2"
stage = var.stage
name = var.name
attributes = var.attributes
tags = var.tags
subnet_ids = module.subnets.private_subnet_ids
instance_types = var.instance_types
desired_size = var.desired_size
min_size = var.min_size
max_size = var.max_size
cluster_name = module.eks_cluster.eks_cluster_id
kubernetes_version = var.kubernetes_version
kubernetes_labels = var.kubernetes_labels
}
#module "eks_fargate_profile" {
# source = "git@github.com:webuildyourcloud/terraform-aws-eks_fargate_profile.git?ref=tags/0.0.2"
# stage = var.stage
# name = var.name
# attributes = var.attributes
# tags = var.tags
# subnet_ids = module.subnets.private_subnet_ids
# cluster_name = module.eks_cluster.eks_cluster_id
# kubernetes_namespace = var.kubernetes_namespace
# kubernetes_labels = var.kubernetes_labels
#}