@@ -5,36 +5,11 @@ data "aws_availability_zones" "available" {}
55
66locals {
77 cluster_name = " cluster-${ var . suffix } "
8-
9- worker_groups = [
10- {
11- instance_type = " t2.large"
12- subnets = " ${ join (" ," , module. vpc . private_subnets )} "
13- asg_desired_capacity = " 2"
14- },
15- ]
16- tags = {
17- Workspace = " ${ terraform . workspace } "
18- }
19- worker_groups_launch_template = [
20- {
21- # This will launch an autoscaling group with only Spot Fleet instances
22- instance_type = " t2.small"
23- additional_userdata = " echo foo bar"
24- subnets = " ${ join (" ," , module. vpc . private_subnets )} "
25- additional_security_group_ids = " ${ aws_security_group . worker_group_mgmt_one . id } ,${ aws_security_group . worker_group_mgmt_two . id } "
26- override_instance_type = " t3.small"
27- asg_desired_capacity = " 2"
28- spot_instance_pools = 10
29- on_demand_percentage_above_base_capacity = " 0"
30- },
31- ]
328}
339
3410resource "aws_security_group" "worker_group_mgmt_one" {
3511 name_prefix = " worker_group_mgmt_one"
36- description = " SG to be applied to all *nix machines"
37- vpc_id = " ${ module . vpc . vpc_id } "
12+ vpc_id = module. vpc . vpc_id
3813
3914 ingress {
4015 from_port = 22
@@ -49,7 +24,7 @@ resource "aws_security_group" "worker_group_mgmt_one" {
4924
5025resource "aws_security_group" "worker_group_mgmt_two" {
5126 name_prefix = " worker_group_mgmt_two"
52- vpc_id = " ${ module . vpc . vpc_id } "
27+ vpc_id = module. vpc . vpc_id
5328
5429 ingress {
5530 from_port = 22
@@ -64,7 +39,7 @@ resource "aws_security_group" "worker_group_mgmt_two" {
6439
6540resource "aws_security_group" "all_worker_mgmt" {
6641 name_prefix = " all_worker_management"
67- vpc_id = " ${ module . vpc . vpc_id } "
42+ vpc_id = module. vpc . vpc_id
6843
6944 ingress {
7045 from_port = 22
@@ -80,28 +55,63 @@ resource "aws_security_group" "all_worker_mgmt" {
8055}
8156
8257module "vpc" {
83- source = " terraform-aws-modules/vpc/aws"
84- version = " 1.60.0"
85- name = " test-vpc"
86- cidr = " 10.0.0.0/16"
87- azs = [" ${ data . aws_availability_zones . available . names [0 ]} " , " ${ data . aws_availability_zones . available . names [1 ]} " , " ${ data . aws_availability_zones . available . names [2 ]} " ]
88- private_subnets = [" 10.0.1.0/24" , " 10.0.2.0/24" , " 10.0.3.0/24" ]
89- public_subnets = [" 10.0.4.0/24" , " 10.0.5.0/24" , " 10.0.6.0/24" ]
90- enable_nat_gateway = true
91- single_nat_gateway = true
92- tags = " ${ merge (local. tags , map (" kubernetes.io/cluster/${ local . cluster_name } " , " shared" ))} "
58+ source = " terraform-aws-modules/vpc/aws"
59+ version = " 2.6.0"
60+
61+ name = " test-vpc"
62+ cidr = " 10.0.0.0/16"
63+ azs = " ${ data . aws_availability_zones . available . names } "
64+ private_subnets = [" 10.0.1.0/24" , " 10.0.2.0/24" , " 10.0.3.0/24" ]
65+ public_subnets = [" 10.0.4.0/24" , " 10.0.5.0/24" , " 10.0.6.0/24" ]
66+ enable_nat_gateway = true
67+ single_nat_gateway = true
68+ enable_dns_hostnames = true
69+
70+ tags = {
71+ " kubernetes.io/cluster/${local.cluster_name}" = " shared"
72+ }
73+
74+ public_subnet_tags = {
75+ " kubernetes.io/cluster/${local.cluster_name}" = " shared"
76+ " kubernetes.io/role/elb" = " 1"
77+ }
78+
79+ private_subnet_tags = {
80+ " kubernetes.io/cluster/${local.cluster_name}" = " shared"
81+ " kubernetes.io/role/internal-elb" = " 1"
82+ }
9383}
9484
9585module "eks" {
96- source = " terraform-aws-modules/eks/aws"
97- cluster_name = " ${ local . cluster_name } "
98- cluster_version = " ${ var . cluster_version } "
99- subnets = [" ${ module . vpc . private_subnets } " ]
100- tags = " ${ local . tags } "
101- vpc_id = " ${ module . vpc . vpc_id } "
102- worker_groups = " ${ local . worker_groups } "
103- worker_groups_launch_template = " ${ local . worker_groups_launch_template } "
104- worker_group_count = " 1"
105- worker_group_launch_template_count = " 1"
86+ # source = "terraform-aws-modules/eks/aws"
87+ source = " git@github.com:terraform-aws-modules/terraform-aws-eks.git?ref=6c3e4ec510f658f53508623a6192df064e7a4786"
88+ cluster_name = " ${ local . cluster_name } "
89+ subnets = " ${ module . vpc . private_subnets } "
90+
91+ tags = {
92+ Environment = " test"
93+ GithubRepo = " terraform-aws-eks"
94+ GithubOrg = " terraform-aws-modules"
95+ }
96+
97+ vpc_id = " ${ module . vpc . vpc_id } "
98+
99+ worker_groups = [
100+ {
101+ name = " worker-group-1"
102+ instance_type = " t2.small"
103+ additional_userdata = " echo foo bar"
104+ asg_desired_capacity = 2
105+ additional_security_group_ids = [" ${ aws_security_group . worker_group_mgmt_one . id } " ]
106+ },
107+ {
108+ name = " worker-group-2"
109+ instance_type = " t2.medium"
110+ additional_userdata = " echo foo bar"
111+ additional_security_group_ids = [" ${ aws_security_group . worker_group_mgmt_two . id } " ]
112+ asg_desired_capacity = 1
113+ },
114+ ]
115+
106116 worker_additional_security_group_ids = [" ${ aws_security_group . all_worker_mgmt . id } " ]
107117}
0 commit comments