AWS Update | London - Elastic Beanstalk

53
Amazon Web Services Update | London November 2012

description

We are excited to continue our work on BeanStalk with the introduction of a range of great new features. If you are a Python shop you'll learn how BeanStalk now supports Python containers and the Django and Flask frameworks. Hear about BeanStalk integration with RDS and how custom configuration of containers is possible through simple configuration files.

Transcript of AWS Update | London - Elastic Beanstalk

Page 1: AWS Update | London - Elastic Beanstalk

Amazon Web Services Update | London

November 2012

Page 2: AWS Update | London - Elastic Beanstalk

Quickly deploy and manage apps in AWS…

Elastic Bean Stalk

Page 3: AWS Update | London - Elastic Beanstalk

Application package is deployed into Beanstalk

Elastic Bean Stalk

Page 4: AWS Update | London - Elastic Beanstalk

User Application

Application Service

HTTP Service

Language Interpreter

Operating System

Host

Which creates the container in EC2

Elastic Bean Stalk

Page 5: AWS Update | London - Elastic Beanstalk

Beanstalk takes care of the environment…

Elastic Bean Stalk

Page 6: AWS Update | London - Elastic Beanstalk

…adding Elastic Load Balancer…

Elastic Bean Stalk

Page 7: AWS Update | London - Elastic Beanstalk

…Auto Scaling groups

Elastic Bean Stalk

Page 8: AWS Update | London - Elastic Beanstalk

…and launching instances

Elastic Bean Stalk

Page 9: AWS Update | London - Elastic Beanstalk

…all wired into the Beanstalk framework

Elastic Bean Stalk

Page 10: AWS Update | London - Elastic Beanstalk

…and published under a CNAME

Elastic Bean Stalk

Page 11: AWS Update | London - Elastic Beanstalk

…with logs and app versions held in S3

Elastic Bean Stalk

Page 12: AWS Update | London - Elastic Beanstalk

What about the container?

Page 13: AWS Update | London - Elastic Beanstalk

…into a range of containers

.Net Java

Elastic Bean Stalk

PHP

Page 14: AWS Update | London - Elastic Beanstalk

Adding new containers…

Ruby + Python

Elastic Bean Stalk

Page 15: AWS Update | London - Elastic Beanstalk

User Application

Application Service

HTTP Service

Language Interpreter

Operating System

Host

Containers…

Elastic Bean Stalk

Page 16: AWS Update | London - Elastic Beanstalk

User Application

Application Service

Apache

Python

Operating System

Host

mod_wsgi

…Python mod-wsgi & apache

Elastic Bean Stalk

Page 17: AWS Update | London - Elastic Beanstalk

…Python mod-wsgi & apache

Elastic Bean Stalk

Flask==0.9

requirements.txt

Django==1.4.1

Page 18: AWS Update | London - Elastic Beanstalk

User Application

Application Service

HTTP Service

Language Interpreter

Operating System

Host

Containers…

Elastic Bean Stalk

Page 19: AWS Update | London - Elastic Beanstalk

User Application

Application Service

Nginx

Ruby

Operating System

Host

Passenger & Nginx…

Elastic Bean Stalk

passenger

Page 20: AWS Update | London - Elastic Beanstalk

Passenger & Nginx…

Elastic Bean Stalk

Classic rails MVC Bare-metal routes (non-MVC)

Page 21: AWS Update | London - Elastic Beanstalk

What about the data?

Page 22: AWS Update | London - Elastic Beanstalk
Page 23: AWS Update | London - Elastic Beanstalk

D.I.Y

Page 24: AWS Update | London - Elastic Beanstalk

Adding new containers…

Ruby + Python + Java

Elastic Bean Stalk

Page 25: AWS Update | London - Elastic Beanstalk

Adding new containers…

Ruby + Python + Java

Elastic Bean Stalk

RDS

Page 26: AWS Update | London - Elastic Beanstalk

Option to create RDS at

application launch:

Page 27: AWS Update | London - Elastic Beanstalk

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:

Page 28: AWS Update | London - Elastic Beanstalk

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

Page 29: AWS Update | London - Elastic Beanstalk

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

Page 30: AWS Update | London - Elastic Beanstalk

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)

Page 31: AWS Update | London - Elastic Beanstalk

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:

Page 32: AWS Update | London - Elastic Beanstalk

# 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

Page 33: AWS Update | London - Elastic Beanstalk

# 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

Page 34: AWS Update | London - Elastic Beanstalk

Rails

Django

Git Beanstalk

rake

syncdb

RDS

Page 35: AWS Update | London - Elastic Beanstalk

Container config

Language/versions

Git Beanstalk

.ebextensions

Configuration/commands

RDS

Page 36: AWS Update | London - Elastic Beanstalk

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

Page 37: AWS Update | London - Elastic Beanstalk

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

Page 38: AWS Update | London - Elastic Beanstalk

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

Page 39: AWS Update | London - Elastic Beanstalk

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

Page 40: AWS Update | London - Elastic Beanstalk

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

Page 41: AWS Update | London - Elastic Beanstalk

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

Page 42: AWS Update | London - Elastic Beanstalk

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

Page 43: AWS Update | London - Elastic Beanstalk

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

Page 44: AWS Update | London - Elastic Beanstalk

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

Page 45: AWS Update | London - Elastic Beanstalk

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

Page 46: AWS Update | London - Elastic Beanstalk

VPC

Page 47: AWS Update | London - Elastic Beanstalk

Deploy apps inside a Virtual Private Cloud

Elastic Bean Stalk

Launch apps into a VPC

Launch “private”

applications

Deeper networking

control

Page 48: AWS Update | London - Elastic Beanstalk

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.

Page 49: AWS Update | London - Elastic Beanstalk

VPC ID

Page 50: AWS Update | London - Elastic Beanstalk

VPC ID

Auto-scaling subnet

Page 51: AWS Update | London - Elastic Beanstalk

VPC ID

Auto-scaling subnet

ELBSubnet

Page 52: AWS Update | London - Elastic Beanstalk

Summary

New Python & Ruby containers Beanstalk integrates with RDS

Beanstalk in VPC

Page 53: AWS Update | London - Elastic Beanstalk

http://aws.amazon.com/elasticbeanstalk