-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathec2-instance-launch.sh
executable file
·23 lines (17 loc) · 1.11 KB
/
ec2-instance-launch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
######################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# SPDX-License-Identifier: Apache-2.0 #
######################################################################
source ./ec2.conf
echo ""
if [ "$EC2_INSTANCE_NAME" == "" ]; then
echo "Please configure all settings in the EC2 Instance Configuration section of ./ec2.conf"
echo "Then run $0 again to launch the instance"
else
echo "Launching instance $EC2_INSTANCE_NAME ..."
CMD="aws ec2 run-instances --image-id $EC2_IMAGE_ID --block-device-mappings \"DeviceName=/dev/xvda,Ebs={DeleteOnTermination=true,VolumeSize=$EC2_VOLUME_SIZE_GB,VolumeType=gp3,Encrypted=true}\" --instance-type $EC2_INSTANCE_TYPE --iam-instance-profile \"Name=$EC2_INSTANCE_PROFILE_NAME\" --network-interfaces \"AssociatePublicIpAddress=$EC2_ASSIGN_PUBLIC_IP,DeviceIndex=0,Groups=$EC2_SG_ID,SubnetId=$EC2_SUBNET_ID\" --tag-specifications \"ResourceType=instance,Tags=[{Key=Name,Value=$EC2_INSTANCE_NAME}]\" --key-name $EC2_KEY_NAME"
echo "$CMD"
eval "$CMD"
fi
echo ""