この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
AWS Elastic BeanstalkがNode.jsアプリケーションのサポートを開始したので早速HelloWorld
http://aws.typepad.com/aws_japan/2013/03/aws-elastic-beanstalk-for-nodejs.html
Node.jsのEnvironmentを作る
AWS Elastic Beanstalkの任意のアプリケーションのLaunch New Environmentをクリックする
そこからContainer TypeからNode.jsを選択する
アプリを作成
フォルダを作成して下記のファイルを作成
server.js : HelloWorldを返すHTTPサーバ
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(process.env.PORT || 8888);
gitの設定
作成したフォルダにgitの設定する
git init
gitにadd
ブランチにserver.jsを追加する
git add server.js
gitのawsの設定
aws.configコマンドを使ってElastic Beanstalkにアップロードするための設定を行う
> git aws.config
...
AWS Access Key: XXXX
AWS Secret Key: XXXXXXX
AWS Region [default to us-east-1]: ap-northeast-1
AWS Elastic Beanstalk Application: My First Elastic Beanstalk Application
AWS Elastic Beanstalk Environment: akb7dev
gitでEBにアップロード
git aws.pushコマンドを使ってElastic Beanstalkにアップロードする
(git aws.pushコマンドは、Elastic Beanstalkにコンテンツをアップロードしてアプリケーションを更新することができるコマンド)
> git aws.push
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 480 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)
remote:
To https://xxxxxxxxx
* [new branch] xxxxxxxxxxx -> master
アプリケーションの更新を待つ
コンソールのElastic Beanstalk ApplicationのEventsタブで更新状況は確認できる
備考:インストールしておくためのツール
git
http://git-scm.com/
AWS Elastic Beanstalk Command Line Tool
http://aws.amazon.com/code/6752709412171743