LoginSignup
4
4

More than 5 years have passed since last update.

【AWS】ebでPython環境構築してみた Flaskアプリケーションデプロイ編【Elastic Beanstalk】

Last updated at Posted at 2016-04-28

http://docs.aws.amazon.com/ja_jp/elasticbeanstalk/latest/dg/create-deploy-python-flask.html
に沿って作業していきます

前提条件

【AWS】ebでPython環境構築してみた Flaskアプリケーションデプロイ準備編の内容が終わっている

要は以下4つが使えればOK

  • Python 2.7
  • pip
  • virtualenv
  • awsebcli

EBCLIの導入

Macに Homebrew を使用して導入します

コマンド
brew install awsebcli
確認
eb --version
結果
EB CLI 3.7 (Python 2.7.1)

EB CLI でサイトをデプロイする

変数
VIRTUAL_ENV_NAME='eb-test-Flask'
コマンド
VIRTUAL_ENV_NAME='eb-test-Flask'
PJ_DIR_NAME='eb-flask'
cd ~/${VIRTUAL_ENV_NAME}/${PJ_DIR_NAME}
pwd
結果
/Users/****/eb-test-Flask/eb-flask
コマンド
eb init -p python2.7 flask-tutorial
結果
You have not yet set up your credentials or your credentials are incorrect 
You must provide your credentials.
(aws-access-id): ***************** ←クレデンシャルを入力
(aws-secret-key): **************** ←クレデンシャルを入力
Application flask-tutorial has been created.

コンソールで確認するとできている(この手順そのままなぞると多分オレゴンに出来ます)

Elastic_Beanstalk.jpg

pemキーの準備

コマンド
eb init
結果
Do you want to set up SSH for your instances?
(y/n): y

Type a keypair name.
(Default is aws-eb): eb-test-yuki
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/****/****/eb-test-hoge.
Your public key has been saved in /Users/****/****/eb-test-hoge.pub.
The key fingerprint is:

The key's randomart image is:

WARNING: Uploaded SSH public key for "eb-test-hoge" into EC2 for region us-west-2.
コマンド
eb create
結果
Enter Environment Name
(default is flask-tutorial-dev): flask-env
Enter DNS CNAME prefix
(default is flask-env):

これで処理が走るのでしばらく待ちます

コマンド
eb open

このコマンド打った後も実際にサイトが見れるようになるまで少し時間がかかります。
Elastic_Beanstalk_アプリケーション.jpg

URLを使用してサイトに接続すると手元でやったのと同じ環境が構築されているはずです。

リソースの削除

コマンド
eb terminate flask-env
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4