LoginSignup
4
6

More than 5 years have passed since last update.

[JAWS-UG CLI] ElasticBeanstalk #1 ElasticBeanstalk入門 (アプリケーションの作成&リリース)

Last updated at Posted at 2015-03-02

http://jawsug-cli.doorkeeper.jp/events/19360 でのハンズオン資料です。

AWS CLIを利用して、ElasticBeanstalkでアプリケーションを作成してみます。

前提条件

ElasticBeanstalkに関連するフル権限

  • 以下に対してフル権限があること。
ポリシードキュメント
{
    "GroupName": "beanstalk_full", 
    "PolicyDocument": {
        "Version": "2012-10-17", 
        "Statement": [
            {
                "Action": [
                    "elasticbeanstalk:*", 
                    "ec2:*", 
                    "elasticloadbalancing:*", 
                    "autoscaling:*", 
                    "cloudwatch:*", 
                    "s3:*", 
                    "sns:*", 
                    "cloudformation:*", 
                    "rds:*", 
                    "sqs:*", 
                    "iam:CreateRole",
                    "iam:CreateInstanceProfile",
                    "iam:GetUser",
                    "iam:ListInstanceProfiles",
                    "iam:ListRoles", 
                    "iam:PassRole"
                ], 
                "Resource": "*", 
                "Effect": "Allow"
            }
        ]
    }, 
    "PolicyName": "beanstalk_full"
}

AWS CLIのバージョン

  • 以下のバージョンで動作確認済

    • AWS CLI 1.7.12
コマンド
aws --version
結果(例)
aws-cli/1.7.12 Python/2.7.5 Darwin/13.4.0

VPC

  • 利用するリージョンにデフォルトVPCが存在すること。

0. 準備

0.1. 変数の確認

0.1. リージョンの決定

作成するユーザのデフォルトリージョンを決めます。
(カレントユーザが利用するカレントリージョンも切り変わります。)

コマンド(東京リージョンの場合)
export AWS_DEFAULT_REGION='ap-northeast-1'

0.2. 変数の確認

プロファイルとリージョンが想定のものになっていることを確認します。

変数の確認
aws configure list
結果(例)
            Name                    Value             Type    Location
            ----                    -----             ----    --------
         profile beanstalkFull-prjZ-mbp13              env    AWS_DEFAULT_PROFILE
      access_key     ****************LOAQ shared-credentials-file
      secret_key     ****************I1O1 shared-credentials-file
          region           ap-northeast-1              env    AWS_DEFAULT_REGION

0.3. S3バケットの確認

コマンド
AWS_ID=`aws iam get-user --query 'User.Arn' --output text | sed 's/^.*:://' | sed 's/:.*$//'` \
   && echo ${AWS_ID}
コマンド
S3_BUCKET_NAME="elasticbeanstalk-${AWS_DEFAULT_REGION}-${AWS_ID}"
  echo ${S3_BUCKET_NAME}
確認
aws s3 ls s3://${S3_BUCKET_NAME}
結果(存在する場合)
   (戻り値なし)

ノート: 存在しなくても、アプリケーション作成時に自動作成されるようで
す。

1. solution stackの決定

1.1. Solution Stackの一覧 (list-available-solution-stacks)

コマンド
aws elasticbeanstalk list-available-solution-stacks \
        --query 'SolutionStacks[]'
結果(例)
      [
          "64bit Amazon Linux 2014.09 v1.2.0 running PHP 5.5", 
          "32bit Amazon Linux 2014.09 v1.2.0 running PHP 5.5", 
          "64bit Amazon Linux 2014.09 v1.2.0 running PHP 5.4", 
          "32bit Amazon Linux 2014.09 v1.2.0 running PHP 5.4", 
          "64bit Amazon Linux 2014.09 v1.1.0 running PHP 5.5", 
          "64bit Amazon Linux 2014.09 v1.1.0 running PHP 5.4", 
          "64bit Amazon Linux 2014.03 v1.1.0 running PHP 5.5", 
          "32bit Amazon Linux 2014.03 v1.1.0 running PHP 5.5", 
          "64bit Amazon Linux 2014.03 v1.1.0 running PHP 5.4", 
          "32bit Amazon Linux 2014.03 v1.1.0 running PHP 5.4", 
          "32bit Amazon Linux running PHP 5.3", 
          "64bit Amazon Linux running PHP 5.3", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Node.js", 
          "32bit Amazon Linux 2014.09 v1.2.0 running Node.js", 
          "64bit Amazon Linux 2014.03 v1.1.0 running Node.js", 
          "32bit Amazon Linux 2014.03 v1.1.0 running Node.js", 
          "64bit Windows Server 2008 R2 running IIS 7.5", 
          "64bit Windows Server 2012 running IIS 8", 
          "64bit Windows Server 2012 R2 running IIS 8.5", 
          "64bit Windows Server Core 2012 R2 running IIS 8.5", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Tomcat 8 Java 8", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Tomcat 7 Java 7", 
          "32bit Amazon Linux 2014.09 v1.2.0 running Tomcat 7 Java 7", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Tomcat 7 Java 6", 
          "32bit Amazon Linux 2014.09 v1.2.0 running Tomcat 7 Java 6", 
          "64bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 7", 
          "32bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 7", 
          "64bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 6", 
          "32bit Amazon Linux 2014.03 v1.1.0 running Tomcat 7 Java 6", 
          "32bit Amazon Linux running Tomcat 7", 
          "64bit Amazon Linux 2014.03 v1.1.0 running Python 2.7", 
          "64bit Amazon Linux running Tomcat 7", 
          "32bit Amazon Linux running Tomcat 6", 
          "32bit Amazon Linux 2014.03 v1.1.0 running Python 2.7", 
          "64bit Amazon Linux 2014.03 v1.1.0 running Python", 
          "64bit Amazon Linux running Tomcat 6", 
          "32bit Amazon Linux 2014.03 v1.1.0 running Python", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Python 2.7", 
          "32bit Amazon Linux 2014.09 v1.2.0 running Python 2.7", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Python", 
          "32bit Amazon Linux 2014.09 v1.2.0 running Python", 
          "32bit Amazon Linux running Python", 
          "64bit Amazon Linux running Python", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Ruby 2.1 (Puma)", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Ruby 2.1 (Passenger Standalone)", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Ruby 2.0 (Puma)", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Ruby 2.0 (Passenger Standalone)", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Ruby 1.9.3", 
          "32bit Amazon Linux 2014.09 v1.2.0 running Ruby 1.9.3", 
          "64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.1 (Passenger Standalone)", 
          "64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.1 (Puma)", 
          "64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.0 (Passenger Standalone)", 
          "64bit Amazon Linux 2014.03 v1.1.0 running Ruby 2.0 (Puma)", 
          "64bit Amazon Linux 2014.03 v1.1.0 running Ruby 1.9.3", 
          "32bit Amazon Linux 2014.03 v1.1.0 running Ruby 1.9.3", 
          "64bit Amazon Linux 2014.09 v1.2.0 running Docker 1.3.3", 
          "64bit Debian jessie v1.2.0 running GlassFish 4.1 Java 8 (Preconfigured - Docker)", 
          "64bit Debian jessie v1.2.0 running GlassFish 4.0 Java 7 (Preconfigured - Docker)", 
          "64bit Debian jessie v1.2.0 running Python 3.4 (Preconfigured - Docker)", 
          "64bit Debian jessie v1.2.0 running Go 1.4 (Preconfigured - Docker)", 
          "64bit Debian jessie v1.2.0 running Go 1.3 (Preconfigured - Docker)"
      ]

