-
Notifications
You must be signed in to change notification settings - Fork 9
/
ManagementInstance.json
168 lines (159 loc) · 6.23 KB
/
ManagementInstance.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "(SO9259) - ML inference on EKS with Graviton and Inferentia2 architecures",
"Mappings": {
"AWSRegion2AMI": {
"us-east-1": {
"ami": "ami-03f6c2c562b3df715"
},
"us-east-2": {
"ami": "ami-0485ca4b2b7cb275d"
},
"us-west-1": {
"ami": "ami-06800a9f539283f43"
},
"us-west-2": {
"ami": "ami-093e5f43b11508e3e"
}
}
},
"Resources": {
"ManagementInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": {
"Fn::FindInMap": ["AWSRegion2AMI", {
"Ref": "AWS::Region"
}, "ami"]
},
"InstanceType": "c7g.4xlarge",
"IamInstanceProfile": {
"Ref": "RootInstanceProfile"
},
"SecurityGroups": [{
"Ref": "ManagementInstanceSecurityGroup"
}],
"UserData": {
"Fn::Base64": {
"Fn::Join": ["", [
"#!/bin/bash \n",
"echo 'Executing userdata script ...' | sudo tee -a /tmp/bootstrap.log \n",
"#sudo chmod 666 /tmp/bootstrap.log; sudo chown ec2-user:ec2-user /tmp/bootstrap.log \n",
"date | sudo tee -a /tmp/bootstrap.log \n",
"sudo yum update | sudo tee -a /tmp/bootstrap.log \n",
"sudo yum install -y aws-cfn-bootstrap git | sudo tee -a /tmp/bootstrap.log \n",
"sudo su ec2-user bash -c 'cd /home/ec2-user; git clone https://github.com/aws-samples/aws-do-eks.git | sudo tee -a /tmp/bootstrap.log' \n",
"sudo su ec2-user bash -c 'cd /home/ec2-user; git clone https://github.com/aws-solutions-library-samples/guidance-for-machine-learning-inference-on-aws.git | sudo tee -a /tmp/bootstrap.log' \n",
"sudo bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/ops/setup/install-aws-cli.sh | sudo tee -a /tmp/bootstrap.log' \n",
"sudo bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/ops/setup/install-eksctl.sh | sudo tee -a /tmp/bootstrap.log' \n",
"sudo bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/ops/setup/install-kubectl.sh | sudo tee -a /tmp/bootstrap.log' \n",
"sudo bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/ops/setup/install-kubectx.sh | sudo tee -a /tmp/bootstrap.log' \n",
"sudo bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/ops/setup/install-kubeps1.sh | sudo tee -a /tmp/bootstrap.log' \n",
"sudo bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/ops/setup/install-docker-yum.sh | sudo tee -a /tmp/bootstrap.log' \n",
"sudo bash -c 'ln -s /usr/bin/python3 /usr/bin/python | sudo tee -a /tmp/bootstrap.log' \n",
"#bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/ops/setup/install-python2.sh | sudo tee -a /tmp/bootstrap.log' \n",
"#sudo su ec2-user bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/ops/setup/install-cloud9.sh | sudo tee -a /tmp/bootstrap.log' \n",
"sudo su ec2-user bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/ops/setup/install-envsubst.sh | sudo tee -a /tmp/bootstrap.log' \n",
"sudo su ec2-user bash -c 'source /home/ec2-user/aws-do-eks/wd/cfn/inference-workshop/.env; cat /home/ec2-user/aws-do-eks/wd/conf/eksctl/yaml/eks-inference-workshop.yaml-template | envsubst | sudo tee /home/ec2-user/aws-do-eks/wd/conf/eksctl/yaml/eks-inference-workshop.yaml' \n",
"sudo su ec2-user bash -c 'cat /home/ec2-user/aws-do-eks/wd/conf/eksctl/yaml/eks-inference-workshop.yaml | sudo tee -a /tmp/bootstrap.log' \n",
"sudo su ec2-user bash -c 'echo Creating EKS cluster ... | sudo tee -a /tmp/bootstrap.log' \n",
"sudo su ec2-user bash -c '/usr/local/bin/eksctl create cluster -f /home/ec2-user/aws-do-eks/wd/conf/eksctl/yaml/eks-inference-workshop.yaml | sudo tee -a /tmp/bootstrap.log' \n",
"sudo su ec2-user bash -c 'source /home/ec2-user/.bashrc; sleep 2; aws eks update-kubeconfig --name eks-inference-workshop | sudo tee -a /tmp/bootstrap.log' \n",
"sudo su ec2-user bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/deployment/neuron-device-driver/labels-add.sh | sudo tee -a /tmp/bootstrap.log' \n",
"sudo su ec2-user bash -c 'kubectl apply -f /home/ec2-user/aws-do-eks/Container-Root/eks/deployment/neuron-device-driver/neuron2-device-driver-daemonset.yaml | sudo tee -a /tmp/bootstrap.log' \n",
"sudo su ec2-user bash -c '/home/ec2-user/aws-do-eks/Container-Root/eks/deployment/neuron-device-plugin/deploy.sh | sudo tee -a /tmp/bootstrap.log' \n",
"date | sudo tee -a /tmp/bootstrap.log \n",
"echo 'Done executing userdata script.' | sudo tee -a /tmp/bootstrap.log \n"
]]
}
}
},
"CreationPolicy": {}
},
"RootRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {
"Service": ["ec2.amazonaws.com"]
},
"Action": ["sts:AssumeRole"]
}]
},
"Path": "/"
}
},
"RolePolicies": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": "root",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}]
},
"Roles": [{
"Ref": "RootRole"
}]
}
},
"RootInstanceProfile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [{
"Ref": "RootRole"
}]
}
},
"ManagementInstanceSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable access to Management Instance",
"SecurityGroupIngress": [{
"IpProtocol": "tcp",
"FromPort": "443",
"ToPort": "443",
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": "0.0.0.0/0"
}
]
}
}
},
"Outputs": {
"ManagementInstanceDNSName": {
"Description": "Management Instance",
"Value": {
"Fn::Join": ["", ["", {
"Fn::GetAtt": ["ManagementInstance", "PublicDnsName"]
}]]
}
},
"ManagementInstanceSMLogin": {
"Description": "Session Manager Login",
"Value": {
"Fn::Join": ["", [
"https://",
{ "Ref": "AWS::Region" },
".console.aws.amazon.com/systems-manager/session-manager/",
{ "Ref": "ManagementInstance" },
"?region=",
{"Ref": "AWS::Region"}
]
]
}
}
}
}