-
Notifications
You must be signed in to change notification settings - Fork 13
/
wordpress_ha.aws
19 lines (16 loc) · 1.34 KB
/
wordpress_ha.aws
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Title: Highly-available wordpress behind a loadbalancer, with a RDS database
# Tags: infra, rds, autoscaling
# MinimalVersion: v0.1.1
dbname={dbname}
dbhost={dbhost}
dbuser={dbuser}
dbpassword={dbpassword}
# Create the load balancer with its security group, target group and listener
lbsecgroup = create securitygroup vpc={wordpress.vpc} description="authorize HTTP from the Internet" name=wordpress-lb-securitygroup
update securitygroup id=$lbsecgroup inbound=authorize protocol=tcp cidr=0.0.0.0/0 portrange=80
tg = create targetgroup name=wordpress-workers port=80 protocol=HTTP vpc={wordpress.vpc}
lb = create loadbalancer name=wordpress-loadbalancer subnets={wordpress.subnets} securitygroups=$lbsecgroup
create listener actiontype=forward loadbalancer=$lb port=80 protocol=HTTP targetgroup=$tg
# Create the launch configuration for the instances and start it in a scaling group, to ensure having always 2 instances running
launchconf = create launchconfiguration image={instance.image} keypair={wordpress.keypair} name=wordpress-launch-configuration type=t2.micro userdata=https://raw.githubusercontent.com/wallix/awless-templates/master/userdata/wordpress.sh securitygroups={instances.securitygroup}
create scalinggroup desired-capacity=2 launchconfiguration=$launchconf max-size=2 min-size=2 name=wordpress-scalinggroup subnets={wordpress.subnets} targetgroups=$tg