aws-samples / aws-refarch-wordpress

This reference architecture provides best practices and a set of YAML CloudFormation templates for deploying WordPress on AWS.
MIT No Attribution
1.08k stars 601 forks source link

Help with updating wordpress #13

Closed lfreneda closed 6 years ago

lfreneda commented 6 years ago

Hello Folks,

I tried to update an available update from WordPress, but when I did it, my current ec2 instance was terminated and another one was initialized.

Is not possible to update wp? Tips?

darrylsosborne commented 6 years ago

You have two options to make updates to WordPress instances.

WordPress instances are members of an Auto Scaling group (ASG) with health checks managed by an application load balancer. The health check service checks /wp-login.php and if it can't access it within the defined threshold (five 5 second timeouts @ 30 second intervals) then it will automatically launch a replacement instance and terminate the old one. Rebooting the instance or stopping the service for too long will cause health checks to fail and initiate a replacement. (https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html)

Option 1) You can place an instance into a 'Standby' state to make updates. Standby instances are still in the ASG do not actively handle application traffic and healthchecks are suspended. Once the update is finished, change the instance back to 'InService'. http://docs.aws.amazon.com/autoscaling/latest/userguide/as-enter-exit-standby.html

Option 2) Create a new launch configuration that includes your updates and associate it with the ASG. Running instances don't automatically use the new launch config but any new instances launched as a part of the ASG will. So, double the desired size of the ASG and allow these instances to launch and successfully handle application traffic. Then reverse what you just did, halving the desired size of the ASG. The ASG default termination policy will drain connections on the oldest instances and terminate them, leaving only new instances that have your change (and any future instance launched in the ASG). This way you don't have to manually touch and update each existing instance and any new instance after it launches. (http://docs.aws.amazon.com/autoscaling/latest/userguide/change-launch-config.html)

Hope this helps.