In the past I've done posts involving AWS and how to use AWS and Jekyll to launch your website. Seeing that they just had their annual London Summit (which was great by the way), I thought I 'd do a post on Elastic Beanstalk on how to deploy a simple Rails device, which uses postgres.
What is The Elastic beanstalk?
EB or Elastic Beanstalk allows users to deploy and manage their applications quickly without having to worry about setting up the infrastructure running those applications. It takes care of load balancing, health monitoring, capacity provision and scaling, allowing you to focus a little bit more on your actual application. Currently it supports Java, PHP,. NET, Python, Node.js, and Ruby applications built. Ruby on rails online course helps you to learn more skills and techniques.
The best thing about EB is that it helps you to handle that environment under one program. For instance, you could test new apps or plug-ins, live, on staging, without making an effect on your production site, which is very useful. Elastic Beanstalk is kind of the same thing, if you're used to deploying on Heroku. When you're confused about future charges, refer to the AWS free tier guide.

Get Started
It probably goes without saying, but make sure that you have an account with AWS. First, after you've installed a brew, make sure it's modified and then download the EB CLI.
$Review Brief
$Download brew awsebcli
$eb —release
The CLI 3.2.2 EB (Python 3.4.3)
Just run the version command to ensure it's all correctly installed and you should get something similar to the above.
I'll assume you've got your rails app ready to go, in the sense it works locally and you're just looking to deploy it. Having that in mind, you 're going to want to initialise EB in your app directory.
$init eb
Upon executing the above instruction, you will be given a series of questions about the device, the first of which is about the zone you would like to set up in.
Select a Region by default
1) Us-East-1: Eastern USA (N. Virginia)
2) us-west-1: US West (NC)
3) Us-west-2: Oregon (US West)
4) WE-1: EU (Ireland)
5) eu-central-1: European Union (Frankfurt)
6) Ap-South-1: Mumbai (Asia Pacific)
7) Ap-southeast-1: Singapore (Asia Pacific)
8) Asia Pacific (Sydney) ap-southeast-2
9) Asia Pacific (Tokyo) ap-northeast-1
10) Asia Pacific (Seoul) ap-northeast-2
11) South America (Sao Paulo): Sa-East-1
12) China (Beijing) cn-north-1:
13) Us-east-2: Eastern USA (Ohio)
14) Ca-central-1: (central) Canada
15) eu-west-2: European Union (London)
(3 By default):
I would obviously choose 6 because I'm in hyderabad, but choose which zone is nearest to where you are.
Pick an application you want to use
1) AnotherAppIPReployed previously
2) [Create New Request]
(By default 2): 2
Enter Name of Application
(Originally "myapp"):
Myapp Application was created.
Looks like you're using Ruby. Is this right?
(Y / n) to: y
Choose edition of the app.
Rubies 2.3 (Puma)
Rubies 2.2 (Puma)
(Puma) 3) Ruby 2.1
Ruby 2.0 (Puma) 4.
5) Ruby 2.3 (The Standalone Passenger)
6) Ruby 2.2 (The Standalone Passenger)
7) Ruby 2.1 (The Standalone Passenger)
8) Ruby 2.0 (The Standalone Passenger)
9) 1.9.3 in Ruby
(Originally 1): 1
Would you like to set up SSH to your instances?
You'll then be asked which application to use, you 'd choose a new application, I have two options as I've already implemented it. Next you can change your app's name but by default it will choose the root of the app. The Beanstalk will even check what's written in your app and make a presumption, but it will still first confirm it with you. Next you'll want to pick a ruby framework that fits the ruby version you've used for your device.
The last option allows you to set up SSH for your instances if you want to connect and configure things remotely, it doesn't take long to setup and will only generate a keypair to use, which will then be automatically uploaded to your generated instance on the EB console. For now, if you want to keep things simple, simply hit no.
If you want to Gain In-depth Knowledge on Ruby on Rails, please go through this link ruby on rails certification training
Establishing an Environment
Now if you log into your AWS console and head over to Elastic Beanstalk, you'll see just sitting there to see your generated device. It's all ready to go, we just have to upload our code actually.
First thing that you have to do is create an environment.
$EB Make myapp-env
Next EB will do some magic and create everything you need for your environment, including an S3 bucket to store data from the environment, a security group, a load balancer, an auto-scaling group, and notifications from CloudWatch.
Creating "app-170629 125010" application version archive
To upload S3 to myapp/app-170629 125010.zip. That can take some time.
Download Complete.
Details of environment of: myapp-env
Name of application: the myapp
Area: eu-west-2
Version currently in use: app-170629 125010
Eco ID: e-r4aeg3mdhp
Platform: arn: aws: elasticbeanstalk: eu-west-2::platform / Puma running 64bit Amazon Linux/2.4.1 with Ruby 2.3
Tier: Simple Web-Server
CNAME: AWARE
Updated: 11:50:15.449000 + 00:00:2017-06-29
Presentation Status:
start creatingEnvironment.
Use elasticbeanstalk-eu-west-2-677471806624 as an environment data storage bucket for the Amazon S3.
Security group founded named: sg-6aa8d203
Load balancer created, named: awseb-e-r-AWSEBLoa-1HFNDWZGG06GC
Security group created, called: awseb-e-r4aeg3mdhp-stack-AWSEBSecurityGroup-4BVER9RZTAEA
Auto Scaling setup named: awseb-e-r4aeg3mdhp-stack-AWSEBAutoScalingLaunchConfiguration-BGBXSRWXV2CS
Quality of the community has moved to Pending. Launch in progress (running for 30 seconds). There aren't examples.
Auto Scaling Group created with the name: awseb-e-r4aeg3mdhp-stack-AWSEBAutoScalingGroup-16TMUTO9XH2LD
Awaiting the launch of EC2 instances. That can take a couple of minutes.
Auto Scaling community policy created: arn: aws: autoscaling: eu-west-2:677471806624: scalingPolicy:3554965a-0856-4f3c-90be-cb49bace9305: autoScalingGroupName / awseb-e-r4aeg3mdhp-stack-AWSEBAutoScalingGroup-16TMUTO9XH2LD: policyName / awseb-e-r4aeg3mdhp-stack-AWSEBAutoScalingScaleUpPolicy-1NDWK7HFTSWWTSW
Auto Scaling community policy created named: arn: aws: autoscaling: eu-west-2:677471806624: scalingPolicy:2e1bac83-9f60-41ca-b60d-70e83fe14992: autoScalingGroupName / awseb-e-r4aeg3mdhp-stack-AWSEBAutoScalingGroup-16TMUTO9XH2LD: policyName / awseb-e-r4aeg3mdhp-stack-AWSEBAutoScalingScaleDownPolicy-56CUZI6KKC
CloudWatch alarm created named awseb-e-r4aeg3mdhp-stack-AWSEBCloudwatchAlarmHigh-MXF54IOA2SZX
CloudWatch alarm produced with the name: awseb-e-r4aeg3mdhp-stack-AWSEBCloudwatchAlarmLow-V88MV4MSDP3H
Instance added to your environment [i-0086bb04a1a0d57b9]
Health of the environment has shifted from Pending to Ok. It finished initialization 27 seconds ago and took 3 minutes.
Started environment successfully: myapp-env
It doesn't take too long but it's getting everything set up nicely and ready to go. You can view the status to check that it's all working, as below.
$Condition eb
Details of environment of: myapp-env
Name of application: the myapp
Area: eu-west-2
Version currently in use: app-170629 125010
Eco ID: e-r4aeg3mdhp
Platform: arn: aws: elasticbeanstalk: eu-west-2::platform / Puma running 64bit Amazon Linux/2.4.1 with Ruby 2.3
Tier: Simple Web-Server
CNAME: the myapp-env.itykuzig2.eu-west-2.elasticbeanstalk.com
Updated: 11:54:30.354000 + 00:00:2017-06-29
Status: Made ready
Health: Verdant
The last thing to do for the Rails App is to build a new environment variable SECRET KEY BASE to use, which is very easy to do.
$Top rake
GeneratesConnect
First, you 're going to want to change EB's environment variables, it's essential to remember that you're going to have to re-set all of your environment variables, similar to Heroku, because you're now running on a completely different computer.
SECRET KEY BASE = generatesalongkey $eb setenv
For the new environment variable this will change the climate. The same method applies to all other env vars you may have.
Set up PostgreSQL on your Instance with Rails
But at this stage your app will probably still not run, because we haven't set up a database for it. That's good, now we are about to do it.
On the Elastic Beanstalk screen, head over to your app's dashboard and click the "Configuration" key.
You'll then see the following at the bottom of the page.
Pick a protected username and password to request, then strike. That will create your database.
We also need to tell our instance to use postgres, and we use a yum package named postgresql93-devel to do this.
You can create custom configurations for EB environments, all you need to do is create a.ebextensions folder in the root, then use the.config suffix to name the file whatever you want. Also the file should be formatted like a file of.yml. So will your db.config file look like this in this situation.
Packings:
Yum:-Yum:
Postgresql93:]
Now commit and push this update to your repo, and re-deploy your app's latest version.
Add $git to.
$git commit -m 'postgres setup adding .config'
$git origin master push
$deploy eb
Once this is done, you can use the following command to open your Web app.
$opens eb
All should be set up and working now!
Conclusion
I hope you reach to a conclusion about Ruby on rails on AWS elastic beanstalk. You can learn more through Ruby on rails online training.