Hello!
I’m working on a project which soon is ready for production. I’ve been reading a lot and realized that the Amazon AWS ecosystem seems really great for hosting your application.
What I find interesting is the fact that you can scale your app when needed, firing up more EC2 instances. The database is moved to a separate RDS instance with failover and possibility scale when needed. S3/Cloudfront is great for serving your static assets, ensuring load time is reduced for your visitors.
This is all good stuff. But what I came to think of when I was about to start deploying my project is that I can’t wrap my head around how to get Trellis/Bedrock play nice with this setup.
The idea is that the app is entirely stateless, like I said, DB is on RDS, files are on S3. So with every instance you fire up, they connect to these sources to serve up your app. But this also means that whenever an instance fails and dies, it gets replaced with a new one, and this new instance needs to be provisioned. It’s here I’m a bit stumped.
This is how I’m thinking provisioning could work:
- Instance fails and gets removed by AWS.
- New instance is fired up.
- Start up script installs ansible
- Script pulls production branch from github
- ?
Yeah, at step 5 I’m stumped.
Do I setup additional env that allows me to run the remote script as local?
Also bit curious what happens during a deploy, let’s say that I have 4 instances up and running at the moment the deploy script runs. Can’t figure out how it’s deployed to all instances. Imagine I need to look at something heavily customized.
Anyone that’s attempted to set this up and could share some thoughts?
Edit: After some digging around it seems like creating an ami file to be distributed to your instances is one way to go. Any other solution that requires less build time?