Amazon Web Services Update | London
November 2012
Quickly deploy and manage apps in AWS…
Elastic Bean Stalk
Application package is deployed into Beanstalk
Elastic Bean Stalk
User Application
Application Service
HTTP Service
Language Interpreter
Operating System
Host
Which creates the container in EC2
Elastic Bean Stalk
Beanstalk takes care of the environment…
Elastic Bean Stalk
…adding Elastic Load Balancer…
Elastic Bean Stalk
…Auto Scaling groups
Elastic Bean Stalk
…and launching instances
Elastic Bean Stalk
…all wired into the Beanstalk framework
Elastic Bean Stalk
…and published under a CNAME
Elastic Bean Stalk
…with logs and app versions held in S3
Elastic Bean Stalk
What about the container?
…into a range of containers
.Net Java
Elastic Bean Stalk
PHP
Adding new containers…
Ruby + Python
Elastic Bean Stalk
User Application
Application Service
HTTP Service
Language Interpreter
Operating System
Host
Containers…
Elastic Bean Stalk
User Application
Application Service
Apache
Python
Operating System
Host
mod_wsgi
…Python mod-wsgi & apache
Elastic Bean Stalk
…Python mod-wsgi & apache
Elastic Bean Stalk
Flask==0.9
requirements.txt
Django==1.4.1
User Application
Application Service
HTTP Service
Language Interpreter
Operating System
Host
Containers…
Elastic Bean Stalk
User Application
Application Service
Nginx
Ruby
Operating System
Host
Passenger & Nginx…
Elastic Bean Stalk
passenger
Passenger & Nginx…
Elastic Bean Stalk
Classic rails MVC Bare-metal routes (non-MVC)
What about the data?
D.I.Y
Adding new containers…
Ruby + Python + Java
Elastic Bean Stalk
Adding new containers…
Ruby + Python + Java
Elastic Bean Stalk
RDS
Option to create RDS at
application launch:
String dbName =
System.getProperty("RDS_DB_NAME");
String userName = System.getProperty("RDS_USERNAME");
String password = System.getProperty("RDS_PASSWORD");
String hostname = System.getProperty("RDS_HOSTNAME");
String port = System.getProperty("RDS_PORT");
Grab connection details for use:
import os
if 'RDS_HOSTNAME' in os.environ:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ['RDS_DB_NAME'],
'USER': os.environ['RDS_USER'],
'PASSWORD’: os.environ['RDS_PASSWORD'],
'HOST': os.environ['RDS_HOSTNAME'],
'PORT': os.environ['RDS_PORT'],
}
}
Grab connection details from os.environ’s
commands:
syncdb:
command: "django-admin.py syncdb --noinput"
leader_only: true
option_settings:
"aws:elasticbeanstalk:application:python:environment":
DJANGO_SETTINGS_MODULE: "mysite.settings"
"aws:elasticbeanstalk:container:python":
WSGIPath: "mysite/wsgi.py"
Add “.ebextensions” directory Add “python.config” file
commands:
syncdb:
command: "django-admin.py syncdb --noinput"
leader_only: true
option_settings:
"aws:elasticbeanstalk:application:python:environment":
DJANGO_SETTINGS_MODULE: "mysite.settings"
"aws:elasticbeanstalk:container:python":
WSGIPath: "mysite/wsgi.py"
RDS populated from Django model (use Django Evolution etc to upate when model changes)
production:
adapter: mysql2
encoding: utf8
database: <%= ENV['RDS_DB_NAME'] %>
username: <%= ENV['RDS_USERNAME'] %>
password: <%= ENV['RDS_PASSWORD'] %>
host: <%= ENV['RDS_HOSTNAME'] %>
port: <%= ENV['RDS_PORT'] %>
Update database.yml to include generated RDS details:
# Configure third-party service credentials
# Run rake tasks before an application deployment
container_commands:
01deploy:
command: rake my_deployment_tasks
# in environment variables:
option_settings:
- option_name: AIRBRAKE_API_KEY
value: MYAPIKEY
Add “.ebextensions” directory Add “.config” file
# Configure third-party service credentials
# Run rake tasks before an application deployment
container_commands:
01deploy:
command: rake my_deployment_tasks
# in environment variables:
option_settings:
- option_name: AIRBRAKE_API_KEY
value: MYAPIKEY
RDS populated from rails model
Rails
Django
Git Beanstalk
rake
syncdb
RDS
Container config
Language/versions
Git Beanstalk
.ebextensions
Configuration/commands
RDS
Java, Python & Ruby container configuration
.ebextensions
packages Download and install pre-packaged applications and components using apt, yum,
rubygems, python, and rpm
sources Download an archive file and unpack it in a target directory on the EC2 instance
(e.g from S3). Supported formats are tar, tar+gzip, tar+bz2 and zip
files Create files on the EC2 instance
Users/groups Create Linux/UNIX users/groups on the EC2 instance
Java, Python & Ruby container configuration
.ebextensions
packages Download and install pre-packaged applications and components using apt, yum,
rubygems, python, and rpm
sources Download an archive file and unpack it in a target directory on the EC2 instance
(e.g from S3). Supported formats are tar, tar+gzip, tar+bz2 and zip
files Create files on the EC2 instance
Users/groups Create Linux/UNIX users/groups on the EC2 instance
packages:
yum:
package1: [3.2.1]
package2: [1.0]
rpm:
package3
Java, Python & Ruby container configuration
.ebextensions
packages Download and install pre-packaged applications and components using apt, yum,
rubygems, python, and rpm
sources Download an archive file and unpack it in a target directory on the EC2 instance
(e.g from S3). Supported formats are tar, tar+gzip, tar+bz2 and zip
files Create files on the EC2 instance
Users/groups Create Linux/UNIX users/groups on the EC2 instance
sources:
/home/myfiles:
https://s3.amazonaws.com/bucket/myf
iles.zip
Java, Python & Ruby container configuration
.ebextensions
packages Download and install pre-packaged applications and components using apt, yum,
rubygems, python, and rpm
sources Download an archive file and unpack it in a target directory on the EC2 instance
(e.g from S3). Supported formats are tar, tar+gzip, tar+bz2 and zip
files Create files on the EC2 instance
Users/groups Create Linux/UNIX users/groups on the EC2 instance
files:
“/home/ec2-user/myfile” :
mode: "000777"
owner: ec2-user
group: ec2-user
source: http://foo.bar/myfile
“/home/ec2-user/myfile2” :
mode: “000777”
owner: ec2-user
group: ec2-user
content: |
# this is my file
# with content
Java, Python & Ruby container configuration
.ebextensions
packages Download and install pre-packaged applications and components using apt, yum,
rubygems, python, and rpm
sources Download an archive file and unpack it in a target directory on the EC2 instance
(e.g from S3). Supported formats are tar, tar+gzip, tar+bz2 and zip
files Create files on the EC2 instance
Users/groups Create Linux/UNIX users/groups on the EC2 instance
users:
- myuser :
groups:
- group1
- group2
uid: 50
homedir: “/tmp”
groups:
- group1 : 45
- group2 : 99
- group3
Java, Python & Ruby container configuration
.ebextensions
command Execute commands on the EC2 instance
container_commands Execute commands for your container
services Define which services should be started or stopped when the instance is launched
including dependencies that require Beanstalk to execute a restart
option_settings Define container settings that get passed in as environment variables on your
Amazon EC2 instances
Java, Python & Ruby container configuration
.ebextensions
command Execute commands on the EC2 instance
container_commands Execute commands for your container
services Define which services should be started or stopped when the instance is launched
including dependencies that require Beanstalk to execute a restart
option_settings Define container settings that get passed in as environment variables on your
Amazon EC2 instances
commands:
myscript:
command: myscript.py
cwd: /home/ec2-user
env:
a: b
Java, Python & Ruby container configuration
.ebextensions
command Execute commands on the EC2 instance
container_commands Execute commands for your container
services Define which services should be started or stopped when the instance is launched
including dependencies that require Beanstalk to execute a restart
option_settings Define container settings that get passed in as environment variables on your
Amazon EC2 instances
container_commands:
replace-config-label:
command: cp
.ebextensions/server.xml
/etc/tomcat7/server.xml
Java, Python & Ruby container configuration
.ebextensions
command Execute commands on the EC2 instance
container_commands Execute commands for your container
services Define which services should be started or stopped when the instance is launched
including dependencies that require Beanstalk to execute a restart
option_settings Define container settings that get passed in as environment variables on your
Amazon EC2 instances
services:
sysvinit:
- myservice:
enabled: true
ensureRunning: true
Java, Python & Ruby container configuration
.ebextensions
command Execute commands on the EC2 instance
container_commands Execute commands for your container
services Define which services should be started or stopped when the instance is launched
including dependencies that require Beanstalk to execute a restart
option_settings Define container settings that get passed in as environment variables on your
Amazon EC2 instances
option_settings:
- namespace:
aws:elasticbeanstalk:container:tom
cat:jvmoptions
option_name: Xmx
value: 256m
- option_name: AWS_SECRET_KEY
value:
wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAM
PLEKEY
- option_name: AWS_ACCESS_KEY_ID
value: AKIAIOSFODNN7EXAMPLE
VPC
Deploy apps inside a Virtual Private Cloud
Elastic Bean Stalk
Launch apps into a VPC
Launch “private”
applications
Deeper networking
control
Additional required options
Elastic Bean Stalk
VPCId Contains the ID of the VPC
Subnets Contains the ID of the Auto Scaling group subnet
ELBSubnets Contains the ID of the subnet for the elastic load
balancer
SecurityGroups Contains the ID of the security group.
VPC ID
VPC ID
Auto-scaling subnet
VPC ID
Auto-scaling subnet
ELBSubnet
Summary
New Python & Ruby containers Beanstalk integrates with RDS
Beanstalk in VPC
http://aws.amazon.com/elasticbeanstalk
Top Related