Thankfully, it’s not as tricky as it looks but it will take some patience on the first build. The steps would be:
- Create the VPC and security group.
- Create the RDS configuration (start with just one DB, no read replicas, keep it simple). Import your database contents. Point your webserver to the DB and make sure everything can connect.
- Create your EC2 image (i.e. WordPress + Plugins, etc.) from a model EC2 instance. Ensure that you’re using IAM roles to authorize DB access .
- Create a launch configuration (this determines the instance config that autoscaling will use) and then create the autoscaling group.
- Create the S3 bucket to store JS/CSS and other static files. Create a CloudFront distribution fed by this bucket. Update your CMS accordingly (this depends on how the webserver is set up).
- Configure Route53 when this is all tested to point the traffic from the current live site to the new configuration. Make sure you run Amazon Inspector to check for any security issues first.
Here are some resources that might help:
- http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/php-hawordpress-tutorial.html (good tutorial but WordPress specific).
- https://premium.wpmudev.org/blog/host-wordpress-multiple-aws-server-instances/ (WordPress, again)
- https://bitnami.com/stacks/cms (Bitnami provides ready-made stacks for CMS systems — this can provide a good starting point to see how they’re configured).
The key things to remember:
- Separate your state from your instance (e.g. persistent files go to S3, session store goes to DynamoDB, and credentials are either passed into the instance on startup or use IAM).
- When things don’t work, 99% of the time it’s your security group or ACL blocking.
- You’d be surprised how much load one instance with the right cache configuration can take before it scales up. Ensure your autoscaling allows enough time before cooling down to avoid scaling up/down too frequently.
- If you start small, learn how it scales and once it’s working you can develop the CloudFormation script to automate the process in future
I hope this helps!