Elastic Beanstalk CLI を使ってみる
Elastic Beanstalk の CLI を使ってみたので、そのメモを載せます。
まずは Elastic Beanstalk の CLI を以下からダウンロード
http://aws.amazon.com/code/6752709412171743
展開した後、PATH に eb.exe のあるフォルダのパスを追加する。
今回は Windows 環境で実行。
早速以下のコマンドを実行してみると、
C:\ec2>eb status The configuration file, "config", cannot be found. Use the "init" command to cre ate it.
configuration ファイルが見つからないと言われる。
ので、init コマンドを実行。
すると、下記のように Access Key や Secret Access Key を聞かれる。
C:\ec2>eb init To get your AWS Access Key ID and Secret Access Key, visit "https://aws-portal.amazon.com/gp/aws/securityCredentials". Enter your AWS Access Key ID (current value is "*****"): Enter your AWS Secret Access Key (current value is "*****"): Select an AWS Elastic Beanstalk service region. Available service regions are: 1) US East (Virginia) 2) US West (Oregon) 3) US West (North California) 4) EU West (Ireland) 5) Asia Pacific (Singapore) 6) Asia Pacific (Tokyo) Select: (1 to 6): 6 Enter an AWS Elastic Beanstalk application name (auto-generated value is "ec2"): test1 Enter an AWS Elastic Beanstalk environment name (auto-generated value is "test1- env"): Select a solution stack. Available solution stacks are: 1) 32bit Amazon Linux running PHP 5.3 2) 64bit Amazon Linux running PHP 5.3 3) 64bit Windows Server 2008 R2 running IIS 7.5 4) 32bit Amazon Linux running Tomcat 7 5) 64bit Amazon Linux running Tomcat 7 6) 32bit Amazon Linux running Tomcat 6 7) 64bit Amazon Linux running Tomcat 6 8) 32bit Amazon Linux running Python 9) 64bit Amazon Linux running Python Select: (1 to 9): 4 Create an RDS DB Instance? [y/n]: y Create an RDS BD Instance from (current value is "No snapshot"): 1) No snapshot 2) Other snapshot Select: (1 to 2): 1 Enter an RDS DB master password: Retype password to confirm: It you terminate your environment, your RDS DB Instance will be deleted and you will lose your data. Create snapshot? [y/n]: n Updated AWS Credential file at "C:\Users\xxxxxxxxxxx\.elasticbeanstalk\aws_credenti al_file". Warning: Your directory has not been initialized as a Git repository. To create a local Git repository, run "git init" and then re-run the "eb init" command.
順番に答えていく。RDS も Elastic Beanstalk から自動で作成ができる。
作成が完了後、status コマンドを実行すると、以下のようになる。
C:\ec2>eb status Environment "test1-env" is not running.
作成した環境を起動してみる。
C:\ec2>eb start Warning: Your directory has not been initialized as a Git repository. To create a local Git repository, run "git init" and then re-run the "eb init" command. Starting application "test1". Waiting for environment "test1-env" to launch. 2012-10-25 13:35:16 INFO createEnvironment is starting. --- 途中省略 --- Application is available at "test1-env-xxxxxxxxxxxxx.elasticbeanstalk.com".
起動完了までに数分はかかる。
完了後 status を確認すると、以下のように表示される。
C:\ec2>eb status URL : test1-env-xxxxxxxx.elasticbeanstalk.com Status : Ready Health : Green RDS Database: AWSEBRDSDatabase | xxxxxxxxxxxxxx.xxxxxxxxxxx.ap-northeast-1.rds. amazonaws.com:3306 C:\ec2>
起動した http://test1-env-xxxxxxxxxxxxx.elasticbeanstalk.com にブラウザでアクセスしてみると、以下のように表示される。