1.2. Solution Stackの決定

Solution Stackを選択する。

コマンド
      EB_ENV_SOL='64bit Amazon Linux 2014.09 v1.2.0 running PHP 5.5'

1.3. Solution Stackの内容確認

コマンド
aws elasticbeanstalk describe-configuration-options \
        --solution-stack-name "${EB_ENV_SOL}"
結果(例)
 {
  "Options": [
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:scheduledaction",
      "Name": "Recurrence",
      "UserDefined": false
    },
    {
      "Name": "DesiredCapacity",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:scheduledaction",
      "MaxValue": 10000,
      "MinValue": 0
    },
    {
      "Name": "DefaultSSHPort",
      "UserDefined": false,
      "DefaultValue": "22",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:control",
      "ValueType": "Scalar"
    },
    {
      "Name": "Interval",
      "UserDefined": false,
      "DefaultValue": "30",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:healthcheck",
      "MaxValue": 300,
      "MinValue": 5,
      "ValueType": "Scalar"
    },
    {
      "Name": "EvaluationPeriods",
      "UserDefined": false,
      "DefaultValue": "1",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:trigger",
      "MaxValue": 600,
      "MinValue": 1,
      "ValueType": "Scalar"
    },
    {
      "Name": "HooksPkgUrl",
      "UserDefined": false,
      "DefaultValue": "https://s3-ap-southeast-1.amazonaws.com/elasticbeanstalk-env-resources-ap-southeast-1/stalks/eb_php_3.11.1/lib/assets.tar.gz",
      "ChangeSeverity": "Unknown",
      "Namespace": "aws:cloudformation:template:parameter",
      "ValueType": "Scalar"
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:scheduledaction",
      "Name": "EndTime",
      "UserDefined": false
    },
    {
      "Regex": {
        "Pattern": "((HTTP|TCP):)?(\\d*)(/.*)?",
        "Label": "HTTP or TCP (optional - default HTTP) followed by a port (optional - default 80) followed by an optional path"
      },
      "Name": "Application Healthcheck URL",
      "UserDefined": false,
      "DefaultValue": null,
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:application",
      "MaxLength": 200,
      "ValueType": "Scalar"
    },
    {
      "Name": "BatchSizeType",
      "UserDefined": false,
      "DefaultValue": "Percentage",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:command",
      "ValueType": "Scalar",
      "ValueOptions": [
        "Percentage",
        "Fixed"
      ]
    },
    {
      "Name": "MinInstancesInService",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:updatepolicy:rollingupdate",
      "MaxValue": 9999,
      "MinValue": 0
    },
    {
      "Name": "Automatically Terminate Unhealthy Instances",
      "UserDefined": false,
      "DefaultValue": "true",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:monitoring",
      "ValueType": "Boolean"
    },
    {
      "Regex": {
        "Pattern": "^\\S*$",
        "Label": "No spaces"
      },
      "Name": "Timeout",
      "UserDefined": false,
      "DefaultValue": "PT30M",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:updatepolicy:rollingupdate",
      "ValueType": "Scalar"
    },
    {
      "Name": "MinSize",
      "UserDefined": false,
      "DefaultValue": "1",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:asg",
      "MaxValue": 10000,
      "MinValue": 1,
      "ValueType": "Scalar"
    },
    {
      "Name": "composer_options",
      "UserDefined": false,
      "DefaultValue": null,
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:container:php:phpini",
      "ValueType": "Scalar"
    },
    {
      "Name": "Timeout",
      "UserDefined": false,
      "DefaultValue": "5",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:healthcheck",
      "MaxValue": 60,
      "MinValue": 2,
      "ValueType": "Scalar"
    },
    {
      "Name": "UpperBreachScaleIncrement",
      "UserDefined": false,
      "DefaultValue": "1",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:trigger",
      "MaxLength": 200,
      "ValueType": "Scalar"
    },
    {
      "ValueType": "Boolean",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:ec2:vpc",
      "Name": "AssociatePublicIpAddress",
      "UserDefined": false
    },
    {
      "Name": "allow_url_fopen",
      "UserDefined": false,
      "DefaultValue": "On",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:container:php:phpini",
      "ValueType": "Scalar",
      "ValueOptions": [
        "true",
        "false",
        "On",
        "Off"
      ]
    },
    {
      "Name": "MaxBatchSize",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:updatepolicy:rollingupdate",
      "MaxValue": 10000,
      "MinValue": 1
    },
    {
      "Name": "LoadBalancerHTTPPort",
      "UserDefined": false,
      "DefaultValue": "OFF",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:loadbalancer",
      "ValueType": "Scalar",
      "ValueOptions": [
        "OFF",
        "80"
      ]
    },
    {
      "Name": "HealthyThreshold",
      "UserDefined": false,
      "DefaultValue": "3",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:healthcheck",
      "MaxValue": 10,
      "MinValue": 2,
      "ValueType": "Scalar"
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:sns:topics",
      "Name": "Notification Topic ARN",
      "UserDefined": false
    },
    {
      "Name": "Notification Protocol",
      "UserDefined": false,
      "DefaultValue": "email",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:sns:topics",
      "ValueType": "Scalar",
      "ValueOptions": [
        "http",
        "https",
        "email",
        "email-json",
        "sqs"
      ]
    },
    {
      "Name": "CrossZone",
      "UserDefined": false,
      "DefaultValue": "false",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:loadbalancer",
      "ValueType": "Boolean"
    },
    {
      "Name": "MeasureName",
      "UserDefined": false,
      "DefaultValue": "NetworkOut",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:trigger",
      "ValueType": "Scalar",
      "ValueOptions": [
        "CPUUtilization",
        "NetworkIn",
        "NetworkOut",
        "DiskWriteOps",
        "DiskReadBytes",
        "DiskReadOps",
        "DiskWriteBytes",
        "Latency",
        "RequestCount",
        "HealthyHostCount",
        "UnhealthyHostCount"
      ]
    },
    {
      "Regex": {
        "Pattern": "^(/.*)?$",
        "Label": "Value must be empty or begin with a forward slash"
      },
      "Name": "document_root",
      "UserDefined": false,
      "DefaultValue": null,
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:container:php:phpini",
      "ValueType": "Scalar"
    },
    {
      "Name": "LowerBreachScaleIncrement",
      "UserDefined": false,
      "DefaultValue": "-1",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:trigger",
      "MaxLength": 200,
      "ValueType": "Scalar"
    },
    {
      "ValueType": "Boolean",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:updatepolicy:rollingupdate",
      "Name": "RollingUpdateEnabled",
      "UserDefined": false
    },
    {
      "Name": "Suspend",
      "UserDefined": false,
      "DefaultValue": "false",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:scheduledaction",
      "ValueType": "Boolean"
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:sns:topics",
      "Name": "Notification Topic Name",
      "UserDefined": false
    },
    {
      "Name": "LoadBalancerPortProtocol",
      "UserDefined": false,
      "DefaultValue": "HTTP",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:loadbalancer",
      "ValueType": "Scalar",
      "ValueOptions": [
        "HTTP",
        "TCP"
      ]
    },
    {
      "Name": "Timeout",
      "UserDefined": false,
      "DefaultValue": "600",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:command",
      "MaxValue": 3600,
      "MinValue": 1,
      "ValueType": "Scalar"
    },
    {
      "Name": "UnhealthyThreshold",
      "UserDefined": false,
      "DefaultValue": "5",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:healthcheck",
      "MaxValue": 10,
      "MinValue": 2,
      "ValueType": "Scalar"
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:scheduledaction",
      "Name": "StartTime",
      "UserDefined": false
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:application:environment",
      "Name": "PARAM3",
      "UserDefined": false
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:application:environment",
      "Name": "PARAM2",
      "UserDefined": false
    },
    {
      "Name": "MinSize",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:scheduledaction",
      "MaxValue": 10000,
      "MinValue": 0
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:application:environment",
      "Name": "PARAM1",
      "UserDefined": false
    },
    {
      "Regex": {
        "Pattern": "^\\S*$",
        "Label": "No spaces"
      },
      "Name": "AWS_ACCESS_KEY_ID",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:application:environment"
    },
    {
      "Regex": {
        "Pattern": "((/dev/([sh]d[a-z]([1-9]?|1[0-5]?)|xvd[a-z]|xvd[bc][a-z])|xvd[a-z]|xvd[bc][a-z])=(none|ephemeral[0-9]+|(snap-[a-zA-Z0-9]+)?(:([0-9]+)?)?(:(true|false)?)?(:gp2|:standard|:io1:[0-9]+)?))(,\\s*(/dev/([sh]d[a-z]([1-9]?|1[0-5]?)|xvd[a-z]|xvd[bc][a-z])|xvd[a-z]|xvd[bc][a-z])=(none|ephemeral[0-9]+|(snap-[a-zA-Z0-9]+)?(:([0-9]+)?)?(:(true|false)?)?(:gp2|:standard|:io1:[0-9]+)?))*",
        "Label": "<DeviceName>=<Volume>, <Volume> is one of 'none', 'ephemeral<NUMBER>', or '[<SnapshotId>]:[<VolumeSize>]:[DeleteOnTermination]:[<VolumeType>][:<IOPS> (only when VolumeType is io1)]'."
      },
      "Name": "BlockDeviceMappings",
      "UserDefined": false,
      "ValueType": "CommaSeparatedList",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration"
    },
    {
      "Name": "SecurityGroups",
      "UserDefined": false,
      "ValueType": "CommaSeparatedList",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "MaxLength": 200
    },
    {
      "Name": "MaxSize",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:scheduledaction",
      "MaxValue": 10000,
      "MinValue": 0
    },
    {
      "Regex": {
        "Pattern": "^\\S*$",
        "Label": "No spaces"
      },
      "Name": "PauseTime",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:updatepolicy:rollingupdate"
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:application:environment",
      "Name": "PARAM5",
      "UserDefined": false
    },
    {
      "ValueType": "CommaSeparatedList",
      "ChangeSeverity": "Unknown",
      "Namespace": "aws:ec2:vpc",
      "Name": "ELBSubnets",
      "UserDefined": false
    },
    {
      "Name": "LaunchType",
      "UserDefined": false,
      "DefaultValue": "Normal",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:control",
      "ValueType": "Scalar",
      "ValueOptions": [
        "Migration",
        "Normal"
      ]
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:application:environment",
      "Name": "PARAM4",
      "UserDefined": false
    },
    {
      "Name": "display_errors",
      "UserDefined": false,
      "DefaultValue": "Off",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:container:php:phpini",
      "ValueType": "Scalar",
      "ValueOptions": [
        "On",
        "Off"
      ]
    },
    {
      "Name": "max_execution_time",
      "UserDefined": false,
      "DefaultValue": "60",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:container:php:phpini",
      "MinValue": 1,
      "ValueType": "Scalar"
    },
    {
      "Name": "Cooldown",
      "UserDefined": false,
      "DefaultValue": "360",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:asg",
      "MaxValue": 10000,
      "MinValue": 0,
      "ValueType": "Scalar"
    },
    {
      "Regex": {
        "Pattern": "^\\S*$",
        "Label": "No spaces"
      },
      "Name": "AWS_SECRET_KEY",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:application:environment"
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "Name": "IamInstanceProfile",
      "UserDefined": false
    },
    {
      "Name": "LoadBalancerHTTPSPort",
      "UserDefined": false,
      "DefaultValue": "OFF",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:loadbalancer",
      "ValueType": "Scalar",
      "ValueOptions": [
        "OFF",
        "443",
        "8443"
      ]
    },
    {
      "ValueType": "CommaSeparatedList",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:ec2:vpc",
      "Name": "Subnets",
      "UserDefined": false
    },
    {
      "Name": "LogPublicationControl",
      "UserDefined": false,
      "DefaultValue": "false",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:hostmanager",
      "ValueType": "Boolean",
      "ValueOptions": [
        "true",
        "false"
      ]
    },
    {
      "Name": "RootVolumeIOPS",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "MaxValue": 4000,
      "MinValue": 100
    },
    {
      "Name": "ConnectionDrainingTimeout",
      "UserDefined": false,
      "DefaultValue": "20",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:policies",
      "MaxValue": 3600,
      "MinValue": 1,
      "ValueType": "Scalar"
    },
    {
      "Name": "BreachDuration",
      "UserDefined": false,
      "DefaultValue": "5",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:trigger",
      "MaxValue": 600,
      "MinValue": 1,
      "ValueType": "Scalar"
    },
    {
      "Name": "InstancePort",
      "UserDefined": false,
      "DefaultValue": "80",
      "ChangeSeverity": "Unknown",
      "Namespace": "aws:cloudformation:template:parameter",
      "ValueType": "Scalar"
    },
    {
      "Name": "Unit",
      "UserDefined": false,
      "DefaultValue": "Bytes",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:trigger",
      "ValueType": "Scalar",
      "ValueOptions": [
        "Seconds",
        "Percent",
        "Bytes",
        "Bits",
        "Count",
        "Bytes/Second",
        "Bits/Second",
        "Count/Second",
        "None"
      ]
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "Unknown",
      "Namespace": "aws:ec2:vpc",
      "Name": "VPCId",
      "UserDefined": false
    },
    {
      "Name": "RollingUpdateType",
      "UserDefined": false,
      "DefaultValue": "Time",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:updatepolicy:rollingupdate",
      "ValueType": "Scalar",
      "ValueOptions": [
        "Time",
        "Health"
      ]
    },
    {
      "Regex": {
        "Pattern": "ami-.+",
        "Label": "must start with ami-"
      },
      "Name": "ImageId",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "MaxLength": 200
    },
    {
      "Name": "Stickiness Cookie Expiration",
      "UserDefined": false,
      "DefaultValue": "0",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:policies",
      "MaxValue": 1000000,
      "MinValue": 0,
      "ValueType": "Scalar"
    },
    {
      "Name": "LaunchTimeout",
      "UserDefined": false,
      "DefaultValue": "0",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:control",
      "MinValue": 0,
      "ValueType": "Scalar"
    },
    {
      "Name": "RollbackLaunchOnFailure",
      "UserDefined": false,
      "DefaultValue": "false",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:control",
      "ValueType": "Boolean"
    },
    {
      "Name": "MonitoringInterval",
      "UserDefined": false,
      "DefaultValue": "5 minute",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "ValueType": "Scalar",
      "ValueOptions": [
        "1 minute",
        "5 minute"
      ]
    },
    {
      "Name": "RootVolumeType",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "ValueOptions": [
        "standard",
        "gp2",
        "io1"
      ]
    },
    {
      "Name": "SSLCertificateId",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:loadbalancer",
      "MaxLength": 200
    },
    {
      "Regex": {
        "Pattern": "[1-9][0-9]*(K|M|G)",
        "Label": "Value must be greater than zero and includes a K, M, or G to represent kilobytes, megabytes, or gigabytes"
      },
      "Name": "memory_limit",
      "UserDefined": false,
      "DefaultValue": "256M",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:container:php:phpini",
      "ValueType": "Scalar"
    },
    {
      "Name": "Statistic",
      "UserDefined": false,
      "DefaultValue": "Average",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:trigger",
      "ValueType": "Scalar",
      "ValueOptions": [
        "Minimum",
        "Maximum",
        "Sum",
        "Average"
      ]
    },
    {
      "Name": "RootVolumeSize",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "MaxValue": 1024,
      "MinValue": 8
    },
    {
      "Regex": {
        "Pattern": ".+,\\d+,\\d+,.+",
        "Label": "<protocol>,<fromport>,<toport>,source"
      },
      "Name": "SSHSourceRestriction",
      "UserDefined": false,
      "DefaultValue": "tcp,22,22,0.0.0.0/0",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "ValueType": "Scalar"
    },
    {
      "Name": "BatchSize",
      "UserDefined": false,
      "DefaultValue": "100",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:command",
      "MaxValue": 10000,
      "MinValue": 1,
      "ValueType": "Scalar"
    },
    {
      "Name": "zlib.output_compression",
      "UserDefined": false,
      "DefaultValue": "Off",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:elasticbeanstalk:container:php:phpini",
      "ValueType": "Scalar",
      "ValueOptions": [
        "true",
        "false",
        "On",
        "Off"
      ]
    },
    {
      "Name": "ELBScheme",
      "UserDefined": false,
      "DefaultValue": "public",
      "ChangeSeverity": "Unknown",
      "Namespace": "aws:ec2:vpc",
      "ValueType": "Scalar",
      "ValueOptions": [
        "public",
        "internal"
      ]
    },
    {
      "Name": "MaxSize",
      "UserDefined": false,
      "DefaultValue": "4",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:asg",
      "MaxValue": 10000,
      "MinValue": 1,
      "ValueType": "Scalar"
    },
    {
      "Name": "EnvironmentType",
      "UserDefined": false,
      "DefaultValue": "LoadBalanced",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:elasticbeanstalk:environment",
      "ValueType": "Scalar",
      "ValueOptions": [
        "LoadBalanced",
        "SingleInstance"
      ]
    },
    {
      "ValueType": "Scalar",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elasticbeanstalk:sns:topics",
      "Name": "Notification Endpoint",
      "UserDefined": false
    },
    {
      "Name": "Availability Zones",
      "UserDefined": false,
      "DefaultValue": "Any",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:asg",
      "ValueType": "Scalar",
      "ValueOptions": [
        "Any",
        "Any 1",
        "Any 2",
        "Any 3"
      ]
    },
    {
      "Name": "UpperThreshold",
      "UserDefined": false,
      "DefaultValue": "2000000",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:trigger",
      "MinValue": 0,
      "ValueType": "Scalar"
    },
    {
      "Name": "EnvironmentVariables",
      "UserDefined": false,
      "DefaultValue": "AWS_ACCESS_KEY_ID=,AWS_SECRET_KEY=,PARAM1=,PARAM2=,PARAM3=,PARAM4=,PARAM5=",
      "ChangeSeverity": "RestartApplicationServer",
      "Namespace": "aws:cloudformation:template:parameter",
      "ValueType": "KeyValueList"
    },
    {
      "Name": "Stickiness Policy",
      "UserDefined": false,
      "DefaultValue": "false",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:policies",
      "ValueType": "Boolean"
    },
    {
      "Regex": {
        "Pattern": "((HTTP|TCP):)?(\\d*)(/.*)?",
        "Label": "Either TCP:port or HTTP:port/pathToPing"
      },
      "Name": "Target",
      "UserDefined": false,
      "DefaultValue": "TCP:80",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:healthcheck",
      "ValueType": "Scalar"
    },
    {
      "Name": "ConnectionSettingIdleTimeout",
      "UserDefined": false,
      "DefaultValue": "60",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:policies",
      "MaxValue": 3600,
      "MinValue": 1,
      "ValueType": "Scalar"
    },
    {
      "Name": "EC2KeyName",
      "UserDefined": false,
      "ValueType": "Scalar",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "MaxLength": 200
    },
    {
      "Name": "AppSource",
      "UserDefined": false,
      "DefaultValue": "http://s3-ap-southeast-1.amazonaws.com/elasticbeanstalk-samples-ap-southeast-1/php-newsample-app.zip",
      "ChangeSeverity": "Unknown",
      "Namespace": "aws:cloudformation:template:parameter",
      "ValueType": "Scalar"
    },
    {
      "Name": "Period",
      "UserDefined": false,
      "DefaultValue": "5",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:trigger",
      "MaxValue": 600,
      "MinValue": 1,
      "ValueType": "Scalar"
    },
    {
      "Name": "InstanceType",
      "UserDefined": false,
      "DefaultValue": "t1.micro",
      "ChangeSeverity": "RestartEnvironment",
      "Namespace": "aws:autoscaling:launchconfiguration",
      "ValueType": "Scalar",
      "ValueOptions": [
        "t2.micro",
        "t2.small",
        "t2.medium",
        "m3.medium",
        "m3.large",
        "m3.xlarge",
        "m3.2xlarge",
        "c3.large",
        "c3.xlarge",
        "c3.2xlarge",
        "c3.4xlarge",
        "c3.8xlarge",
        "t1.micro",
        "m1.small",
        "m1.medium",
        "m1.large",
        "m1.xlarge",
        "c1.medium",
        "c1.xlarge",
        "c4.large",
        "c4.xlarge",
        "c4.2xlarge",
        "c4.4xlarge",
        "c4.8xlarge",
        "m2.xlarge",
        "m2.2xlarge",
        "m2.4xlarge",
        "g2.2xlarge",
        "i2.xlarge",
        "i2.2xlarge",
        "i2.4xlarge",
        "i2.8xlarge",
        "r3.large",
        "r3.xlarge",
        "r3.2xlarge",
        "r3.4xlarge",
        "r3.8xlarge"
      ]
    },
    {
      "Name": "LoadBalancerSSLPortProtocol",
      "UserDefined": false,
      "DefaultValue": "HTTPS",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:loadbalancer",
      "ValueType": "Scalar",
      "ValueOptions": [
        "HTTPS",
        "SSL"
      ]
    },
    {
      "Name": "LowerThreshold",
      "UserDefined": false,
      "DefaultValue": "2000000",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:trigger",
      "MinValue": 0,
      "ValueType": "Scalar"
    },
    {
      "Name": "Custom Availability Zones",
      "UserDefined": false,
      "DefaultValue": null,
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:autoscaling:asg",
      "ValueType": "List",
      "ValueOptions": [
        "ap-southeast-1a",
        "ap-southeast-1b"
      ]
    },
    {
      "Name": "ConnectionDrainingEnabled",
      "UserDefined": false,
      "DefaultValue": "false",
      "ChangeSeverity": "NoInterruption",
      "Namespace": "aws:elb:policies",
      "ValueType": "Boolean"
    }
  ]
}

