View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
#AWS #CIRCLECI #CONTINUOUS DEPLOYMENT #ELASTIC BEANSTALK #GITHUB #RAILS

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:

git remote add origin https://github.com/......
git push --set-upstream origin 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: develop
    commands:
      - 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: master
    commands:
      - 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 awsebcli
deployment:
  develop:
    branch: develop
    commands:
      - eb use Dev-env --profile default
      - eb deploy --profile default
  production:
    branch: master
    commands:
      - 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.

#AWS #CIRCLECI #CONTINUOUS DEPLOYMENT #ELASTIC BEANSTALK #GITHUB #RAILS

Related Posts

Step 4: Deploy Rails App To Elastic Beanstalk from Command Line - This post guides you through the essential steps of creating and deploying a Rails application into Elastic Beanstalk environment. Topics include creating an AWS user, configuring AWS CLI for deployment, and setting up the environment variables for your app. Also, it provides you the valuable knowledge of connecting your Rails app to RDS instance and ensuring it successfully connects with the dev database.
Step 1 - Setup VPC: Deploying a Rails Application to Elastic Beanstalk - In this blog post, I am guiding you through the process of deploying a Rails application to Elastic Beanstalk in a Virtual Private Cloud (VPC) on Amazon AWS. I detail the setup of a VPC, subnets, and internet gateways, as well as the configuration of NAT gateways and security groups. Ultimately, this will allow for a safe, internet-accessible environment for your application and its accompanying databases.
Step 8: Set up Active Job on Elastic Beanstalk - This blog post walks through setting up a worker environment on Elastic Beanstalk and using SQS as our Active Job queue, using the active-elastic-job Gem. We start by creating a new queue in our AWS account via Simple Queue Service. Then, we provide our Elastic Beanstalk environments access to the queue and add an AWS_REGION environment variable. We proceed to creating and configuring our worker environment. In our Rails app, we instruct Active Job to use our active-elastic-job queue adapter and create an Active Job. Finally, we deploy our changes to both the web and worker environments, ensuring our ActiveJobs run successfully.
Step 2 - Setup Elastic Beanstalk: Deploying a Rails Application to Elastic Beanstalk - In this post, I describe how to set up, configure and deploy an Elastic Beanstalk application on a VPC in Amazon AWS, using Rails 5 and Ruby, using Puma for deployment and configuration of Public and Private subnets in Elastic Load Balancer. I also cover the details of network card settings, the selection process for subnets and security groups for Load Balancer and Instances, and finally shared the result of deploying the sample application on Elastic Beanstalk.
Step 6: Add a Custom Domain and SSL to Elastic Beanstalk - In this post, we successfully set up a custom domain name for our Elastic Beanstalk environment and secured it using SSL. By creating a CNAME or an ALIAS pointing at our environment URL (found on the dashboard screen), we made our app accessible via the new domain name. We then used AWS Certificate Manager to add SSL to our environment for access over HTTPS, which was confirmed by visiting the secured site. Now we have a Rails application that can not only be deployed by a CI server, but is also SSL secured with a custom domain.

Related Videos

You Need Arduino GitHub Actions - Learn how to add GitHub badges to your Arduino projects, improving project visibility and attracting contributors. Set up automated build checks with GitHub Actions to prevent broken code merges.
Revolutionize Your Raspberry Pi Development with VSCode Remote! - Learn how to develop code on Raspberry Pi using VSCode without needing VNC or a desktop environment by setting up a remote development environment. Develop your projects more conveniently and efficiently with this powerful tool!
The Hacker News Effect - The Website Didn't Catch Fire - Let's look at the traffic - Witness the Hacker News effect in action as the author's blog skyrocketed to popularity, easily handling massive traffic thanks to efficient hosting and Cloudfront!
AR Sudoku Solver in Your Browser: TensorFlow & Image Processing Magic - Discover how to recreate a Sudoku app using browser APIs and ecosystem advancements, and explore the image processing pipeline technique for extracting Sudoku puzzles and solving them.
Build Your Own Voice-Controlled Robot with ESP32 & TensorFlow Lite - Learn how to create a voice-controlled robot using ESP32 and TensorFlow Lite with this step-by-step guide on creating neural networks, generating training data, and implementing firmware codes.
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening


Published

> Image

atomic14

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...

View All Posts