華麗なる
  Elastic Beanstalk
  での環境構築



                                                                      2013年2月22日
欧文印刷株式会社・田名辺健人 http://blog.dateofrock.com/   NetCOBOLによるAWS活用事例とAWSを活用した事例セミナー
Who am I ?
  (この顔にピンときたら)
田名辺 健人(たなべたけひと)
ソフトウェアエンジニア
  @dateofrock
  http://blog.dateofrock.com/
欧文印刷株式会社(東京都)
高校まで札幌在住
2011年11月から札幌でテレワーク




                     有効期限切れてますww
1946年創業/社員数130名
   本社:東京都文京区
   工場:埼玉県坂戸市
アナログ デジタル
    ・
独自商品開発
紙で出来た
                                                ホワイトボード
                                                 消せる紙(し)



ノート型
ホワイトボード
NUboard
   http://www.g-mark.org/award/describe/39114
✓Elastic Beanstalkとは?
✓使う3つの理由
✓Elastic Beanstalkとは?
✓使う3つの理由
アマゾン ウェブ サービスの製品・サービス構成
マネージメント&管理
 ウェブインターフェース                     識別&アクセス                          デプロイ&自動化                            モニタリング
          AWS                                IAM                     AWS               AWS
                                     Identity Federation             Elastic           Cloud                   Amazon CloudWatch
    Mangement Console                                                Beanstalk         Formation
                                     Consolidated Billing


アプリケーションプラットフォームサービス
コンテンツ配信                  メッセージング                      検索                       分散処理                          ライブラリ&SDK
       Amazon                                          Amazon CloudSearch                                        Java, PHP, Python,
      CloudFront        Amazon    Amazon   Amazon                                  Elastic      Amazon              Ruby, .NET
                         SNS       SQS      SES                                  MapReduce       SWF


基本サービス
コンピューティング                        クラウドストレージ                        データベース                              ネットワーク

    Amazon         Auto
    EC2            Scaling       Amazon    Amazon   AWS Storage   Amazon     Amazon   Amazon          Amazon Elastic Load Amazon    AWS Direct
                                   S3       EBS      Gateway       RDS      DynamoDB Elasticache       VPC    Balancer    Route53    Connect




                                                                   アベイラビリティ―ゾーン

  AWS グローバルインフラストラクチャ
                                                                                                             エッジロケーション
                                                                            リージョン


                                                                             ©Amazon Web Services LLC or its affiliates. All rights reserved.




        http://aws.amazon.com/jp/what-is-aws/
ービス構成


                デプロイ&自動化                     モニタリング
                   AWS           AWS
eration            Elastic       Cloud           Amaz
d Billing          Beanstalk     Formation




   検索                     分散処理                   ライブラ

     Amazon CloudSearch                           Jav
                             Elastic    Amazon
                           MapReduce     SWF
構成


      デプロイ&自動化                      モニタリング
                                      2013/02/19追加!
         AWS            AWS
         Elastic        Cloud           AWS
                                          Amazon Cloud
         Beanstalk      Formation       OpsWorks




                 分散処理                    ライブラリ&SDK

on CloudSearch                             Java, PHP, Py
                   Elastic     Amazon         Ruby, .NE
                 MapReduce      SWF
構成


      デプロイ&自動化                      モニタリング
                                      2013/02/19追加!
         AWS            AWS
         Elastic        Cloud           AWS
                                          Amazon Cloud
         Beanstalk      Formation       OpsWorks




                 分散処理                    ライブラリ&SDK

on CloudSearch                             Java, PHP, Py
                   Elastic     Amazon         Ruby, .NE
                 MapReduce      SWF
時間もないので
AWSの
良い資料があります
     【注】スライドの手抜きではありません(笑)
はじめてのElastic Beanstalk

                 Amazon Data Services Japan




http://www.slideshare.net/AmazonWebServicesJapan/
        getting-startedwithbeanstalk-20130111