1.4. ソースのファイル形式確認

ソースのファイル形式を確認する。

コマンド
EB_SOL_FTYPE=`aws elasticbeanstalk list-available-solution-stacks | jq --arg sol "${EB_ENV_SOL}" -r '.SolutionStackDetails[] | select( .SolutionStackName == $sol ).PermittedFileTypes[]'` \
&& echo ${EB_SOL_FTYPE}
結果(例)
zip

1.5. その他のチェックポイント

  • InstanceTypeのDefaultValue (例: t1.micro)

  • MinSizeのDefaultValue (例: 1)

  • MaxSizeのDefaultValue (例: 4)

2. アプリケーションの作成

2.1. アプリケーション名の決定

コマンド
EB_APP_NAME='My First Elastic Beanstalk Application'

2.2. アプリケーションの作成

アプリケーションの不存在確認 (describe-applications)

コマンド
aws elasticbeanstalk describe-applications \
-application-name "${EB_APP_NAME}"
結果
{
    "Applications": []
}

アプリケーション作成 (create-application)

変数の確認
cat << ETX

EB_APP_NAME: "${EB_APP_NAME}"

ETX
コマンド
aws elasticbeanstalk create-application --application-name "${EB_APP_NAME}"
結果(例)
{
  "Application": {
    "ApplicationName": "My First Elastic Beanstalk Application",
    "ConfigurationTemplates": [],
    "DateUpdated": "2015-02-17T07:25:12.971Z",
    "DateCreated": "2015-02-17T07:25:12.971Z"
  }
}

