At BRADIENT we use Solidus eCommerce and AWS to deploy our client's websites. In this tutorial, we’ll show you how to deploy a Solidus eCommerce application to Amazon AWS Elastic Beanstalk, the leading Cloud Computing Services platform.

AWS Elastic Beanstalk is an orchestration service offered from Amazon Web Services for deploying infrastructure which orchestrates various AWS services, including EC2, S3, Simple Notification Service (SNS), CloudWatch, autoscaling, and Elastic Load Balancers.


Here are the requirements:


Install and configure your eCommerce locally
First of all, like you did a thousand times, create your new Rails application:

> gem install pg
> rails new dope_ecommerce --database=postgresql
> cd dope_ecommerce


Install the required Solidus gem. Simply add the following lines to your Gemfile:

> vim Gemfile
gem 'solidus', '~> 2.6.0'
gem 'solidus_auth_devise'
gem 'aws-sdk', '~> 2.3'

> bundle


Note that we are also specifying the aws-sdk gem; this is needed if we want to use S3. Edit your config/database.yml and add the database configuration:

> vim config/database.yml
  <<: *default
  adapter: postgresql
  encoding: unicode
  database: <%= ENV['RDS_DB_NAME'] %>
  username: <%= ENV['RDS_USERNAME'] %>
  password: <%= ENV['RDS_PASSWORD'] %>
  host: <%= ENV['RDS_HOSTNAME'] %>
  port: <%= ENV['RDS_PORT'] %>


Install and run migrations on Solidus:

> bundle
> bundle exec rake db:create
> bundle exec rails g spree:install
> bundle exec rails g solidus:auth:install
> bundle exec rake railties:install:migrations
> bundle exec rake db:migrate


Initialize your project and make your first commit in Git:
> git init
> git add .
> git commit -m 'Initial project'


Run bundle exec rails s then go to http://localhost:3000 and make sure you correctly visualize the homepage.

> bundle exec rails s 

Configure Elastic Beanstalk
Ok, let’s start running some commands using EB CLI Commands. Then you can initiate a new Environment application with the following:

> eb init  

If you are using a separate AWS account use this instead:   > eb init  --profile profile_name

select this option: 4) Ruby 2.4 (Puma)

> mkdir .ebextensions
> cd .ebextensions
> touch 01_packages.config
> touch 02_nginx.config


Include your EB Extensions configurations, please make sure that you copy and paste correctly since these are space sensitive.

> vim .ebextensions/01_packages.config

# .ebextensions/packages.config
      git: []
      ImageMagick: []
      ImageMagick-devel: []
      openssl-devel: []
      postgresql93-devel: []

> vim .ebextensions/02_nginx.config

# .ebextensions/02_nginx.config
    mode: "000644"
    owner: root
    group: root
    content: |
      client_max_body_size 100M;
    command: "sudo service nginx reload"

> git add .
> git commit -m "message commit"
> git push origin master

Create your .ENV keys:
At the root of your app:

> touch .env
> vim .env



Deploy, create and setenv keys for your app to an EB environment with a single command:

> eb create domainName-development -c subdomain-name -r us-west-2 -k key_name -db.i db.t2.micro -db.engine postgres -db.user rds_username -db.pass rds_password -db.size 5 --scale 1 --elb-type classic --debug --verbose && eb setenv SECRET_KEY_BASE=653.................8556 && eb setenv AWS_BUCKET=S3BucketName && eb setenv AWS_ACCESS_KEY_ID=A.........8Q && eb setenv AWS_SECRET_ACCESS_KEY=qx.......Gp && eb setenv AWS_REGION=us-west-2  --profile profile_name --verbose && eb deploy --profile profile_name --verbose --debug

Pass in the profile to the command above if any:  --profile profile_name

Next tutorial is on how to setup the TLS/SSL with AWS ACM Certificate.

Thanks to nebulab for the format using Heroku deployment :) make sure to contact us if you have any questions.