In case anyone should read this article and get the wrong idea here is my disclaimer for 2021 and beyond…
This post was written in 2019. I had a specific use case where something like CodePipeline was not necessarily required. In the original post from 2019, the summary actually explains that there are different ways to deploy to EB. One reason I tried this way was that in 2019 I was looking at different methods where I was able to use GitHub as the repo instead of AWS CodeCommit. I’d like to be absolutely clear that I would probably not choose to deploy this way in 2021.
I’m choosing to leave this post here, as opposed to deleting it. I have not written a similar post on deploying with CodePipeline, but I have set up and used a more standard CodePipeline setup more than I have used this method. I am also constantly assessing how I deploy and if better methods are available. There are many much better methods which I may well post about in the future, but have not done so yet.
2021, October 11th
Here’s what you do to set up an AWS Elastic Beanstalk instance and update it through GIT. So, you’ll need the correct access on your AWS account and here we’re going to use Elastic Beanstalk (EB), RDS, IAM, EB CLI, Github and GIT.
This setup is for an Ubuntu machine. Most of this comes from this url…
zip ../laravel-default.zip -r * .[^.]* -x "vendor/*"
At this point, you should have a working version of Laravel on your EB that you have uploaded manually and that isn’t connected to a database.
Your AWS EB instance should now be able to chat with the database freely but you’re still updating with the zip files.
Most of this comes from this url and this url…
python3 --version
. If it isn’t you’ll have to follow something like this url. NB: python and python3 are different, make sure to follow the advice from the url but use python3 instead of python.eb init
from your project directory to set up your GIT repo with EB. You’ll need to get an ID/secret from a user in IAM. Once you have created/clicked on the user you would go to “Security credentials” and create an access key. You’ll have to remember this info as you won’t be able to access the secret more than once.eb deploy --staged
Believe it or not, that should have deployed to your instance. Huzzah!!
If the Ubuntu machine you are developing on is a new build or has not been used recently for development you’ll need to update and upgrade. When installing Laravel you’ll need to install all the PHP modules it needs (in my case it was “mbstring” and “dom”), you’ll also need to make sure “mysql-server” is installed locally.
This process is not too bad at all. There are different ways to update an EB instance, e.g. using AWS CodePipeline, but if you prefer Github over AWS’s CodeCommit this method is very straightforward to setup. Using this method on a Production website as I’ve described it here would mean testing locally then only deploying once the work was tested locally. You could also set up a dev server and deploy there first for further testing before deploying to the live website.
Quick Links
Legal Stuff