アプリケーションの内容確認 (describe-applications)

コマンド
aws elasticbeanstalk describe-applications \
-application-name "${EB_APP_NAME}"
結果(例)
{
  "Applications": [
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "ConfigurationTemplates": [],
      "DateUpdated": "2015-02-17T07:25:12.971Z",
      "DateCreated": "2015-02-17T07:25:12.971Z"
    }
  ]
}

イベント確認 (describe-events)

コマンド
EB_MAX_ITEMS='3'
コマンド
aws elasticbeanstalk describe-events \
-application-name "${EB_APP_NAME}" \
-max-items ${EB_MAX_ITEMS}
結果(例)
{
  "NextToken": "None___3",
  "Events": [
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "Message": "createApplication completed successfully.",
      "Severity": "INFO",
      "EventDate": "2015-03-02T07:08:08.039Z",
      "RequestId": "e0de0f03-c0aa-11e4-ac14-7f1caa62b011"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "Message": "Created new Application: My First Elastic Beanstalk Application",
      "Severity": "INFO",
      "EventDate": "2015-03-02T07:08:07.954Z",
      "RequestId": "e0de0f03-c0aa-11e4-ac14-7f1caa62b011"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "Message": "createApplication is starting.",
      "Severity": "INFO",
      "EventDate": "2015-03-02T07:08:07.822Z",
      "RequestId": "e0de0f03-c0aa-11e4-ac14-7f1caa62b011"
    }
  ]
}

3. アプリケーションの開発 (versionの作成)

3.1. 最初のversion名の決定

コマンド
EB_VER_LABEL='Sample Application'

3.2. 最初のversionのソースコード配備

ソースコードの準備 (1st version)

コマンド
SRC_EB_VER='https://elasticbeanstalk-samples-us-east-1.s3.amazonaws.com/php-sample.zip'
コマンド
FILE_EB_VER=`echo ${SRC_EB_VER} | sed 's/^.*\///'` \
&& echo ${FILE_EB_VER}
コマンド
curl ${SRC_EB_VER} > ${FILE_EB_VER}
結果(例)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3509 100 3509 0 0 3712 0 --:--:-- --:--:-- --:--:-- 3830

ソースコードのS3バケットへの転送

コマンド
S3_OBJECT_NAME=${FILE_EB_VER}
コマンド
aws s3 cp ${FILE_EB_VER} s3://${S3_BUCKET_NAME}/${S3_OBJECT_NAME}
結果(例)
upload: ./php-secondsample.zip to s3://example-bucket/php-secondsample.zip

ノート: 転送先のリージョンと AWS_DEFAULT_REGIONのリージョンが同一
じゃない と転送できない?

3.3. 最初のversionの作成

バージョンの存在確認 (describe-application-versions)

コマンド
aws elasticbeanstalk describe-application-versions \
-application-name "${EB_APP_NAME}"
結果
{
"ApplicationVersions": []
}

バージョンの作成 (create-application-version)

変数の確認
cat << ETX

EB_APP_NAME: "${EB_APP_NAME}"
EB_VER_LABEL: "${EB_VER_LABEL}"
S3_BUCKET_NAME: ${S3_BUCKET_NAME}
S3_OBJECT_NAME: ${S3_OBJECT_NAME}

ETX
コマンド
aws elasticbeanstalk create-application-version \
-application-name "${EB_APP_NAME}" \
-version-label "${EB_VER_LABEL}" \
-source-bundle "S3Bucket=${S3_BUCKET_NAME},S3Key=${S3_OBJECT_NAME}"
結果(例)
{
  "ApplicationVersion": {
    "ApplicationName": "My First Elastic Beanstalk Application",
    "VersionLabel": "Sample Application",
    "SourceBundle": {
      "S3Bucket": "elasticbeanstalk-us-west-2-XXXXXXXXXXXX",
      "S3Key": "php-sample.zip"
    },
    "DateUpdated": "2015-03-02T07:11:16.839Z",
    "DateCreated": "2015-03-02T07:11:16.839Z"
  }
}

バージョンの存在確認 (describe-application-versions)

コマンド
aws elasticbeanstalk describe-application-versions \
-application-name "${EB_APP_NAME}" \
-version-labels "${EB_VER_LABEL}"
結果(例)
{
  "ApplicationVersions": [
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "VersionLabel": "Sample Application",
      "SourceBundle": {
        "S3Bucket": "elasticbeanstalk-us-west-2-XXXXXXXXXXXX",
        "S3Key": "php-sample.zip"
      },
      "DateUpdated": "2015-03-02T07:11:16.839Z",
      "DateCreated": "2015-03-02T07:11:16.839Z"
    }
  ]
}

イベント確認 (describe-events)

コマンド
EB_MAX_ITEMS='3'
コマンド
aws elasticbeanstalk describe-events \
-application-name "${EB_APP_NAME}" \
-max-items ${EB_MAX_ITEMS}
結果(例)
{
  "NextToken": "None___3",
  "Events": [
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "VersionLabel": "Sample Application",
      "Severity": "INFO",
      "RequestId": "51717cc0-c0ab-11e4-8956-c1c4d272c950",
      "Message": "createApplicationVersion completed successfully.",
      "EventDate": "2015-03-02T07:11:16.974Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "VersionLabel": "Sample Application",
      "Severity": "INFO",
      "RequestId": "51717cc0-c0ab-11e4-8956-c1c4d272c950",
      "Message": "Created new Application Version: Sample Application",
      "EventDate": "2015-03-02T07:11:16.841Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "VersionLabel": "Sample Application",
      "Severity": "INFO",
      "RequestId": "51717cc0-c0ab-11e4-8956-c1c4d272c950",
      "Message": "createApplicationVersion is starting.",
      "EventDate": "2015-03-02T07:11:16.751Z"
    }
  ]
}

4. 最初のリリース

4.1. environment名の決定

コマンド
EB_ENV_NAME='Default-Environment'

4.2. environmentの起動

Environmentの存在確認 (describe-environments)

コマンド
aws elasticbeanstalk describe-environments \
-application-name "${EB_APP_NAME}" \
-environment-names "${EB_ENV_NAME}"
結果
{
    "Environments": []
}

environmentの起動 (create-environment)

変数の確認
cat << ETX

EB_APP_NAME: "${EB_APP_NAME}"
EB_ENV_NAME: ${EB_ENV_NAME}
EB_VER_LABEL: "${EB_VER_LABEL}"
EB_ENV_SOL: "${EB_ENV_SOL}"

ETX
コマンド
aws elasticbeanstalk create-environment \
-application-name "${EB_APP_NAME}" \
-environment-name ${EB_ENV_NAME} \
-version-label "${EB_VER_LABEL}" \
-solution-stack-name "${EB_ENV_SOL}"
結果(例)
{
  "ApplicationName": "My First Elastic Beanstalk Application",
  "EnvironmentName": "Default-Environment",
  "VersionLabel": "Sample Application",
  "Status": "Launching",
  "EnvironmentId": "e-pm2m8tsyuc",
  "SolutionStackName": "64bit Amazon Linux 2014.09 v1.2.0 running PHP 5.5",
  "Health": "Grey",
  "Tier": {
    "Version": " ",
    "Type": "Standard",
    "Name": "WebServer"
  },
  "DateUpdated": "2015-03-02T07:15:58.576Z",
  "DateCreated": "2015-03-02T07:15:58.576Z"
}

Environment IDの取得 (describe-environments)

コマンド
EB_ENV_ID=`aws elasticbeanstalk describe-environments --application-name "${EB_APP_NAME}" --environment-names "${EB_ENV_NAME}" --query 'Environments[].EnvironmentId' --output text` \
&& echo ${EB_ENV_ID}
結果(例)
e-xxxxxxxxxx

ノート: Environmentは、Environment IDとEnvironment Nameの2つで特定で
きますが 、ここではなるべくEnvironment IDを利用するようにします。

Environmentのステータス確認 (describe-environments)

コマンド
EB_ENV_STATUS=`aws elasticbeanstalk describe-environments --application-name "${EB_APP_NAME}" --environment-ids "${EB_ENV_ID}" --query 'Environments[].Status' --output text` \
&& echo ${EB_ENV_STATUS}
結果
Ready

ノート: Readyになるまで、おおむね5分程度かかるようです。

4.3. environmentの確認

URLの取得

コマンド
EB_CNAME_URL=`aws elasticbeanstalk describe-environments --application-name "${EB_APP_NAME}" --environment-names "${EB_ENV_NAME}" --query 'Environments[].CNAME' --output text` \
&& echo ${EB_CNAME_URL}
結果(例)
Default-Environment-xxxxxxxxxxxx.elasticbeanstalk.com

アクセス確認

ブラウザでアクセスして、アプリケーションが表示されることを確認しましょ
う。

イベント確認 (describe-events)

コマンド
EB_MAX_ITEMS='16'
コマンド
aws elasticbeanstalk describe-events \
-application-name "${EB_APP_NAME}" \
-environment-name ${EB_ENV_NAME} \
-max-items ${EB_MAX_ITEMS}
結果(例)
{
  "NextToken": "None___16",
  "Events": [
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Message": "Adding instance 'i-6d5eb760' to your environment.",
      "EventDate": "2015-03-02T07:19:19.776Z",
      "Severity": "INFO"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Successfully launched environment: Default-Environment",
      "EventDate": "2015-03-02T07:19:13.046Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Application available at Default-Environment-dy6a8ifwuv.elasticbeanstalk.com.",
      "EventDate": "2015-03-02T07:19:12.786Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Message": "Added EC2 instance 'i-6d5eb760' to Auto Scaling Group 'awseb-e-pm2m8tsyuc-stack-AWSEBAutoScalingGroup-1FL6R7WEIXQE1'.",
      "EventDate": "2015-03-02T07:19:10.942Z",
      "Severity": "INFO"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Created CloudWatch alarm named: awseb-e-pm2m8tsyuc-stack-AWSEBCloudwatchAlarmHigh-CLNQSP4AHG1J",
      "EventDate": "2015-03-02T07:17:58.665Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Created CloudWatch alarm named: awseb-e-pm2m8tsyuc-stack-AWSEBCloudwatchAlarmLow-1RM59RCZ9QV4H",
      "EventDate": "2015-03-02T07:17:58.364Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Created Auto Scaling group policy named: arn:aws:autoscaling:us-west-2:XXXXXXXXXXXX:scalingPolicy:332d7aa6-c84d-497d-a4ed-fb8c5a1389e2:autoScalingGroupName/awseb-e-pm2m8tsyuc-stack-AWSEBAutoScalingGroup-1FL6R7WEIXQE1:policyName/awseb-e-pm2m8tsyuc-stack-AWSEBAutoScalingScaleDownPolicy-92IEAFZFDKNJ",
      "EventDate": "2015-03-02T07:17:55.420Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Created Auto Scaling group policy named: arn:aws:autoscaling:us-west-2:XXXXXXXXXXXX:scalingPolicy:6b5fbcd5-111d-47bb-bb1d-27d84eb75906:autoScalingGroupName/awseb-e-pm2m8tsyuc-stack-AWSEBAutoScalingGroup-1FL6R7WEIXQE1:policyName/awseb-e-pm2m8tsyuc-stack-AWSEBAutoScalingScaleUpPolicy-1UIJ44XP4FQGY",
      "EventDate": "2015-03-02T07:17:55.392Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Created Auto Scaling group named: awseb-e-pm2m8tsyuc-stack-AWSEBAutoScalingGroup-1FL6R7WEIXQE1",
      "EventDate": "2015-03-02T07:17:52.322Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Waiting for EC2 instances to launch. This may take a few minutes.",
      "EventDate": "2015-03-02T07:17:52.322Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Created Auto Scaling launch configuration named: awseb-e-pm2m8tsyuc-stack-AWSEBAutoScalingLaunchConfiguration-1ATRW47YSHDS9",
      "EventDate": "2015-03-02T07:16:56.233Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Created security group named: awseb-e-pm2m8tsyuc-stack-AWSEBSecurityGroup-A21GRYC1XDZR",
      "EventDate": "2015-03-02T07:16:53.125Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Created load balancer named: awseb-e-p-AWSEBLoa-1JIB95ZPILT5G",
      "EventDate": "2015-03-02T07:16:32.658Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Created security group named: sg-ee7e518b",
      "EventDate": "2015-03-02T07:16:27.721Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "Using elasticbeanstalk-us-west-2-XXXXXXXXXXXX as Amazon S3 storage bucket for environment data.",
      "EventDate": "2015-03-02T07:15:58.946Z"
    },
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "Severity": "INFO",
      "RequestId": "f8d88fb4-c0ab-11e4-80cd-074970c6fc64",
      "Message": "createEnvironment is starting.",
      "EventDate": "2015-03-02T07:15:57.865Z"
    }
  ]
}

