Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 230e67f

Browse files
committedJul 22, 2023
updated eks-terra
1 parent 1fa3cee commit 230e67f

File tree

4 files changed

+212
-167
lines changed

4 files changed

+212
-167
lines changed
 

‎aws-devops/aws-eks/terra-eks/app-deploy.yaml

-42
This file was deleted.

‎aws-devops/aws-eks/terra-eks/eks.tf

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#==============================================================
2+
3+
resource "aws_iam_role" "eks_cluster-terra" {
4+
name = "eks-cluster-terra"
5+
assume_role_policy = <<POLICY
6+
{
7+
"Version": "2012-10-17",
8+
"Statement": [
9+
{
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "eks.amazonaws.com"
13+
},
14+
"Action": "sts:AssumeRole"
15+
}
16+
]
17+
}
18+
POLICY
19+
}
20+
21+
resource "aws_iam_role_policy_attachment" "AmazonEKSClusterPolicy" {
22+
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
23+
role = aws_iam_role.eks_cluster-terra.name
24+
}
25+
26+
27+
resource "aws_iam_role_policy_attachment" "AmazonEKSServicePolicy" {
28+
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
29+
role = aws_iam_role.eks_cluster-terra.name
30+
}
31+
32+
resource "aws_eks_cluster" "aws_eks" {
33+
name = "eks-cluster-terra"
34+
role_arn = aws_iam_role.eks_cluster-terra.arn
35+
36+
vpc_config {
37+
subnet_ids = ["${aws_subnet.private_subnets[0].id}", "${aws_subnet.private_subnets[1].id}", "${aws_subnet.public_subnets[0].id}", "${aws_subnet.public_subnets[1].id}"]
38+
endpoint_private_access = true
39+
endpoint_public_access = true
40+
public_access_cidrs = ["0.0.0.0/0"]
41+
}
42+
43+
tags = {
44+
Name = "eks-terra"
45+
Owner = "Ranjeet Jadhav"
46+
}
47+
}
48+
49+
resource "aws_iam_role" "eks-node-grp-terra" {
50+
name = "eks-nodegrp-terra"
51+
assume_role_policy = <<POLICY
52+
{
53+
"Version": "2012-10-17",
54+
"Statement": [
55+
{
56+
"Effect": "Allow",
57+
"Principal": {
58+
"Service": "ec2.amazonaws.com"
59+
},
60+
"Action": "sts:AssumeRole"
61+
}
62+
]
63+
}
64+
POLICY
65+
}
66+
67+
resource "aws_iam_role_policy_attachment" "AmazonEKSWorkerNodePolicy" {
68+
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
69+
role = aws_iam_role.eks-node-grp-terra.name
70+
}
71+
72+
resource "aws_iam_role_policy_attachment" "AmazonEKS_CNI_Policy" {
73+
policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
74+
role = aws_iam_role.eks-node-grp-terra.name
75+
}
76+
77+
resource "aws_iam_role_policy_attachment" "AmazonEC2ContainerRegistryReadOnly" {
78+
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
79+
role = aws_iam_role.eks-node-grp-terra.name
80+
}
81+
82+
83+
resource "aws_eks_node_group" "node" {
84+
cluster_name = aws_eks_cluster.aws_eks.name
85+
node_group_name = "eks-node-group-terra"
86+
node_role_arn = aws_iam_role.eks-node-grp-terra.arn
87+
instance_types = ["t2.medium"]
88+
subnet_ids = ["${aws_subnet.private_subnets[0].id}", "${aws_subnet.private_subnets[1].id}"]
89+
ami_type = "AL2_x86_64" # AL2_x86_64, AL2_x86_64_GPU, AL2_ARM_64, CUSTOM
90+
capacity_type = "ON_DEMAND" # ON_DEMAND, SPOT
91+
disk_size = 20
92+
93+
scaling_config {
94+
desired_size = 1
95+
max_size = 1
96+
min_size = 1
97+
}
98+
99+
# Ensure that IAM Role permissions are created before and deleted after EKS Node Group handling.
100+
# Otherwise, EKS will not be able to properly delete EC2 Instances and Elastic Network Interfaces.
101+
depends_on = [
102+
aws_iam_role_policy_attachment.AmazonEKSWorkerNodePolicy,
103+
aws_iam_role_policy_attachment.AmazonEKS_CNI_Policy,
104+
aws_iam_role_policy_attachment.AmazonEC2ContainerRegistryReadOnly,
105+
]
106+
}

