-
Notifications
You must be signed in to change notification settings - Fork 2
/
ec2_setup.sh
34 lines (24 loc) · 1.18 KB
/
ec2_setup.sh
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
#!/bin/bash
aws configure set default.region us-west-2
aws ec2 create-security-group --group-name mxnetworkshop-sg --description "Security Group for the MXNet workshop"
aws ec2 authorize-security-group-ingress --group-name mxnetworkshop-sg --protocol tcp --port 22 --cidr 0.0.0.0/0
aws ec2 authorize-security-group-ingress --group-name mxnetworkshop-sg --protocol tcp --port 8888 --cidr 0.0.0.0/0
aws ec2 create-key-pair --key-name mxnetworkshop --query 'KeyMaterial' --output text > mxnetworkshop.pem
chmod 400 mxnetworkshop.pem
# Deep Learning AMI, Ubuntu edition
# https://aws.amazon.com/marketplace/pp/B06VSPXKDX
# This is the AMI for us-west-2
AMI=ami-f1d51489
TYPE=c4.xlarge
#TYPE=p2.xlarge
# Create a new instance using the Deep Learning AMI
aws ec2 run-instances \
--key-name mxnetworkshop \
--security-group-ids mxnetworkshop-sg \
--instance-type $TYPE \
--image-id $AMI \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=mxnetworkshop}]'
sleep 20
# Get public DNS name for the newly created instance
DNS=`aws ec2 describe-instances --filters Name=tag:Name,Values=mxnetworkshop --query 'Reservations[*].Instances[*].PublicDnsName' --output text`
echo "\n\n" $DNS "\n\n"