5. リソースの確認

5.1. configuration-settingsの確認 (describe-configuration-settings)

コマンド
aws elasticbeanstalk describe-configuration-settings \
-application-name "${EB_APP_NAME}" \
-environment-name ${EB_ENV_NAME}
結果(例)
{
  "ConfigurationSettings": [
    {
      "ApplicationName": "My First Elastic Beanstalk Application",
      "EnvironmentName": "Default-Environment",
      "DeploymentStatus": "deployed",
      "DateCreated": "2015-03-02T07:15:57Z",
      "OptionSettings": [
        {
          "OptionName": "document_root",
          "Namespace": "aws:elasticbeanstalk:container:php:phpini"
        },
        {
          "OptionName": "AWS_SECRET_KEY",
          "Namespace": "aws:elasticbeanstalk:application:environment",
          "Value": null
        },
        {
          "OptionName": "AppSource",
          "Namespace": "aws:cloudformation:template:parameter",
          "Value": "http://s3-us-west-2.amazonaws.com/elasticbeanstalk-samples-us-west-2/php-newsample-app.zip"
        },
        {
          "OptionName": "AWS_ACCESS_KEY_ID",
          "Namespace": "aws:elasticbeanstalk:application:environment",
          "Value": null
        },
        {
          "OptionName": "composer_options",
          "Namespace": "aws:elasticbeanstalk:container:php:phpini"
        },
        {
          "OptionName": "zlib.output_compression",
          "Namespace": "aws:elasticbeanstalk:container:php:phpini",
          "Value": "Off"
        },
        {
          "OptionName": "memory_limit",
          "Namespace": "aws:elasticbeanstalk:container:php:phpini",
          "Value": "256M"
        },
        {
          "OptionName": "PARAM1",
          "Namespace": "aws:elasticbeanstalk:application:environment",
          "Value": null
        },
        {
          "OptionName": "PARAM2",
          "Namespace": "aws:elasticbeanstalk:application:environment",
          "Value": null
        },
        {
          "OptionName": "InstancePort",
          "Namespace": "aws:cloudformation:template:parameter",
          "Value": "80"
        },
        {
          "OptionName": "allow_url_fopen",
          "Namespace": "aws:elasticbeanstalk:container:php:phpini",
          "Value": "On"
        },
        {
          "OptionName": "PARAM4",
          "Namespace": "aws:elasticbeanstalk:application:environment",
          "Value": null
        },
        {
          "OptionName": "PARAM3",
          "Namespace": "aws:elasticbeanstalk:application:environment",
          "Value": null
        },
        {
          "OptionName": "EnvironmentVariables",
          "Namespace": "aws:cloudformation:template:parameter",
          "Value": "PARAM3=,PARAM4=,PARAM1=,PARAM2=,PARAM5=,AWS_SECRET_KEY=,AWS_ACCESS_KEY_ID="
        },
        {
          "OptionName": "PARAM5",
          "Namespace": "aws:elasticbeanstalk:application:environment",
          "Value": null
        },
        {
          "OptionName": "HooksPkgUrl",
          "Namespace": "aws:cloudformation:template:parameter",
          "Value": "https://s3-us-west-2.amazonaws.com/elasticbeanstalk-env-resources-us-west-2/stalks/eb_php_3.11.1/lib/assets.tar.gz"
        },
        {
          "OptionName": "LogPublicationControl",
          "Namespace": "aws:elasticbeanstalk:hostmanager",
          "Value": "false"
        },
        {
          "OptionName": "max_execution_time",
          "Namespace": "aws:elasticbeanstalk:container:php:phpini",
          "Value": "60"
        },
        {
          "OptionName": "InstanceType",
          "Namespace": "aws:autoscaling:launchconfiguration",
          "Value": "t1.micro"
        },
        {
          "OptionName": "display_errors",
          "Namespace": "aws:elasticbeanstalk:container:php:phpini",
          "Value": "Off"
        },
        {
          "OptionName": "ELBScheme",
          "Namespace": "aws:ec2:vpc",
          "Value": "public"
        },
        {
          "OptionName": "ConnectionDrainingTimeout",
          "Namespace": "aws:elb:policies",
          "Value": "20"
        },
        {
          "OptionName": "Interval",
          "Namespace": "aws:elb:healthcheck",
          "Value": "30"
        },
        {
          "OptionName": "LoadBalancerPortProtocol",
          "Namespace": "aws:elb:loadbalancer",
          "Value": "HTTP"
        },
        {
          "OptionName": "Stickiness Policy",
          "Namespace": "aws:elb:policies",
          "Value": "false"
        },
        {
          "OptionName": "UnhealthyThreshold",
          "Namespace": "aws:elb:healthcheck",
          "Value": "5"
        },
        {
          "OptionName": "Target",
          "Namespace": "aws:elb:healthcheck",
          "Value": "TCP:80"
        },
        {
          "OptionName": "ConnectionSettingIdleTimeout",
          "Namespace": "aws:elb:policies",
          "Value": "60"
        },
        {
          "OptionName": "Stickiness Cookie Expiration",
          "Namespace": "aws:elb:policies",
          "Value": "0"
        },
        {
          "OptionName": "Timeout",
          "Namespace": "aws:elb:healthcheck",
          "Value": "5"
        },
        {
          "OptionName": "SSLCertificateId",
          "Namespace": "aws:elb:loadbalancer"
        },
        {
          "OptionName": "LoadBalancerSSLPortProtocol",
          "Namespace": "aws:elb:loadbalancer",
          "Value": "HTTPS"
        },
        {
          "OptionName": "ELBSubnets",
          "Namespace": "aws:ec2:vpc"
        },
        {
          "OptionName": "LoadBalancerHTTPPort",
          "Namespace": "aws:elb:loadbalancer",
          "Value": "80"
        },
        {
          "OptionName": "HealthyThreshold",
          "Namespace": "aws:elb:healthcheck",
          "Value": "3"
        },
        {
          "OptionName": "ConnectionDrainingEnabled",
          "Namespace": "aws:elb:policies",
          "Value": "false"
        },
        {
          "OptionName": "LoadBalancerHTTPSPort",
          "Namespace": "aws:elb:loadbalancer",
          "Value": "OFF"
        },
        {
          "OptionName": "CrossZone",
          "Namespace": "aws:elb:loadbalancer",
          "Value": "false"
        },
        {
          "OptionName": "ImageId",
          "Namespace": "aws:autoscaling:launchconfiguration",
          "Value": "ami-2bc1981b"
        },
        {
          "OptionName": "MonitoringInterval",
          "Namespace": "aws:autoscaling:launchconfiguration",
          "Value": "5 minute"
        },
        {
          "OptionName": "SecurityGroups",
          "Namespace": "aws:autoscaling:launchconfiguration",
          "Value": "awseb-e-pm2m8tsyuc-stack-AWSEBSecurityGroup-A21GRYC1XDZR"
        },
        {
          "OptionName": "AssociatePublicIpAddress",
          "Namespace": "aws:ec2:vpc"
        },
        {
          "OptionName": "RootVolumeIOPS",
          "Namespace": "aws:autoscaling:launchconfiguration"
        },
        {
          "OptionName": "EC2KeyName",
          "Namespace": "aws:autoscaling:launchconfiguration"
        },
        {
          "OptionName": "BlockDeviceMappings",
          "Namespace": "aws:autoscaling:launchconfiguration"
        },
        {
          "OptionName": "RootVolumeType",
          "Namespace": "aws:autoscaling:launchconfiguration"
        },
        {
          "OptionName": "RootVolumeSize",
          "Namespace": "aws:autoscaling:launchconfiguration"
        },
        {
          "OptionName": "IamInstanceProfile",
          "Namespace": "aws:autoscaling:launchconfiguration"
        },
        {
          "OptionName": "MaxSize",
          "Namespace": "aws:autoscaling:asg",
          "Value": "4"
        },
        {
          "OptionName": "Cooldown",
          "Namespace": "aws:autoscaling:asg",
          "Value": "360"
        },
        {
          "OptionName": "MinSize",
          "Namespace": "aws:autoscaling:asg",
          "Value": "1"
        },
        {
          "OptionName": "Subnets",
          "Namespace": "aws:ec2:vpc"
        },
        {
          "OptionName": "RollingUpdateEnabled",
          "Namespace": "aws:autoscaling:updatepolicy:rollingupdate",
          "Value": "false"
        },
        {
          "OptionName": "Availability Zones",
          "Namespace": "aws:autoscaling:asg",
          "Value": "Any"
        },
        {
          "OptionName": "MinInstancesInService",
          "Namespace": "aws:autoscaling:updatepolicy:rollingupdate"
        },
        {
          "OptionName": "Timeout",
          "Namespace": "aws:autoscaling:updatepolicy:rollingupdate",
          "Value": "PT30M"
        },
        {
          "OptionName": "RollingUpdateType",
          "Namespace": "aws:autoscaling:updatepolicy:rollingupdate",
          "Value": "Time"
        },
        {
          "OptionName": "PauseTime",
          "Namespace": "aws:autoscaling:updatepolicy:rollingupdate"
        },
        {
          "OptionName": "MaxBatchSize",
          "Namespace": "aws:autoscaling:updatepolicy:rollingupdate"
        },
        {
          "OptionName": "Custom Availability Zones",
          "Namespace": "aws:autoscaling:asg",
          "Value": null
        },
        {
          "OptionName": "VPCId",
          "Namespace": "aws:ec2:vpc"
        },
        {
          "OptionName": "UpperThreshold",
          "Namespace": "aws:autoscaling:trigger",
          "Value": "6000000"
        },
        {
          "OptionName": "Period",
          "Namespace": "aws:autoscaling:trigger",
          "Value": "5"
        },
        {
          "OptionName": "Statistic",
          "Namespace": "aws:autoscaling:trigger",
          "Value": "Average"
        },
        {
          "OptionName": "MeasureName",
          "Namespace": "aws:autoscaling:trigger",
          "Value": "NetworkOut"
        },
        {
          "OptionName": "LowerThreshold",
          "Namespace": "aws:autoscaling:trigger",
          "Value": "2000000"
        },
        {
          "OptionName": "EvaluationPeriods",
          "Namespace": "aws:autoscaling:trigger",
          "Value": "1"
        },
        {
          "OptionName": "BreachDuration",
          "Namespace": "aws:autoscaling:trigger",
          "Value": "5"
        },
        {
          "OptionName": "Unit",
          "Namespace": "aws:autoscaling:trigger",
          "Value": "Bytes"
        },
        {
          "OptionName": "LowerBreachScaleIncrement",
          "Namespace": "aws:autoscaling:trigger",
          "Value": "-1"
        },
        {
          "OptionName": "UpperBreachScaleIncrement",
          "Namespace": "aws:autoscaling:trigger",
          "Value": "1"
        },
        {
          "OptionName": "RollbackLaunchOnFailure",
          "Namespace": "aws:elasticbeanstalk:control",
          "Value": "false"
        },
        {
          "OptionName": "LaunchTimeout",
          "Namespace": "aws:elasticbeanstalk:control",
          "Value": "0"
        },
        {
          "OptionName": "DefaultSSHPort",
          "Namespace": "aws:elasticbeanstalk:control",
          "Value": "22"
        },
        {
          "OptionName": "EnvironmentType",
          "Namespace": "aws:elasticbeanstalk:environment",
          "Value": "LoadBalanced"
        },
        {
          "OptionName": "LaunchType",
          "Namespace": "aws:elasticbeanstalk:control",
          "Value": "Migration"
        },
        {
          "OptionName": "Automatically Terminate Unhealthy Instances",
          "Namespace": "aws:elasticbeanstalk:monitoring",
          "Value": "true"
        },
        {
          "OptionName": "Notification Topic Name",
          "Namespace": "aws:elasticbeanstalk:sns:topics"
        },
        {
          "OptionName": "Timeout",
          "Namespace": "aws:elasticbeanstalk:command",
          "Value": "600"
        },
        {
          "OptionName": "Notification Endpoint",
          "Namespace": "aws:elasticbeanstalk:sns:topics"
        },
        {
          "OptionName": "BatchSizeType",
          "Namespace": "aws:elasticbeanstalk:command",
          "Value": "Percentage"
        },
        {
          "OptionName": "Application Healthcheck URL",
          "Namespace": "aws:elasticbeanstalk:application",
          "Value": null
        },
        {
          "OptionName": "SSHSourceRestriction",
          "Namespace": "aws:autoscaling:launchconfiguration",
          "Value": "tcp,22,22,0.0.0.0/0"
        },
        {
          "OptionName": "Notification Topic ARN",
          "Namespace": "aws:elasticbeanstalk:sns:topics"
        },
        {
          "OptionName": "BatchSize",
          "Namespace": "aws:elasticbeanstalk:command",
          "Value": "100"
        },
        {
          "OptionName": "Notification Protocol",
          "Namespace": "aws:elasticbeanstalk:sns:topics",
          "Value": "email"
        }
      ],
      "DateUpdated": "2015-03-02T07:26:41Z",
      "SolutionStackName": "64bit Amazon Linux 2014.09 v1.2.0 running PHP 5.5"
    }
  ]
}

5.2. Environmentのリソース確認 (describe-environment-resources)

コマンド
aws elasticbeanstalk describe-environment-resources \
-environment-id ${EB_ENV_ID}
結果(例)
{
  "EnvironmentResources": {
    "EnvironmentName": "Default-Environment",
    "AutoScalingGroups": [
      {
        "Name": "awseb-e-mvmwrxyipz-stack-AWSEBAutoScalingGroup-xxxxxxxxxxxxx"
      }
    ],
    "Triggers": [],
    "LoadBalancers": [
      {
        "Name": "awseb-e-m-AWSEBLoa-xxxxxxxxxxxx"
      }
    ],
    "Queues": [],
    "Instances": [
      {
        "Id": "i-xxxxxxxx"
      }
    ],
    "LaunchConfigurations": [
      {
        "Name": "awseb-e-mvmwrxyipz-stack-AWSEBAutoScalingLaunchConfiguration-xxxxxxxxxxxxx"
      }
    ]
  }
}

完了

続いて、アプリケーションの更新をしてみましょう。

4
6
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
6