/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: MIT-0 * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * software and associated documentation files (the "Software"), to deal in the Software * without restriction, including without limitation the rights to use, copy, modify, * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ terraform { required_version = ">= 1.0.1" required_providers { aws = { source = "hashicorp/aws" version = ">= 3.66.0" } kubernetes = { source = "hashicorp/kubernetes" version = ">= 2.7.1" } helm = { source = "hashicorp/helm" version = ">= 2.4.1" } } } provider "aws" { region = data.aws_region.current.id alias = "default" } data "aws_region" "current" {} data "aws_availability_zones" "available" {} #--------------------------------------------------------------- # Note: Terraform_remote_state for S3 backend can be imported using the below code snippet #--------------------------------------------------------------- /* data "terraform_remote_state" "vpc_s3_backend" { backend = "s3" config = { bucket = "" # Bucket name key = "" # Key path to terraform-main.tfstate file region = "" # aws region } vpc_id = data.terraform_remote_state.vpc_s3_backend.outputs.vpc_id private_subnet_ids = data.terraform_remote_state.vpc_s3_backend.outputs.private_subnets public_subnet_ids = data.terraform_remote_state.vpc_s3_backend.outputs.public_subnets }*/ locals { tenant = var.tenant environment = var.environment zone = var.zone kubernetes_version = "1.21" terraform_version = "Terraform v1.0.1" vpc_id = var.vpc_id private_subnet_ids = var.private_subnet_ids public_subnet_ids = var.public_subnet_ids } module "aws-eks-accelerator-for-terraform" { source = "github.com/aws-samples/aws-eks-accelerator-for-terraform" tenant = local.tenant environment = local.environment zone = local.zone terraform_version = local.terraform_version # EKS Cluster VPC and Subnets vpc_id = local.vpc_id private_subnet_ids = local.private_subnet_ids # EKS CONTROL PLANE VARIABLES create_eks = true kubernetes_version = local.kubernetes_version # EKS MANAGED NODE GROUPS managed_node_groups = { mg_4 = { node_group_name = "managed-ondemand" instance_types = ["m5.large"] subnet_ids = local.private_subnet_ids } } # Fargate profiles fargate_profiles = { default = { fargate_profile_name = "default" fargate_profile_namespaces = [ { namespace = "default" k8s_labels = { Environment = "preprod" Zone = "dev" env = "fargate" } }] subnet_ids = local.private_subnet_ids additional_tags = { ExtraTag = "Fargate" } }, } # AWS Managed Services enable_amazon_prometheus = true enable_emr_on_eks = true emr_on_eks_teams = { data_team_a = { emr_on_eks_namespace = "emr-data-team-a" emr_on_eks_iam_role_name = "emr-eks-data-team-a" } data_team_b = { emr_on_eks_namespace = "emr-data-team-b" emr_on_eks_iam_role_name = "emr-eks-data-team-b" } } } module "kubernetes-addons" { source = "github.com/aws-samples/aws-eks-accelerator-for-terraform//modules/kubernetes-addons" eks_cluster_id = module.aws-eks-accelerator-for-terraform.eks_cluster_id eks_oidc_issuer_url = module.aws-eks-accelerator-for-terraform.eks_oidc_issuer_url eks_oidc_provider_arn = module.aws-eks-accelerator-for-terraform.eks_oidc_provider_arn eks_worker_security_group_id = module.aws-eks-accelerator-for-terraform.worker_security_group_id auto_scaling_group_names = module.aws-eks-accelerator-for-terraform.self_managed_node_group_autoscaling_groups # EKS Managed Add-ons enable_amazon_eks_vpc_cni = true enable_amazon_eks_coredns = true enable_amazon_eks_kube_proxy = true enable_amazon_eks_aws_ebs_csi_driver = true #K8s Add-ons enable_aws_load_balancer_controller = true enable_metrics_server = true enable_cluster_autoscaler = true enable_vpa = true enable_prometheus = true enable_ingress_nginx = true enable_aws_for_fluentbit = true enable_argocd = true enable_fargate_fluentbit = true }