-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-aws-machine.sh
executable file
·57 lines (48 loc) · 1.52 KB
/
create-aws-machine.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
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
#!/usr/bin/env sh
# More information here https://docs.docker.com/machine/drivers/aws/
usage() {
echo "Usage: $(basename "$0") [NAME] [TYPE] [AMI]"
echo
echo "NAME The name to give to the instance"
echo "AMI The AMI image to clone"
echo "TYPE The type of instance: t3.micro, t3.small, t3.medium, t3.large"
}
if [ $# -eq 0 ]; then
usage
exit 1
fi
MACHINE_NAME=$1
if [ "$1" == "" ]; then
echo "You need to provide a name for the machine (no space, keep simple)"
exit 1
fi
AWS_INSTANCE_TYPE=${AWS_INSTANCE_TYPE:-t2.small}
if [ "$2" != "" ]; then
AWS_INSTANCE_TYPE="$2"
fi
MACHINE_IMAGE=${MACHINE_IMAGE:-ami-05a7435a08406e458}
if [ "$3" != "" ]; then
MACHINE_IMAGE="$3"
fi
AWS_SSH_USER=${AWS_SSH_USER:-ec2-user}
if [ "$4" != "" ]; then
AWS_SSH_USER="$4"
fi
AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-ap-northeast-2}
echo "----------------------------------------------"
echo "Creating instance with the following settings:"
echo "- Machine Name: $MACHINE_NAME"
echo "- Region: $AWS_DEFAULT_REGION"
echo "- Machine Type: $AWS_INSTANCE_TYPE"
echo "- Image: $MACHINE_IMAGE"
echo "----------------------------------------------"
docker-machine create \
--driver amazonec2 \
--amazonec2-region ${AWS_DEFAULT_REGION} \
--amazonec2-access-key ${AWS_ACCESS_KEY_ID} \
--amazonec2-secret-key ${AWS_SECRET_ACCESS_KEY} \
--amazonec2-ami "${MACHINE_IMAGE}" \
--amazonec2-instance-type ${AWS_INSTANCE_TYPE} \
--amazonec2-ssh-user ${AWS_SSH_USER} \
--amazonec2-root-size 50 \
${MACHINE_NAME}