Doubleheader is a basic example project that will require minimal modification from the user to connect to their personal Amazon Web Services (AWS) account. This repository contains everything you will need to deploy a sample "Hello World" web page to an Elastic Beanstalk (EB) environment via Git and the EB Command Line Interface (EB CLI), the deployment process will then automatically upload sample website content to an S3 bucket via auto-installation of the s3cmd tool. This project can be expanded upon for your own use to help you serve up an entire website without having to manually upload projects to EB and assets to S3, with the added .
- Install and setup Git. If you're cloning this project from GitHub you should already be good to go.
- Install EB CLI. (Note: you may need to restart your machine after installing for modifications to your machines PATH environment variable to work properly)
- Make a fresh copy of your Doubleheader clone, and be sure to remove any Git files, you will be reinitializing the sample website to work with your EB account.
- Edit the bucket name in the provided .config file to the name of the S3 bucket you wish to upload your sample files to.
- Open up your terminal of choice, for our run we used the Git Bash client for Windows.
cd
into the new copy of the sample website files and callgit init
. This will create new Git information for your local working copy of the repository to be used by EB CLI for the deployment process.- Call
git add .
to add all of the files in the working directory. - Call
git commit -m "first test deploy"
. - Call
eb init
and follow through the steps. This will create an .elasticbeanstalk directory in your local copy of the repository. An in depth list of steps can be found here via Amazon's documentation. You will have to provide your aws-access-id and aws-secret-key for your AWS account in step 2. In step 5, select option2
for PHP (since the sample web page we provide in Doubleheader is PHP based). - Call
eb create
, you will be prompted to provide an environment name and DNS CNAME for the website. An exampleeb create
call can be found here in Amazon's documentation. AWS will now spin up a new EB environment for your website and do an initial deploy. A live events list will scroll by giving you an update on the status of the deployment. If successful, you should be able to log into your AWS account and find a new environment running your index.php file as a webpage. - If successful, you should now also see the sample files uploaded to the bucket name you specified for S3 in step 4. If nothing showed up, be sure to check the log generated in step 11 to see if a command was malformed in the .config file. In some cases, you may need to create a new IAM policy allowing access to S3 buckets and commands to assign to your EB environment in AWS. An example policy (which you may have to modify some to get the proper permissions for your specific buckets and commands) can be found at Will Writes blog article on using s3cmd.
- For any further changes (i.e. as a quick test try changing the message in index.php from
"Hello World"
to something else), add the files you modify and commit via git, then entereb deploy
, this will deploy the newest version of your web site to the same environment you created in step 10. To add more rules and paths of files to upload to S3, modify the .config YAML file. Some more example commands can be found in Michael Gallego's Tutorial on how to use s3cmd w/ EB. If everything worked as expected, congratulations!
josh@mindaptiv.com
chris@mindaptiv.com
Doubleheader is named for the one-two punch of combining deployment to Elastic Beanstalk via Git/EB CLI & S3 synchronization w/ Elastic Beanstalk via s3cmd. We found many tutorials online for how to do each piece separate, but none that used both in tandem. We believe integrating both features into a single automated deployment process can help the user focus more on developing and testing their website in a rapid fashion. Doubleheader is also named for the ~2 week endeavor of guess/check/test/re-test trial-&-error work between two team members to get the process streamlined and working for a production website, and shows (just like the 1989 Transformers Pretender character), two heads can be better than one.