Difference between revisions of "Terraform EKS module official usage example"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
 
(17 intermediate revisions by one other user not shown)
Line 2: Line 2:
 
  module "eks" {
 
  module "eks" {
 
   source  = "terraform-aws-modules/eks/aws"
 
   source  = "terraform-aws-modules/eks/aws"
   version = "~> 19.0"
+
   [[version =]] "~> 19.0"
 
   
 
   
 
   cluster_name    = "my-cluster"
 
   cluster_name    = "my-cluster"
Line 10: Line 10:
 
   
 
   
 
   [[cluster_addons]] = {
 
   [[cluster_addons]] = {
     coredns = {
+
     [[coredns]] = {
 
       most_recent = true
 
       most_recent = true
 
     }
 
     }
Line 20: Line 20:
 
     }
 
     }
 
   }
 
   }
<pre>
+
   vpc_id                  = "vpc-1234556abcdef"
+
   [[vpc_id]]                   = "vpc-1234556abcdef"
 
   subnet_ids              = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
 
   subnet_ids              = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
 
   control_plane_subnet_ids = ["subnet-xyzde987", "subnet-slkjf456", "subnet-qeiru789"]
 
   control_plane_subnet_ids = ["subnet-xyzde987", "subnet-slkjf456", "subnet-qeiru789"]
 
+
 
   # Self Managed Node Group(s)
 
   # Self Managed Node Group(s)
 
   self_managed_node_group_defaults = {
 
   self_managed_node_group_defaults = {
Line 33: Line 33:
 
     }
 
     }
 
   }
 
   }
 
