In the previous step we deployed our Rails application from the command line to Elastic Beanstalk. In this step we setup CircleCI to deploy our application directly out to Elastic Beanstalk when code is pushed to GitHub.
You will need to create a GitHub account and new repository for our application. Once you have done this add the GitHub remote to our local git and make our first push from develop:
CircleCI is able to infer most of our build settings from our type of project and will automatically detect that we are running Rails and will run our tests for us. However we need to tell it how to deploy our application on a successful build. We do this by creating a circle.yml file.
In this file we need to tell CircleCI to install the AWS EB CLI tools. This is done using the following section:
dependencies:pre:-pip install awsebcli
We then need to tell CircleCI how to deploy our application. For develop deployments we use the following commands - make sure you use “–profile default” as this is how CircleCI exposes your AWS credentials.
deployment:develop:branch:developcommands:-eb use Dev-env --profile default-eb deploy --profile default
The above commands tell the eb command to start using the Dev-env and then tells it to deploy the application.
For our production deployment we need the following commands:
production:branch:mastercommands:-eb use Prod-env --profile default-eb deploy --profile default
This tells eb to use the Prod-env and then deploy the application.
Both these sets of commands refer to values that are configures in our .elasticbeanstalk/config.yml file.
Our final circle.yml file will look like:
dependencies:pre:-pip install awsebclideployment:develop:branch:developcommands:-eb use Dev-env --profile default-eb deploy --profile defaultproduction:branch:mastercommands:-eb use prod-env-demo-app --profile default-eb deploy --profile default
The final step for CircleCI is to tell it what credentials to use for AWS. You can create a new user for this as we did in the previous step or re-use the credentials you have already created. For extra control and security you may want to create a specific CircleCI IAM user.
Once you have finished your setup you can push a change to the develop branch and watch CircleCI pick up your change and deploy it straight out to your dev environment. If that works then checkout the master branch and make a change. CircleCI should see the change and deploy out to your production environment.
In the next step we’ll configure a custom domain name and setup SSL for our Elastic Beanstalk application.
A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff.
Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...