Reputation: 851
For the past week, I've been playing with the Rubber gem and can't seem to get it to work. I've decided it would be easier just to manually set up my EC2 instance. The problem is that I don't know how. Google hasn't been much help for a newb either. Any suggestions? It really is appreciated.
Upvotes: 10
Views: 10463
Reputation: 41844
You should also check out Ubuntu Juju deployment options.
Configuring for Amazon Web Services
https://juju.ubuntu.com/docs/getting-started.html
Using Juju to Deploy your Rails Application
https://juju.ubuntu.com/docs/howto-rails.html
Basic Usage of the Ruby on Rails Charm
Create a YAML config file with your application's name and its git location
sample-app.yaml
sample-app:
repo: https://github.com/pavelpachkovskij/sample-rails
Deploy the application and a proxy:
juju deploy --config sample-app.yaml rails myapp
juju deploy haproxy
juju add-relation haproxy myapp
Deploy and relate database:
juju deploy postgresql
juju add-relation postgresql:db myapp
Now you can run migrations:
juju ssh myapp/0 run rake db:migrate
Seed database
juju ssh myapp/0 run rake db:seed
And finally expose the proxy:
juju expose haproxy
Find the instance's public URL from
juju status haproxy
Scale horizontally by adding and removing units:
juju add-unit myapp
juju remove-unit myapp
Or go even larger with juju add-unit -n10 myapp for 10 nodes.
Upvotes: 0
Reputation: 54
chantheman gave a great tutorial if you want to do this manually. If you are looking for alternatives, you shall consider using a third-party solution like cloud management platforms, which make the setup of an EC2 instance and the deployment of applications easier. RightScale, which was mentioned earlier as an AMI provider in chantheman's tutorial, is one of them, but you can have a look at enStratus and Scalr as well (disclaimer: I work there). You'll need to give them your AWS credentials to allow them to make API calls on your behalf.
Cloud management softwares will provide some pre-configured AMIs (at Scalr, we call them roles) and offer an application deployment framework (we wrote a blogpost about this http://scalr.net/blog/announcements/deployments/). You will thus perform step 2-10 more quickly.
If you are tight on budget, RightScale and enStratus have a free account whereas Scalr is open-source and available under the Apache 2 license.
Upvotes: 1
Reputation: 5286
Sure.
Create a AWS account.
Decided what region you want to be in. Lots of things go into this decision, but worry about it later and just do a cheap one like Oregon or East.
Make sure you are in the correct region at the top left.
Then click launch server.
At this point you have to pick a AMI. An AMI is basically the template you want to use when you boot your server. Amazon gives you some, but there are a ton in the community section. I am a CentOS guy so I usually search for a CentOS AMI. RightScale makes some good ones so you can search for one of those. Make sure you pick i386 or x64 depending on the size of server you want. There are two distinct types of AMI's, EBS backed and S3 backed. Really you should stick with EBS because you have some more freedoms, but there are reasons to use both that are beyond the scope of this answer. Look for EBS and you probably will be good. EBS is the block storage. Basically it is attachable harddrives for your instances. Since everything in the cloud is "virtual" and nothing is thought of in a physical sense, you have to think that way too. So if you want more storage, you can attach some EBS volumes later. One thing though, S3 backed instances go bye bye when you shut them down. The EBS ones will too if you have the delete on termination flag set, but with EBS ones you can "Stop" them as well as "Terminate" them.
Select the size and availability zone. The zone is important if you are going to be setting up some kind of redundancy. Like if I have a master slave setup with MySQL I would put the master in one zone and the slave in another in case Amazon was having troubles that were isolated to one zone. But for this general purpose, don't worry about it.
Advanced Instance Options. Just leave all this alone most likely it is fine. Some of the small things here you can set later like termination protection.
Name it. Whatever.
Make a SSH key. Striaght forward. The only way to login to an Amazon server will be with the SSH key you assign it. There are no user names or passwords.
Security Groups. This is where you could get tripped up, well here and #5. But you should start off with creating a general security group call foo or whatever then adding the ports you want open on it. So if you want to ssh into it, which I assume you do, then open 22. If you want to use it for web then open 80 and 8080 or whatever. But be careful. I usually change my SSH port later to something random. And instead of putting 0.0.0.0/0 on it, I put my personal ip. But if you don't care that much just put 0.0.0.0/0 and open that bad boy to the world.
Then it will boot. As long as it all went as it was supposed to.
Now you can login. Just ssh -i thekey.pem thenwholehostname
Hope that helps.
There is this whole free tier you can use. http://aws.amazon.com/free/
Check that out. I would use that while you play with it.
I did all that from memory so I could have been off. ;)
Upvotes: 28