+
   self_managed_node_groups = {
+
   [[self_managed_node_groups]] = {
 
     one = {
 
     one = {
 
       name        = "mixed-1"
 
       name        = "mixed-1"
 
       max_size    = 5
 
       max_size    = 5
 
       desired_size = 2
 
       desired_size = 2
 
+
 
       use_mixed_instances_policy = true
 
       use_mixed_instances_policy = true
 
       mixed_instances_policy = {
 
       mixed_instances_policy = {
Line 47: Line 47:
 
           spot_allocation_strategy                = "capacity-optimized"
 
           spot_allocation_strategy                = "capacity-optimized"
 
         }
 
         }
 
+
 
         override = [
 
         override = [
 
           {
 
           {
Line 61: Line 61:
 
     }
 
     }
 
   }
 
   }
 
+
 
   # EKS Managed Node Group(s)
 
   # EKS Managed Node Group(s)
 
   eks_managed_node_group_defaults = {
 
   eks_managed_node_group_defaults = {
 
     instance_types = ["m6i.large", "m5.large", "m5n.large", "m5zn.large"]
 
     instance_types = ["m6i.large", "m5.large", "m5n.large", "m5zn.large"]
 
   }
 
   }
 
+
   eks_managed_node_groups = {
+
   [[eks_managed_node_groups]] = {
 
     blue = {}
 
     blue = {}
 
     green = {
 
     green = {
Line 73: Line 73:
 
       max_size    = 10
 
       max_size    = 10
 
       desired_size = 1
 
       desired_size = 1
 
+
 
       instance_types = ["t3.large"]
 
       instance_types = ["t3.large"]
 
       capacity_type  = "SPOT"
 
       capacity_type  = "SPOT"
 
     }
 
     }
 
   }
 
   }
 
+
 
   # Fargate Profile(s)
 
   # Fargate Profile(s)
   fargate_profiles = {
+
   [[fargate_profiles]] = {
 
     default = {
 
     default = {
 
       name = "default"
 
       name = "default"
Line 90: Line 90:
 
     }
 
     }
 
   }
 
   }
 
+
 
   # aws-auth configmap
 
   # aws-auth configmap
   manage_aws_auth_configmap = true
+
   [[manage_aws_auth_configmap]] = true
 
+
   aws_auth_roles = [
+
   [[aws_auth_roles]] = [
 
     {
 
     {
 
       rolearn  = "arn:aws:iam::66666666666:role/role1"
 
       rolearn  = "arn:aws:iam::66666666666:role/role1"
Line 101: Line 101:
 
     },
 
     },
 
   ]
 
   ]
 
+
   aws_auth_users = [
+
   [[aws_auth_users]] = [
 
     {
 
     {
 
       userarn  = "arn:aws:iam::66666666666:user/user1"
 
       userarn  = "arn:aws:iam::66666666666:user/user1"
Line 115: Line 115:
 
   ]
 
   ]
  
   aws_auth_accounts = [
+
   [[aws_auth_accounts]] = [
 
     "777777777777",
 
     "777777777777",
 
     "888888888888",
 
     "888888888888",
Line 124: Line 124:
 
     Terraform  = "true"
 
     Terraform  = "true"
 
   }
 
   }
}
+
}
</pre>
+
 
 +
== Related ==
 +
* [[AmazonEKSWorkerNodePolicy]]
 +
* [[InvalidVpcID.NotFound]]
 +
[[tf show]] | grep vpc_ip
 +
[[tf show]] | grep [[subnet_id]]
  
 
== See also ==
 
== See also ==

Latest revision as of 12:57, 4 March 2024

module "eks" {
 source  = "terraform-aws-modules/eks/aws"
 version = "~> 19.0"

 cluster_name    = "my-cluster"
 cluster_version = "1.24"

 cluster_endpoint_public_access  = true

 cluster_addons = {
   coredns = {
     most_recent = true
   }
   kube-proxy = {
     most_recent = true
   }
   vpc-cni = {
     most_recent = true
   }
 }

 vpc_id                   = "vpc-1234556abcdef"
 subnet_ids               = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
 control_plane_subnet_ids = ["subnet-xyzde987", "subnet-slkjf456", "subnet-qeiru789"]

 # Self Managed Node Group(s)
 self_managed_node_group_defaults = {
   instance_type                          = "m6i.large"
   update_launch_template_default_version = true
   iam_role_additional_policies = {
     AmazonSSMManagedInstanceCore = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
   }
 }

 self_managed_node_groups = {
   one = {
     name         = "mixed-1"
     max_size     = 5
     desired_size = 2

     use_mixed_instances_policy = true
     mixed_instances_policy = {
       instances_distribution = {
         on_demand_base_capacity                  = 0
         on_demand_percentage_above_base_capacity = 10
         spot_allocation_strategy                 = "capacity-optimized"
       }

       override = [
         {
           instance_type     = "m5.large"
           weighted_capacity = "1"
         },
         {
           instance_type     = "m6i.large"
           weighted_capacity = "2"
         },
       ]
     }
   }
 }

 # EKS Managed Node Group(s)
 eks_managed_node_group_defaults = {
   instance_types = ["m6i.large", "m5.large", "m5n.large", "m5zn.large"]
 }

 eks_managed_node_groups = {
   blue = {}
   green = {
     min_size     = 1
     max_size     = 10
     desired_size = 1

     instance_types = ["t3.large"]
     capacity_type  = "SPOT"
   }
 }

 # Fargate Profile(s)
 fargate_profiles = {
   default = {
     name = "default"
     selectors = [
       {
         namespace = "default"
       }
     ]
   }
 }

 # aws-auth configmap
 manage_aws_auth_configmap = true

 aws_auth_roles = [
   {
     rolearn  = "arn:aws:iam::66666666666:role/role1"
     username = "role1"
     groups   = ["system:masters"]
   },
 ]

 aws_auth_users = [
   {
     userarn  = "arn:aws:iam::66666666666:user/user1"
     username = "user1"
     groups   = ["system:masters"]
   },
   {
     userarn  = "arn:aws:iam::66666666666:user/user2"
     username = "user2"
     groups   = ["system:masters"]
   },
 ]
 aws_auth_accounts = [
   "777777777777",
   "888888888888",
 ]
 tags = {
   Environment = "dev"
   Terraform   = "true"
 }
}

Related[edit]

tf show | grep vpc_ip
tf show | grep subnet_id

See also[edit]

Advertising: