Starting with the release of StrongNode 1.1, you can now deploy our Node.js distribution via a AWS AMI and make use of it in your development, stage or production environment. The pre-built StrongLoop AMI available on the Amazon Marketplace makes it easy for Node developers who’ve chosen Amazon as their infrastructure provider to get up and running, fast.
This post will show you how to configure and run StrongNode on Amazon EC2.
To find the StrongLoop AMI, simply log into the AWS Console and select “EC2.” Browse images by selecting “AMIs” under the “Images” drop down. Make sure the filtering shows “Public Images” , “All Images” and “All Platforms”. From here you can simply search “slnode” (since renamed as slc).
From the console you can directly launch your new instance, or use the Amazon Command Tools.
From the Amazon Command Tools its even easier, simply reference your ec2-keypair, the AMI ID and the instance size. with the following command.
$ ec2-run-instances ami-3ccde579 -k ec2-keypair -t t1.micro
Make sure and configure your authorization (firewall settings if your default configuration does not support the http tcp ports that your application is using ). The following command enables TCP port 22.
$ ec2-authorize default -p 22
You can remote ssh into your newly created server instance using the same ec2-keypair and the machine instance ID. For me its
$ssh -i ec2-keypair firstname.lastname@example.org
You have successfully ‘ssh-ed’ inte your StrongLoop Amazon server instance when you see the EC2 welcome and are presented with the command terminal
Now that your StrongLoop Node server is up, its common to go ahead and install git so you can easily load your Node.js server application code.
Installing git on the image is simple
$sudo yum install git'
If your pulling your code from a public github repo, you can just create an an app folder on your machine and git clone from the http github reference
$git clone https://github.com/strongloop-community/fib
To run the app:
$slnode run app.js
…or if you would like to use the new node-inspector debugging integration in the distro, run:
$slnode debug app.js
Then simply open a browser window to your new instance IP address. In this case I’m using port 3000, and my server instance prefix (just change the ec2-XX-XXX-XX-XX.us-west-1 url prefix to match your newly created machine address.) From your browser open http://ec2-54-222-94-59.us-west-1.compute.amazonaws.com:3000/. To checkout the integrated node-inspector debugger, you can open a Chrome browser and point it to: http://ec2-54-222-94-59.us-west-1.compute.amazonaws.com:8080/debug?port=5858 .
It’s that simple to get the StrongLoop Node distribution up and running on Amazon EC2.
- Ready to develop APIs in Node.js and get them connected to your data? Check out the Node.js LoopBack framework. We’ve made it easy to get started either locally or on your favorite cloud, with a simple npm install.