以前と設定の仕方が変わったようで、
npm startを設定しないとExpressが起動されなかったので手順をまとめました。
クライアントはMacです。
IAMユーザーの作成
マネジメントコンソールから必要な権限を持ったIAMユーザーを作成し、認証情報を取得。
awscliのインストール
sudo pip install awscli
aws --version
-------
aws-cli/1.11.74 Python/2.7.13 Darwin/16.6.0 botocore/1.5.55
-------
aws configure
------
AWS Access Key ID [None]: ********
AWS Secret Access Key [None]: ********
Default region name [None]: ap-northeast-1
Default output format [None]:
------
ebコマンドのインストール
pip install --upgrade --user awsebcli
vi .bash_profile
-----
export PATH=~/Library/Python/2.7/bin:$PATH
-----
eb --version
------
EB CLI 3.10.1 (Python 2.7.1)
------
Express環境の設定
sudo npm install -g express
sudo npm install -g express-generator
Expressプロジェクトの作成
express test-nodejs
cd test-nodejs/
npm install
git初期設定
git init
cat > .gitignore <<EOT
node_modules/
.gitignore
.elasticbeanstalk/
EOT
Elastic Beanstalkの初期設定/アプリ作成
eb init --platform node.js --region ap-northeast-1
eb create --sample test-nodejs
eb status
------
Environment details for: test-nodejs
Application name: test-nodejs
Region: ap-northeast-1
Deployed Version: app-e465-170525_182949
Environment ID: e-v7aa4cmhbi
Platform: arn:aws:elasticbeanstalk:ap-northeast-1::platform/Node.js running on 64bit Amazon Linux/4.1.0
Tier: WebServer-Standard
CNAME: test-nodejs.xxxxxxxxx.ap-northeast-1.elasticbeanstalk.com
Updated: 2017-05-25 09:31:52.871000+00:00
Status: Ready
Health: Green
これでElastic Beanstalk側の環境が完了です。
eb open
ここからExpressアプリをデプロイしていきます。
elasticbeanstalkでExpressを動かす設定
mkdir .ebextensions
vi .ebextensions/nodecommand.config
------
option_settings:
aws:elasticbeanstalk:container:nodejs:
NodeCommand: "npm start"
-------
ちなみに、これをやらないで進めると、Expressが起動せずに502エラーになってしまう。
アプリのデプロイ
vi views/index.jade
-----
extends layout
block content
h1= title
p Welcome to AWS
------
git add .
git commit -m "First express app"
eb deploy
eb open
無事expressアプリが表示されました