‎aws-devops/aws-eks/terra-eks/ingress.yaml

-19
This file was deleted.

‎aws-devops/aws-eks/terra-eks/main.tf

+106-106
Original file line numberDiff line numberDiff line change
@@ -94,109 +94,109 @@ resource "aws_route_table_association" "private_routes" {
9494
subnet_id = aws_subnet.private_subnets[count.index].id
9595
}
9696

97-
#==============================================================
98-
99-
resource "aws_iam_role" "eks_cluster-terra" {
100-
name = "eks-cluster-terra"
101-
assume_role_policy = <<POLICY
102-
{
103-
"Version": "2012-10-17",
104-
"Statement": [
105-
{
106-
"Effect": "Allow",
107-
"Principal": {
108-
"Service": "eks.amazonaws.com"
109-
},
110-
"Action": "sts:AssumeRole"
111-
}
112-
]
113-
}
114-
POLICY
115-
}
116-
117-
resource "aws_iam_role_policy_attachment" "AmazonEKSClusterPolicy" {
118-
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
119-
role = aws_iam_role.eks_cluster-terra.name
120-
}
121-
122-
123-
resource "aws_iam_role_policy_attachment" "AmazonEKSServicePolicy" {
124-
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
125-
role = aws_iam_role.eks_cluster-terra.name
126-
}
127-
128-
resource "aws_eks_cluster" "aws_eks" {
129-
name = "eks-cluster-terra"
130-
role_arn = aws_iam_role.eks_cluster-terra.arn
131-
132-
vpc_config {
133-
subnet_ids = ["${aws_subnet.private_subnets[0].id}", "${aws_subnet.private_subnets[1].id}", "${aws_subnet.public_subnets[0].id}", "${aws_subnet.public_subnets[1].id}"]
134-
endpoint_private_access = true
135-
endpoint_public_access = true
136-
public_access_cidrs = ["0.0.0.0/0"]
137-
}
138-
139-
tags = {
140-
Name = "eks-terra"
141-
Owner = "Ranjeet Jadhav"
142-
}
143-
}
144-
145-
resource "aws_iam_role" "eks-node-grp-terra" {
146-
name = "eks-nodegrp-terra"
147-
assume_role_policy = <<POLICY
148-
{
149-
"Version": "2012-10-17",
150-
"Statement": [
151-
{
152-
"Effect": "Allow",
153-
"Principal": {
154-
"Service": "ec2.amazonaws.com"
155-
},
156-
"Action": "sts:AssumeRole"
157-
}
158-
]
159-
}
160-
POLICY
161-
}
162-
163-
resource "aws_iam_role_policy_attachment" "AmazonEKSWorkerNodePolicy" {
164-
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
165-
role = aws_iam_role.eks-node-grp-terra.name
166-
}
167-
168-
resource "aws_iam_role_policy_attachment" "AmazonEKS_CNI_Policy" {
169-
policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
170-
role = aws_iam_role.eks-node-grp-terra.name
171-
}
172-
173-
resource "aws_iam_role_policy_attachment" "AmazonEC2ContainerRegistryReadOnly" {
174-
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
175-
role = aws_iam_role.eks-node-grp-terra.name
176-
}
177-
178-
179-
resource "aws_eks_node_group" "node" {
180-
cluster_name = aws_eks_cluster.aws_eks.name
181-
node_group_name = "eks-node-group-terra"
182-
node_role_arn = aws_iam_role.eks-node-grp-terra.arn
183-
instance_types = ["t2.medium"]
184-
subnet_ids = ["${aws_subnet.private_subnets[0].id}", "${aws_subnet.private_subnets[1].id}"]
185-
ami_type = "AL2_x86_64" # AL2_x86_64, AL2_x86_64_GPU, AL2_ARM_64, CUSTOM
186-
capacity_type = "ON_DEMAND" # ON_DEMAND, SPOT
187-
disk_size = 20
188-
189-
scaling_config {
190-
desired_size = 1
191-
max_size = 1
192-
min_size = 1
193-
}
194-
195-
# Ensure that IAM Role permissions are created before and deleted after EKS Node Group handling.
196-
# Otherwise, EKS will not be able to properly delete EC2 Instances and Elastic Network Interfaces.
197-
depends_on = [
198-
aws_iam_role_policy_attachment.AmazonEKSWorkerNodePolicy,
199-
aws_iam_role_policy_attachment.AmazonEKS_CNI_Policy,
200-
aws_iam_role_policy_attachment.AmazonEC2ContainerRegistryReadOnly,
201-
]
202-
}
97+
# #==============================================================
98+
99+
# resource "aws_iam_role" "eks_cluster-terra" {
100+
# name = "eks-cluster-terra"
101+
# assume_role_policy = <<POLICY
102+
# {
103+
# "Version": "2012-10-17",
104+
# "Statement": [
105+
# {
106+
# "Effect": "Allow",
107+
# "Principal": {
108+
# "Service": "eks.amazonaws.com"
109+
# },
110+
# "Action": "sts:AssumeRole"
111+
# }
112+
# ]
113+
# }
114+
# POLICY
115+
# }
116+
117+
# resource "aws_iam_role_policy_attachment" "AmazonEKSClusterPolicy" {
118+
# policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
119+
# role = aws_iam_role.eks_cluster-terra.name
120+
# }
121+
122+
123+
# resource "aws_iam_role_policy_attachment" "AmazonEKSServicePolicy" {
124+
# policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
125+
# role = aws_iam_role.eks_cluster-terra.name
126+
# }
127+
128+
# resource "aws_eks_cluster" "aws_eks" {
129+
# name = "eks-cluster-terra"
130+
# role_arn = aws_iam_role.eks_cluster-terra.arn
131+
132+
# vpc_config {
133+
# subnet_ids = ["${aws_subnet.private_subnets[0].id}", "${aws_subnet.private_subnets[1].id}", "${aws_subnet.public_subnets[0].id}", "${aws_subnet.public_subnets[1].id}"]
134+
# endpoint_private_access = true
135+
# endpoint_public_access = true
136+
# public_access_cidrs = ["0.0.0.0/0"]
137+
# }
138+
139+
# tags = {
140+
# Name = "eks-terra"
141+
# Owner = "Ranjeet Jadhav"
142+
# }
143+
# }
144+
145+
# resource "aws_iam_role" "eks-node-grp-terra" {
146+
# name = "eks-nodegrp-terra"
147+
# assume_role_policy = <<POLICY
148+
# {
149+
# "Version": "2012-10-17",
150+
# "Statement": [
151+
# {
152+
# "Effect": "Allow",
153+
# "Principal": {
154+
# "Service": "ec2.amazonaws.com"
155+
# },
156+
# "Action": "sts:AssumeRole"
157+
# }
158+
# ]
159+
# }
160+
# POLICY
161+
# }
162+
163+
# resource "aws_iam_role_policy_attachment" "AmazonEKSWorkerNodePolicy" {
164+
# policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
165+
# role = aws_iam_role.eks-node-grp-terra.name
166+
# }
167+
168+
# resource "aws_iam_role_policy_attachment" "AmazonEKS_CNI_Policy" {
169+
# policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
170+
# role = aws_iam_role.eks-node-grp-terra.name
171+
# }
172+
173+
# resource "aws_iam_role_policy_attachment" "AmazonEC2ContainerRegistryReadOnly" {
174+
# policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
175+
# role = aws_iam_role.eks-node-grp-terra.name
176+
# }
177+
178+
179+
# resource "aws_eks_node_group" "node" {
180+
# cluster_name = aws_eks_cluster.aws_eks.name
181+
# node_group_name = "eks-node-group-terra"
182+
# node_role_arn = aws_iam_role.eks-node-grp-terra.arn
183+
# instance_types = ["t2.medium"]
184+
# subnet_ids = ["${aws_subnet.private_subnets[0].id}", "${aws_subnet.private_subnets[1].id}"]
185+
# ami_type = "AL2_x86_64" # AL2_x86_64, AL2_x86_64_GPU, AL2_ARM_64, CUSTOM
186+
# capacity_type = "ON_DEMAND" # ON_DEMAND, SPOT
187+
# disk_size = 20
188+
189+
# scaling_config {
190+
# desired_size = 1
191+
# max_size = 1
192+
# min_size = 1
193+
# }
194+
195+
# # Ensure that IAM Role permissions are created before and deleted after EKS Node Group handling.
196+
# # Otherwise, EKS will not be able to properly delete EC2 Instances and Elastic Network Interfaces.
197+
# depends_on = [
198+
# aws_iam_role_policy_attachment.AmazonEKSWorkerNodePolicy,
199+
# aws_iam_role_policy_attachment.AmazonEKS_CNI_Policy,
200+
# aws_iam_role_policy_attachment.AmazonEC2ContainerRegistryReadOnly,
201+
# ]
202+
# }

0 commit comments

Comments
 (0)
Please sign in to comment.