-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch_tsung.sh
More file actions
executable file
·31 lines (24 loc) · 936 Bytes
/
launch_tsung.sh
File metadata and controls
executable file
·31 lines (24 loc) · 936 Bytes
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
#!/bin/sh -e
TEAMNAME=$(whoami)
TSUNG_AMI=ami-0983761f3d0032a72
if [ $# -eq 0 ]; then
instance_type=t3.micro
elif [ $# -eq 1 ]; then
instance_type=$1
else
echo "Usage $0 [INSTANCE_TYPE]"
exit 1
fi
result=$(aws ec2 run-instances \
--image-id=$TSUNG_AMI \
--instance-type=$instance_type \
--key-name=$TEAMNAME \
--monitoring=Enabled=True \
--security-groups='["tsung"]' \
--tag-specifications='[{"ResourceType":"instance","Tags":[{"Key":"Name","Value":"tsung-'$TEAMNAME'"}]},{"ResourceType":"volume","Tags":[{"Key":"Name","Value":"tsung-'$TEAMNAME'"}]}]')
id=$(echo $result | jq -r '.Instances[].InstanceId')
echo "Instance $id is launching. Obtaining IP address..."
sleep 1
public_ip=$(aws ec2 describe-instances --filters Name=instance-id,Values=$id | jq -r .Reservations[].Instances[].PublicIpAddress)
echo -e "SSH\n---\nssh ec2-user@$public_ip\n"
echo -e "HTTP\n----\nhttp://$public_ip"