Last active
October 14, 2017 10:12
-
-
Save sandeepkunkunuru/91a93ac6c4bc6ba7a62af6d3981fc8ed to your computer and use it in GitHub Desktop.
awless : Create a load balanced web app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -ex | |
AWS_DEFAULT_REGION=xxxx | |
AWS_DEFAULT_PROFILE=xxxx | |
awless config set aws.region ${AWS_DEFAULT_REGION} | |
awless config set aws.profile ${AWS_DEFAULT_PROFILE} | |
SCRIPT_HOME=/home/xxxx/awless | |
DATA_HOME=/home/xxxx/data | |
AZ_1="xxxx" | |
AZ_2="xxxx" | |
function join_by { local IFS="$1"; shift; echo "$*"; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
source ../env.sh | |
keypair="" | |
vpc="" | |
lb_subnets="@subnet_lb,@subnet_lb_2" | |
certificate="" | |
declare -a names=() | |
declare -a vm_subnets=() | |
declare -a images=() | |
## now loop through the above array | |
for i in ${!names[*]}; do | |
echo "Creating load balanced environment for ---> ${names[${i}]} " | |
awless run ${SCRIPT_HOME}/web_components.aws name=${names[${i}]} vpcid=${vpc} vm_subnet=${vm_subnets[${i}]} \ | |
lb_subnets=${lb_subnets} keypair=${keypair} image=${images[${i}]} certificate=${certificate} | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create Target Group | |
tg = create targetgroup name={name}-tg port=443 protocol=HTTPS vpc={vpcid} | |
# Create Load Balancer | |
lb = create loadbalancer name={name}-lb subnets={lb_subnets} iptype=ipv4 scheme=internet-facing | |
# Create Listener to link lb, tg and certificate | |
lstnr = create listener actiontype=forward loadbalancer=$lb port=443 protocol=HTTPS targetgroup=$tg certificate={certificate} sslpolicy=ELBSecurityPolicy-2016-08 | |
# Create an EC2 instance | |
inst = create instance image={image} keypair={keypair} type=m4.large subnet={vm_subnet} name={name} | |
# Wait for the instance | |
check instance id=$inst state=running timeout=180 | |
# Attach instance to target group | |
attach instance id=$inst targetgroup=$tg port=443 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment