-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate-instance-1804.sh
More file actions
33 lines (30 loc) · 1.29 KB
/
create-instance-1804.sh
File metadata and controls
33 lines (30 loc) · 1.29 KB
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
instance_response=$(aws ec2 run-instances \
--image-id ami-0edf3b95e26a682df \
--count 1 \
--instance-type t3.micro \
--key-name Key-only-for-use-with-CloudGenius-workstation \
--security-groups SG-only-for-use-with-CloudGenius-workstation \
--user-data file://provision.txt \
--block-device-mappings 'DeviceName=/dev/xvdf,Ebs={VolumeSize=20,VolumeType=gp2,DeleteOnTermination=false,Encrypted=true}' \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value="Cloud Genius Workstation"}]' 'ResourceType=volume,Tags=[{Key=Name,Value="Disk for Cloud Genius"}]')
sleep 120
instanceId=$(echo -e "$instance_response" | jq -r '.Instances[] | .InstanceId' | tr -d '"')
PublicIpAddress=$(aws ec2 describe-instances \
--instance-id $instanceId | jq -r '.Reservations[] | .Instances[] | .PublicIpAddress' | tr -d '"')
rm -rf config
cat <<EOF >config
# Created on $(date)
Host CloudGenius
HostName $PublicIpAddress
ForwardAgent yes
User ubuntu
StrictHostKeyChecking no
IdentityFile ~/.ssh/CloudGenius
LocalForward 8080 127.0.0.1:80
LocalForward 4000 127.0.0.1:4000
EOF
mv -f config ~/.ssh/config
# rm -rf provision.txt
ssh -o "StrictHostKeyChecking no" CloudGenius "curl -s https://s3-us-west-2.amazonaws.com/cloudgeniuscode/mountdisk.sh | bash"
cat ~/.ssh/config
code