ruk·si

☁️ AWS
Setup Elastic Beanstalk

Updated at 2015-10-02 11:46

Elastic Beanstalk application consists of the application, version and configuration; where environment is a version + configuration pairing.

Elastic Beanstalk:
    Application
    Version
    Configuration

Environment = Version + Configuration

This checklist guides how to create basic Elastic Beanstalk application.

  1. Create New Application, top right in the AWS EB console.
    1. Application Info
      Application Name: App Name
      
    2. Environment Type
      Environment tier:           Web Server
      Predefined configuration:   PHP
      Environment type:           Load balancing, auto scaling
      
    3. Application Version
      Source: Upload your own
          zip a root of the project with "index.php"
      
    4. Environment Information
      Environment name:   appname-env
      Environment URL:    appname-env.elasticbeanstalk.com
      
    5. Additional Resources
      Create an RDS DB Instance with this environment
          If you require MySQL or PostgreSQL.
          Use multi-AZ, SSD and max 1 day backup period for production.
      Create this environment inside a VPC
          If you require Amazon Virtual Private Cloud functionality.
      Edit the security group that was created by for the app.
          Inbound:
              Custom TCP:     5432:   */32    # http://checkip.amazonaws.com/
              HTTP/HTTPS:             0.0.0.0/0
      
    6. Configuration Details
      Instance type:  t2.micro (~$7/month each)
      EC2 key pair:   appname-eb-key-pair-us-west-1
          (Created in EC2 console)
      Application health check URL:
          If you want to check non-root URL for application health.
      Instance profile: appname-eb-role
          (Created in IAM Management Console)
              Create New Role
              Role Name:      appname-eb-role
              Role Type:      Amazon EC2
              Permissions:    No Permissions
      
  2. After the definition:
    Navigate to http://appname-env.elasticbeanstalk.com/
    
  3. Using Domain hosted by a third party:
    1. Create a CNAME for your www record that maps to appname-env.elasticbeanstalk.com.
    2. Forward example.com to www.example.com.
  4. Using a Domain Hosted by Amazon Route 53:
    1. Find Load Balancer.
      Get instance ID:    i-456c32b7
      Hosted Zone ID:     Z215RUKSI1TBD5
      

Optional:

  1. You should define environmental variables for AWS secret etc.
  2. You should deploy using the eb command line tool:
    eb deploy appname-env
    
  3. You can specify auto-scaling:
    Environment type:       Load balanced, auto scaling
    Number of instances:    2 - 5
    Scale based on:         Average network out
    Add instance when:      > 6 000 000
    Remove instance when:   > 2 000 000
    
  4. If the defining as a worker, attach SQS queue using the EB dashboard.

Sources

  • AWS in Action, Michael Wittig and Andreas Wittig