AWS資料より抜粋 http://www.slideshare.net/AmazonWebServicesJapan/getting-startedwithbeanstalk-20130111
AWS資料より抜粋 http://www.slideshare.net/AmazonWebServicesJapan/getting-startedwithbeanstalk-20130111
AWS資料より抜粋 http://www.slideshare.net/AmazonWebServicesJapan/getting-startedwithbeanstalk-20130111
続きはWebで
 AWS資料より抜粋 http://www.slideshare.net/AmazonWebServicesJapan/getting-startedwithbeanstalk-20130111
✓Elastic Beanstalkとは?
✓使う3つの理由
✓Elastic Beanstalkとは?
✓使う3つの理由
【1】
簡単すぎる環境構築
war
構築+deploy完了
Elastic Beanstalk Environment

                                                                       war




                                                              S3
                                    EC2 Instance
Elastic Load Balancing




                                    EC2 Instance
                                    Auto scaling group
                                                         Cloud Watch    SNS
$ git aws.push
【2】
便利なSwap URL
本番環境
    +
ステージング環境
2つの environment
environment1
honban.elasticbeanstalk.com
environment1
Running Version: version2
environment2
staging.elasticbeanstalk.com
environment2
Running Version: version3
ステージングを
 本番に昇格
Swap
Environment
URL
staging.elasticbeanstalk.com




honban.elasticbeanstalk.com
本番がversion3に
   なりました!
【3】
必要十分なConfig
AMI
素のAMIを
      カスタマイズ
      したい!
AMI
✓パッケージ
       インストール
      ✓コンテナ
AMI    カスタマイズ
           etc...
YAML
✓パッケージインストール
       ✓アーカイブダウンロード + 展開
       ✓ファイル生成 or コピー
YAML   ✓OSユーザー・グループ作成
       ✓コマンド実行(OS用)
       ✓コマンド実行(コンテナ用)
       ✓サービス設定(/etc/init.d)
       ✓Beanstalk固有の設定


$APP_ROOT/.ebextensions/*.config
YAML
packages:
  yum:
    libmemcached: []
    ruby-devel: []
    nfs-utils: [1.0.9]



    rpm, yum, apt,
   rubygems (chef)
sources:
  /usr/local/bin:↲
   http://hoge.com/hoge.tar.gz




   tar, tar+gzip, tar+bz2, zip
files:
  "/home/ec2-user":
     mode: "000777"
     owner: ec2-user
     group: ec2-user
     source: http://hoge.com/a.txt
files:
  "/home/ec2-user":
     mode: "000777"
     owner: ec2-user
     group: ec2-user
     content: |
       # this is my file
       # with content



    content直書きOK
users:
  myuser:
    groups:
       group1
       group2
    uid: "50"
    homeDir: “/tmp”
groups:
  - groupOne
  - groupTwo
    gid: "45"
commands:
  test:
    command: myscript.py
    cwd: /home/ec2-user
    env: myvarname: myvarvalue
container_commands:
  replace-server_xml:
    command: ↲
 cp .ebextensions/server.xml ↲
    /etc/tomcat7/server.xml




       server.xmlの置換
container_commands:
  01syncdb:
    command: "django-admin.py syncdb --noinput"
    leader_only: true
  02migrate:
    command: "django-admin.py migrate"
    leader_only: true




          マイグレーションの実行
services:
  sysvinit:
    myservice:
      enabled: true
      ensureRunning: true
option_settings:
  - namespace: ↲
aws:elasticbeanstalk:container:tomcat:jvmoptions
    option_name: Xmx
    value: 512m
  - option_name: AWS_SECRET_KEY
    value: SECRET_KEY
  - option_name: AWS_ACCESS_KEY_ID
    value: ACCESS_KEY
✓Elastic Beanstalkとは?
✓使う3つの理由
  1.簡単すぎる環境構築
  2.便利なSwap URL
  3.必要十分なConfig
Elastic Beanstalkで
華麗に環境構築しよう!




                     おしまい

華麗なるElastic Beanstalkでの環境構築