SlideShare a Scribd company logo
1 of 40
Download to read offline
Scaling Drupal in the Cloud with AWS
Nick Veenhof
Who?
+8	
  Years	
  in	
  Drupal
Fairly	
  heavily	
  invested	
  in	
  Search
+3	
  Years	
  at	
  Acquia
Tech	
  Lead	
  @	
  MollomBelgium
Boston
Barcelona
Belgium
@Nick_vh
Components
→Let’s get physical! Well.. Sort of.

→I want you all to regroup in all the components that a
website needs. One row = One Component

→I will be a site visitor, so I want you to start from the front
to the end. What is the first layer?
3 Layers
Webserver	
  
EC2	
  Instance
MySQL	
  
RDS
Domain	
  
Route	
  53
Ephemeralism
Is Theory boring?
Describes	
  the	
  optimal	
  environment	
  and	
  
how	
  this	
  relates	
  to	
  reality.	
  A	
  very	
  
digestible	
  book	
  	
  for	
  designing	
  
distributed	
  systems.	
  This	
  book	
  exposes	
  
software	
  patterns	
  that	
  every	
  self-­‐
respecting	
  cloud	
  infrastructure	
  
engineer	
  	
  should	
  know.	
  
http://the-­‐cloud-­‐book.com/
Cap Principle
Limoncelli,	
  Thomas	
  A.;	
  Chalup,	
  Strata	
  R.;	
  
Hogan,	
  Christina	
  J.	
  (2014-­‐09-­‐01).	
  The	
  Practice	
  
of	
  Cloud	
  System	
  Administration:	
  Designing	
  and	
  
Operating	
  Large	
  Distributed	
  Systems,	
  Volume	
  2	
  
(p.	
  21).	
  Pearson	
  Education.	
  Kindle	
  Edition.	
  
The	
  CAP	
  Principle	
  CAP	
  stands	
  for	
  
consistency,	
  availability,	
  and	
  partition	
  
resistance.	
  The	
  CAP	
  Principle	
  states	
  that	
  
it	
  is	
  not	
  possible	
  to	
  build	
  a	
  distributed	
  
system	
  that	
  guarantees	
  consistency,	
  
availability,	
  and	
  resistance	
  to	
  
partitioning.	
  Any	
  one	
  or	
  two	
  can	
  be	
  
achieved	
  but	
  not	
  all	
  three	
  
simultaneously.
Ephemeralism
Webserver	
  
EC2	
  Instance
MySQL	
  
RDS
Domain	
  
Route	
  53
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Horizontal Scaling of Web Servers
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Database Scaling
Replica
Primary
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Caching
Replica
Primary
Memcache	
  
ElastiCache
Spof Caching
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Replica
Primary
Memcache	
  
ElastiCache
Spof Caching
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Replica
Primary
Memcache	
  
ElastiCache
Permanent Storage
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Replica
Primary
Memcache	
  
ElastiCache
Backup	
  Storage	
  
S3
Version Control
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Replica
Primary
Memcache	
  
ElastiCache
Backup	
  Storage	
  
S3
GitHub
Persistent Storage
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Replica
Primary
Memcache	
  
ElastiCache
Backup	
  Storage	
  
S3
GitHub
Reverse Proxy
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Replica
Primary
Memcache	
  
ElastiCache
Backup	
  Storage	
  
S3GitHub
Varnish	
  
EC2	
  Instances
http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/
Reverse Proxy (v2)
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Replica
Primary
Memcache	
  
ElastiCache
Backup	
  Storage	
  
S3GitHub
Varnish	
  
EC2	
  Instances
http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/
Nginx	
  
EC2	
  Instances
Reverse Proxy (v3)
Webservers	
  
EC2	
  Instances
MySQL	
  
RDS
Domain	
  
Route	
  53
Replica
Primary
Memcache	
  
ElastiCache
Backup	
  Storage	
  
S3
GitHub
http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/
Varnish	
  &	
  Nginx	
  
Elastic	
  Beanstalk	
  	
  
Docker	
  (ECS)
+
Unexpected Spikes
→You could be hosting the next World Cup website

→Or under some page load DDOS from a script kiddie

→A website that is marketed heavily in the next weeks. But
is fairly idle in the rest of the year

→Former slashdot effect (now Reddit)

→…
Stacking up
WebServer	
  Stack
MySQL	
  
RDS Replica
Primary
Object	
  Caching	
  
Stack
Backup	
  Storage	
  
S3
GitHub
http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/
+
Database	
  Stack
Watch	
  out	
  for	
  Aurora.	
  	
  
RDS	
  is	
  limited	
  by	
  Instance	
  Size
Load	
  Balancing	
  +	
  	
  
Page	
  Caching	
  Stack
Scaling Up
WebServer	
  Stack
MySQL	
  
RDS Replica
Primary
Caching	
  Stack
Backup	
  Storage	
  
S3
GitHub
http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/
+
Database	
  Stack
Watch	
  out	
  for	
  Aurora.	
  	
  
RDS	
  is	
  limited	
  by	
  Instance	
  Size
Load	
  Balancing	
  +	
  	
  
Page	
  Caching	
  Stack
Scaling Up
http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/
AWS	
  AutoScaling	
  Group
Minimum	
  2	
  
Maximum	
  10
AutoScaling Policies
→CPUUtilization

→IF CPU(combined) > ’80% for 5+ min’ THEN ‘add
instance’

→Custom CloudWatch Metrics

→Infinite possibilities
Cloudformation Components
{	
  
	
  	
  	
  	
  "ElasticLoadBalancer":	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "Type":	
  "AWS::ElasticLoadBalancing::LoadBalancer",	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  "Properties":	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "CrossZone":	
  "true",	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "AvailabilityZones":	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "Fn::GetAZs":	
  ""	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "LBCookieStickinessPolicy":	
  [	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "PolicyName":	
  "CookieBasedPolicy",	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "CookieExpirationPeriod":	
  "30"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ],	
  	
  
Cloudformation Sub Stacks
	
  	
  	
  	
  "CacheStack":	
  {	
  
	
  	
  	
  	
  	
  	
  "Type":	
  "AWS::CloudFormation::Stack",	
  
	
  	
  	
  	
  	
  	
  "Properties":	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "TemplateURL":	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "Fn::Join":	
  [	
  "",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  [	
  "https://s3.amazonaws.com/drupaljam.",	
  {	
  "Ref":	
  "AWS::Region"	
  },".",	
  {	
  "Ref":	
  
"EnvironmentName"	
  },	
  "/cloudformation/",	
  "cache.template"	
  ]	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ]	
  
	
  	
  	
  	
  	
  	
  	
  	
  },
Example
→Make a Scalable Static Hosted Website that can handle
gradual increase of visitors beyond 2 web servers.

→Finance wise we are limited to 5 web servers.

→PHP, MySQL, Load Balancer.

→No Object Caching or Page Caching required
Parameters
→database password

→ssh key

→ssh IP restrictions

→etc…
"Parameters"	
  :	
  {	
  
!
	
  	
  	
  	
  "KeyName":	
  {	
  
	
  	
  	
  	
  	
  	
  "Description"	
  :	
  "EC2	
  KeyPair	
  to	
  enable	
  SSH	
  access	
  to	
  the	
  instances",	
  
	
  	
  	
  	
  	
  	
  "Default"	
  :	
  "drupaljam",	
  
	
  	
  	
  	
  	
  	
  "Type":	
  "String",	
  
	
  	
  	
  	
  	
  	
  "MinLength":	
  "1",	
  
	
  	
  	
  	
  	
  	
  "MaxLength":	
  "255",	
  
	
  	
  	
  	
  	
  	
  "AllowedPattern"	
  :	
  "[x20-­‐x7E]*",	
  
	
  	
  	
  	
  	
  	
  "ConstraintDescription"	
  :	
  "can	
  contain	
  only	
  ASCII	
  characters."	
  
	
  	
  	
  	
  },	
  
!
	
  	
  	
  	
  "InstanceType"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  "Description"	
  :	
  "WebServer	
  EC2	
  instance	
  type",	
  
	
  	
  	
  	
  	
  	
  "Type"	
  :	
  "String",	
  
	
  	
  	
  	
  	
  	
  "Default"	
  :	
  "m3.medium",	
  
	
  	
  	
  	
  	
  	
  "ConstraintDescription"	
  :	
  "must	
  be	
  a	
  valid	
  EC2	
  instance	
  type."	
  
	
  	
  	
  	
  },	
  
!
	
  	
  	
  	
  "SiteName":	
  {	
  
	
  	
  	
  	
  	
  	
  "Default":	
  "Drupal",	
  
	
  	
  	
  	
  	
  	
  "Description"	
  :	
  "Drupal	
  Web	
  Site",	
  
	
  	
  	
  	
  	
  	
  "Type":	
  "String"	
  
	
  	
  	
  	
  },
AWS::ElasticLoadBalancing::LoadBalancer
→Define Listening Ports

→Define Instance Ports

→Define Cookie
Stickiness Policies

→Defines HealthCheck
so it can take
instances out rotation
"ElasticLoadBalancer"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  "Type"	
  :	
  "AWS::ElasticLoadBalancing::LoadBalancer",	
  
	
  	
  	
  	
  	
  	
  "Metadata"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "Comment"	
  :	
  "Configure	
  the	
  Load	
  Balancer	
  with	
  a	
  simple	
  health	
  check
	
  	
  	
  	
  	
  	
  },	
  
	
  	
  	
  	
  	
  	
  "Properties"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "AvailabilityZones"	
  :	
  [	
  "us-­‐east-­‐1b","us-­‐east-­‐1d"	
  ],	
  
	
  	
  	
  	
  	
  	
  	
  	
  "LBCookieStickinessPolicy"	
  :	
  [	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "PolicyName"	
  :	
  "CookieBasedPolicy",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "CookieExpirationPeriod"	
  :	
  "30"	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  ],	
  
	
  	
  	
  	
  	
  	
  	
  	
  "Listeners"	
  :	
  [	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "LoadBalancerPort"	
  :	
  "80",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "InstancePort"	
  :	
  "80",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "Protocol"	
  :	
  "HTTP",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "PolicyNames"	
  :	
  [	
  "CookieBasedPolicy"	
  ]	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  ],	
  
	
  	
  	
  	
  	
  	
  	
  	
  "HealthCheck"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "Target"	
  :	
  "HTTP:80/",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "HealthyThreshold"	
  :	
  "2",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "UnhealthyThreshold"	
  :	
  "5",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "Interval"	
  :	
  "10",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "Timeout"	
  :	
  "5"	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  
AWS::AutoScaling::AutoScalingGroup
→Define Minimum &
Maximum

→Define Availability
Zones we can use

→Define Configuration to
execute
"WebServerGroup1"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  "Type"	
  :	
  "AWS::AutoScaling::AutoScalingGroup",	
  
	
  	
  	
  	
  	
  	
  "Properties"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "AvailabilityZones"	
  :	
  [	
  "us-­‐east-­‐1b","us-­‐east-­‐1d"	
  ],	
  
	
  	
  	
  	
  	
  	
  	
  	
  "LaunchConfigurationName"	
  :	
  {	
  "Ref"	
  :	
  "LaunchConfig1"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "MinSize"	
  :	
  "1",	
  
	
  	
  	
  	
  	
  	
  	
  	
  "MaxSize"	
  :	
  "5",	
  
	
  	
  	
  	
  	
  	
  	
  	
  "DesiredCapacity"	
  :	
  {	
  "Ref"	
  :	
  "WebServerCapacity"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "LoadBalancerNames"	
  :	
  [	
  {	
  "Ref"	
  :	
  "ElasticLoadBalancer"	
  }	
  ],	
  
	
  	
  	
  	
  	
  	
  	
  	
  "Tags"	
  :	
  [	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "Key"	
  	
  :	
  "Name",	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "Value"	
  :	
  "Drupaljam	
  Drupal	
  Instance",	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "PropagateAtLaunch"	
  :	
  “true"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  ]	
  
	
  	
  	
  	
  	
  	
  }
AWS::AutoScaling::LaunchConfiguration
→Define Packages (apt/yum)

→Define Sources to extract
to folders (Drupal)

→Define files

→Define commands

→Define services to run

→Execute Script to initialize
"LaunchConfig1":	
  {	
  
	
  	
  	
  	
  	
  	
  "Type"	
  :	
  "AWS::AutoScaling::LaunchConfiguration",	
  
	
  	
  	
  	
  	
  	
  "Metadata"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "AWS::CloudFormation::Init"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "config"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "packages"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "yum"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "httpd"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "php"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "php-­‐mysql"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "php-­‐gd"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "php-­‐xml"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "php-­‐mbstring"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "mysql"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "gcc"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "make"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "libstdc++-­‐devel"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "gcc-­‐c++"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "fuse"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "fuse-­‐devel"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "libcurl-­‐devel"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "libxml2-­‐devel"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "openssl-­‐devel"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "mailcap"	
  :	
  []	
  
!	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
!	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "sources"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "/var/www/html"	
  :	
  "http://ftp.drupal.org/files/projects/drupal-­‐7.36.tar.gz",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "/home/ec2-­‐user"	
  :	
  "http://ftp.drupal.org/files/projects/drush-­‐7.x-­‐4.5.tar.gz",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "/home/ec2-­‐user/s3fs"	
  :	
  "http://s3fs.googlecode.com/files/s3fs-­‐1.61.tar.gz"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
!	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "files"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "/etc/passwd-­‐s3fs"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "content"	
  :	
  {	
  "Fn::Join"	
  :	
  ["",	
  [	
  {	
  "Ref"	
  :	
  "S3Keys"	
  },	
  ":",	
  {"Fn::GetAtt":	
  ["S3Keys",	
  "SecretAccessKey"]},	
  "n"	
  ]]},	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "mode"	
  :	
  "000400",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "owner"	
  :	
  "root",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "group"	
  :	
  "root"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
!	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "/home/ec2-­‐user/settings.php"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "content"	
  :	
  {	
  "Fn::Join"	
  :	
  ["",	
  [	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "<?phpn",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "$databases	
  =	
  array	
  (n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  'default'	
  =>n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  array	
  (n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  'default'	
  =>n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  array	
  (n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  'database'	
  =>	
  '",	
  {	
  "Ref"	
  :	
  "DBName"	
  },	
  "',n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  'username'	
  =>	
  '",	
  {	
  "Ref"	
  :	
  "DBUsername"	
  },	
  "',n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  'password'	
  =>	
  '",	
  {	
  "Ref"	
  :	
  "DBPassword"	
  },	
  "',n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  'host'	
  =>	
  '",	
  {"Fn::GetAtt"	
  :	
  ["MasterDB",	
  "Endpoint.Address"]},	
  "',n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  'port'	
  =>	
  '",	
  {"Fn::GetAtt"	
  :	
  ["MasterDB",	
  "Endpoint.Port"]},	
  "',n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  'driver'	
  =>	
  'mysql',n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  'prefix'	
  =>	
  'drupal_',n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  ),n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  ),n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ");n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "$update_free_access	
  =	
  FALSE;n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "$drupal_hash_salt	
  =	
  '0c3R8noNALe3shsioQr5hK1dMHdwRfikLoSfqn0_xpA';n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "ini_set('session.gc_probability',	
  1);n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "ini_set('session.gc_divisor',	
  100);n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "ini_set('session.gc_maxlifetime',	
  200000);n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "ini_set('session.cookie_lifetime',	
  2000000);n"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ]]},	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "mode"	
  :	
  "000444",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "owner"	
  :	
  "root",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "group"	
  :	
  "root"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
!	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "services"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "sysvinit"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "httpd"	
  :	
  {	
  "enabled"	
  :	
  "true",	
  "ensureRunning"	
  :	
  "true"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "sendmail"	
  :	
  {	
  "enabled"	
  :	
  "false",	
  "ensureRunning"	
  :	
  "false"	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  },	
  
	
  	
  	
  	
  	
  	
  "Properties":	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "ImageId"	
  :	
  {	
  "Fn::FindInMap"	
  :	
  [	
  "AWSRegionArch2AMI",	
  {	
  "Ref"	
  :	
  "AWS::Region"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  "Fn::FindInMap"	
  :	
  [	
  "AWSInstanceType2Arch",	
  {	
  "Ref"	
  :	
  "InstanceType"	
  },	
  "Arch"	
  ]	
  }	
  ]	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "InstanceType"	
  :	
  {	
  "Ref"	
  :	
  "InstanceType"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "SecurityGroups"	
  :	
  [	
  {"Ref"	
  :	
  "WebServerSecurityGroup"}	
  ],	
  
	
  	
  	
  	
  	
  	
  	
  	
  "KeyName"	
  :	
  {	
  "Ref"	
  :	
  "KeyName"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "UserData"	
  :	
  {	
  "Fn::Base64"	
  :	
  {	
  "Fn::Join"	
  :	
  ["",	
  [	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "#!/bin/bash	
  -­‐vn",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "yum	
  update	
  -­‐y	
  aws-­‐cfn-­‐bootstrapn",	
  
!	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "#	
  Helper	
  functionn",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "function	
  error_exitn",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "{n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  /opt/aws/bin/cfn-­‐signal	
  -­‐e	
  1	
  -­‐r	
  "$1"	
  '",	
  {	
  "Ref"	
  :	
  "WaitHandle"	
  },	
  "'n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  exit	
  1n",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "}n",	
  
!	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "#	
  Install	
  Apache	
  Web	
  Server,	
  MySQL	
  and	
  Drupaln",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "/opt/aws/bin/cfn-­‐init	
  -­‐s	
  ",	
  {	
  "Ref"	
  :	
  "AWS::StackId"	
  },	
  "	
  -­‐r	
  LaunchConfig1	
  ",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "	
  -­‐-­‐region	
  ",	
  {	
  "Ref"	
  :	
  "AWS::Region"	
  },	
  "	
  ||	
  error_exit	
  'Failed	
  to	
  run	
  cfn-­‐init'n",	
  
!	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "#	
  Install	
  s3fsn",	
  
Let’s	
  make	
  this	
  bigger	
  shall	
  we?
"LaunchConfig1":	
  {	
  
	
  	
  	
  	
  	
  	
  "Type"	
  :	
  "AWS::AutoScaling::LaunchConfiguration",	
  
	
  	
  	
  	
  	
  	
  "Metadata"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "AWS::CloudFormation::Init"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "config"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "packages"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "yum"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "httpd"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "php"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "php-­‐mysql"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "php-­‐gd"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "php-­‐xml"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "php-­‐mbstring"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "mysql"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "gcc"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "make"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "libstdc++-­‐devel"	
  :	
  [],	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "sources"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "/var/www/html"	
  :	
  "http://ftp.drupal.org/files/projects/drupal-­‐7.36.tar.gz",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "/home/ec2-­‐user"	
  :	
  "http://ftp.drupal.org/files/projects/drush-­‐7.x-­‐4.5.tar.gz",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "/home/ec2-­‐user/s3fs"	
  :	
  "http://s3fs.googlecode.com/files/s3fs-­‐1.61.tar.gz"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "files"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "/etc/passwd-­‐s3fs"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "content"	
  :	
  {	
  "Fn::Join"	
  :	
  ["",	
  [	
  {	
  "Ref"	
  :	
  "S3Keys"	
  },	
  ":",	
  {"Fn::GetAtt":	
  ["S3Keys",	
  "SecretAccessKey"]},	
  "n"	
  ]]},	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "mode"	
  :	
  "000400",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "owner"	
  :	
  "root",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "group"	
  :	
  "root"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  …	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },
"Properties":	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "ImageId"	
  :	
  {	
  "Fn::FindInMap"	
  :	
  [	
  "AWSRegionArch2AMI",	
  {	
  "Ref"	
  :	
  "AWS::Region"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  "Fn::FindInMap"	
  :	
  [	
  "AWSInstanceType2Arch",	
  {	
  "Ref"	
  :	
  "InstanceType"	
  },	
  
"Arch"	
  ]	
  }	
  ]	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "InstanceType"	
  :	
  {	
  "Ref"	
  :	
  "InstanceType"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "SecurityGroups"	
  :	
  [	
  {"Ref"	
  :	
  "WebServerSecurityGroup"}	
  ],	
  
	
  	
  	
  	
  	
  	
  	
  	
  "KeyName"	
  :	
  {	
  "Ref"	
  :	
  "KeyName"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "UserData"	
  :	
  {	
  "Fn::Base64"	
  :	
  {	
  "Fn::Join"	
  :	
  ["",	
  [	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "#!/bin/bash	
  -­‐vn",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "yum	
  update	
  -­‐y	
  aws-­‐cfn-­‐bootstrapn”,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  ….	
  
AWS::RDS::DBInstance
→Define size of MySQL
Instance

→Define MySQL Version

→Define MultiAZ or not
"MasterDB"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  "Type"	
  :	
  "AWS::RDS::DBInstance",	
  
	
  	
  	
  	
  	
  	
  "Properties"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "DBName"	
  :	
  {	
  "Ref"	
  :	
  "DBName"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "AllocatedStorage"	
  :	
  {	
  "Ref"	
  :	
  "DBAllocatedStorage"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "DBInstanceClass"	
  :	
  {	
  "Ref"	
  :	
  "DBClass"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "Engine"	
  :	
  "MySQL",	
  
	
  	
  	
  	
  	
  	
  	
  	
  "EngineVersion"	
  :	
  "5.6",	
  
	
  	
  	
  	
  	
  	
  	
  	
  "DBInstanceIdentifier"	
  :	
  "DrupalJamMasterDB",	
  
	
  	
  	
  	
  	
  	
  	
  	
  "DBSecurityGroups":	
  [	
  {	
  "Ref":	
  "DBSecurityGroup"	
  }	
  ],	
  
	
  	
  	
  	
  	
  	
  	
  	
  "MasterUsername"	
  :	
  {	
  "Ref"	
  :	
  "DBUsername"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "MasterUserPassword"	
  :	
  {	
  "Ref"	
  :	
  "DBPassword"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "MultiAZ"	
  :	
  {	
  "Ref"	
  :	
  "MultiAZDatabase"	
  },	
  
	
  	
  	
  	
  	
  	
  	
  	
  "Tags"	
  :	
  [{	
  "Key"	
  	
  :	
  "Name",	
  "Value"	
  :	
  "Drupaljam	
  Drupal	
  Master	
  Database"	
  }]	
  
	
  	
  	
  	
  	
  	
  },	
  
	
  	
  	
  	
  	
  	
  "DeletionPolicy"	
  :	
  "Snapshot"	
  
	
  	
  	
  	
  },
AWS::EC2::SecurityGroup
→Define Security Levels
between AWS Services

→Eg. Only allow traffic
between Load Balancer
and Instances on port 80

→Eg. Allow port 22 for the
IP range in the inputs
"WebServerSecurityGroup"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  "Type"	
  :	
  "AWS::EC2::SecurityGroup",	
  
	
  	
  	
  	
  	
  	
  "Properties"	
  :	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "GroupDescription"	
  :	
  "Enable	
  HTTP	
  access	
  via	
  port	
  80,	
  locked	
  down	
  to	
  requests	
  
from	
  the	
  load	
  balancer	
  only	
  and	
  SSH	
  access",	
  
	
  	
  	
  	
  	
  	
  	
  	
  "SecurityGroupIngress"	
  :	
  [	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {"IpProtocol"	
  :	
  "tcp",	
  "FromPort"	
  :	
  "80",	
  "ToPort"	
  :	
  "80",	
  
"SourceSecurityGroupOwnerId"	
  :	
  {"Fn::GetAtt"	
  :	
  ["ElasticLoadBalancer",	
  
"SourceSecurityGroup.OwnerAlias"]},"SourceSecurityGroupName"	
  :	
  {"Fn::GetAtt"	
  :	
  
["ElasticLoadBalancer",	
  "SourceSecurityGroup.GroupName"]}},	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {"IpProtocol"	
  :	
  "tcp",	
  "FromPort"	
  :	
  "22",	
  "ToPort"	
  :	
  "22",	
  "CidrIp"	
  :	
  {	
  "Ref"	
  :	
  
"SSHLocation"}}	
  
	
  	
  	
  	
  	
  	
  	
  	
  ]	
  
	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  }
And more…
→Make sure to start with VPC

→Be Region Agnostic as some are VPC Only

→Internal ELB, Internal IP’s

→Private Puppet/Chef Servers

→Define Security Model first

→Do not create tribal knowledge
Thank You

More Related Content

What's hot

AWS Lambda Tutorial For Beginners | What is AWS Lambda? | AWS Tutorial For Be...
AWS Lambda Tutorial For Beginners | What is AWS Lambda? | AWS Tutorial For Be...AWS Lambda Tutorial For Beginners | What is AWS Lambda? | AWS Tutorial For Be...
AWS Lambda Tutorial For Beginners | What is AWS Lambda? | AWS Tutorial For Be...
Simplilearn
 
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
Amazon Web Services Korea
 
Research in Cloud Computing
Research in Cloud ComputingResearch in Cloud Computing
Research in Cloud Computing
Rajshri Mohan
 

What's hot (20)

강의 5 - AWS 요금 및 지원 (조재구 테크니컬 트레이너, AWS) :: AWSome Day 온라인 컨퍼런스 2018
강의 5 - AWS 요금 및 지원 (조재구 테크니컬 트레이너, AWS) :: AWSome Day 온라인 컨퍼런스 2018강의 5 - AWS 요금 및 지원 (조재구 테크니컬 트레이너, AWS) :: AWSome Day 온라인 컨퍼런스 2018
강의 5 - AWS 요금 및 지원 (조재구 테크니컬 트레이너, AWS) :: AWSome Day 온라인 컨퍼런스 2018
 
Amazon CloudFront 101
Amazon CloudFront 101Amazon CloudFront 101
Amazon CloudFront 101
 
AWS 9월 웨비나 | AWS 데이터베이스 마이그레이션 서비스 활용하기
AWS 9월 웨비나 | AWS 데이터베이스 마이그레이션 서비스 활용하기AWS 9월 웨비나 | AWS 데이터베이스 마이그레이션 서비스 활용하기
AWS 9월 웨비나 | AWS 데이터베이스 마이그레이션 서비스 활용하기
 
Introduction to Amazon Relational Database Service
Introduction to Amazon Relational Database ServiceIntroduction to Amazon Relational Database Service
Introduction to Amazon Relational Database Service
 
Resource Management in Cloud Computing
Resource Management in Cloud ComputingResource Management in Cloud Computing
Resource Management in Cloud Computing
 
Introduction to AWS Glue
Introduction to AWS GlueIntroduction to AWS Glue
Introduction to AWS Glue
 
Aws overview (Amazon Web Services)
Aws overview (Amazon Web Services)Aws overview (Amazon Web Services)
Aws overview (Amazon Web Services)
 
Schema Integration, View Integration and Database Integration, ER Model & Dia...
Schema Integration, View Integration and Database Integration, ER Model & Dia...Schema Integration, View Integration and Database Integration, ER Model & Dia...
Schema Integration, View Integration and Database Integration, ER Model & Dia...
 
05 pig user defined functions (udfs)
05 pig user defined functions (udfs)05 pig user defined functions (udfs)
05 pig user defined functions (udfs)
 
AWS Lambda Tutorial For Beginners | What is AWS Lambda? | AWS Tutorial For Be...
AWS Lambda Tutorial For Beginners | What is AWS Lambda? | AWS Tutorial For Be...AWS Lambda Tutorial For Beginners | What is AWS Lambda? | AWS Tutorial For Be...
AWS Lambda Tutorial For Beginners | What is AWS Lambda? | AWS Tutorial For Be...
 
Platform as a Service (PaaS)
Platform as a Service (PaaS)Platform as a Service (PaaS)
Platform as a Service (PaaS)
 
Distributed database system
Distributed database systemDistributed database system
Distributed database system
 
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
 
Best Practices for Integrating Active Directory with AWS Workloads
Best Practices for Integrating Active Directory with AWS WorkloadsBest Practices for Integrating Active Directory with AWS Workloads
Best Practices for Integrating Active Directory with AWS Workloads
 
Hybrid Cloud and Its Implementation
Hybrid Cloud and Its ImplementationHybrid Cloud and Its Implementation
Hybrid Cloud and Its Implementation
 
Cloud Infrastructure Mechanisms
Cloud Infrastructure MechanismsCloud Infrastructure Mechanisms
Cloud Infrastructure Mechanisms
 
Architetture a Microservizi con Docker Container
Architetture a Microservizi con Docker ContainerArchitetture a Microservizi con Docker Container
Architetture a Microservizi con Docker Container
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
Research in Cloud Computing
Research in Cloud ComputingResearch in Cloud Computing
Research in Cloud Computing
 
AWS Workshop Series: Microsoft licensing and active directory on AWS
AWS Workshop Series: Microsoft licensing and active directory on AWSAWS Workshop Series: Microsoft licensing and active directory on AWS
AWS Workshop Series: Microsoft licensing and active directory on AWS
 

Similar to Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more

2013 05-fite-club-working-models-cloud-growing-up
2013 05-fite-club-working-models-cloud-growing-up2013 05-fite-club-working-models-cloud-growing-up
2013 05-fite-club-working-models-cloud-growing-up
Alex Heneveld
 
Scalable and Fault-Tolerant Apps with AWS
Scalable and Fault-Tolerant Apps with AWSScalable and Fault-Tolerant Apps with AWS
Scalable and Fault-Tolerant Apps with AWS
Fernando Rodriguez
 

Similar to Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more (20)

Infrastructure as Code: Manage your Architecture with Git
Infrastructure as Code: Manage your Architecture with GitInfrastructure as Code: Manage your Architecture with Git
Infrastructure as Code: Manage your Architecture with Git
 
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
Deployment and Management on AWS:
 A Deep Dive on Options and ToolsDeployment and Management on AWS:
 A Deep Dive on Options and Tools
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
 
2013 05-openstack-israel-heat
2013 05-openstack-israel-heat2013 05-openstack-israel-heat
2013 05-openstack-israel-heat
 
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
 
2013 05-fite-club-working-models-cloud-growing-up
2013 05-fite-club-working-models-cloud-growing-up2013 05-fite-club-working-models-cloud-growing-up
2013 05-fite-club-working-models-cloud-growing-up
 
AWS Infrastructure as Code - September 2016 Webinar Series
AWS Infrastructure as Code - September 2016 Webinar SeriesAWS Infrastructure as Code - September 2016 Webinar Series
AWS Infrastructure as Code - September 2016 Webinar Series
 
Scalable and Fault-Tolerant Apps with AWS
Scalable and Fault-Tolerant Apps with AWSScalable and Fault-Tolerant Apps with AWS
Scalable and Fault-Tolerant Apps with AWS
 
Utah Codecamp Cloud Computing
Utah Codecamp Cloud ComputingUtah Codecamp Cloud Computing
Utah Codecamp Cloud Computing
 
Introduction to Apache CloudStack by David Nalley
Introduction to Apache CloudStack by David NalleyIntroduction to Apache CloudStack by David Nalley
Introduction to Apache CloudStack by David Nalley
 
Deep Dive - Infrastructure as Code
Deep Dive - Infrastructure as CodeDeep Dive - Infrastructure as Code
Deep Dive - Infrastructure as Code
 
Infrastructure as Code
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code
 
CloudFormation Best Practices
CloudFormation Best PracticesCloudFormation Best Practices
CloudFormation Best Practices
 
Infrastructure as Code: Manage your Architecture with Git
Infrastructure as Code: Manage your Architecture with GitInfrastructure as Code: Manage your Architecture with Git
Infrastructure as Code: Manage your Architecture with Git
 
Creating real life serverless solutions with Azure Functions - dotNet Amsterd...
Creating real life serverless solutions with Azure Functions - dotNet Amsterd...Creating real life serverless solutions with Azure Functions - dotNet Amsterd...
Creating real life serverless solutions with Azure Functions - dotNet Amsterd...
 
Automating your Infrastructure Deployment with AWS CloudFormation and AWS Ops...
Automating your Infrastructure Deployment with AWS CloudFormation and AWS Ops...Automating your Infrastructure Deployment with AWS CloudFormation and AWS Ops...
Automating your Infrastructure Deployment with AWS CloudFormation and AWS Ops...
 
無伺服器架構和Containers on AWS入門
無伺服器架構和Containers on AWS入門 無伺服器架構和Containers on AWS入門
無伺服器架構和Containers on AWS入門
 
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivSelf Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
 
Dev & Test on AWS Webinar October 2017 - IL Webinar
Dev & Test on AWS Webinar October 2017 - IL WebinarDev & Test on AWS Webinar October 2017 - IL Webinar
Dev & Test on AWS Webinar October 2017 - IL Webinar
 
TechDays 2017 - Creating real life serverless solutions with azure functions
TechDays 2017 - Creating real life serverless solutions with azure functionsTechDays 2017 - Creating real life serverless solutions with azure functions
TechDays 2017 - Creating real life serverless solutions with azure functions
 
Creating real life serverless solutions with Azure Functions
Creating real life serverless solutions with Azure FunctionsCreating real life serverless solutions with Azure Functions
Creating real life serverless solutions with Azure Functions
 

More from Dropsolid

More from Dropsolid (7)

Drupal Developers Days - One Flew Over The Developers Nest 2018
Drupal Developers Days - One Flew Over The Developers Nest 2018Drupal Developers Days - One Flew Over The Developers Nest 2018
Drupal Developers Days - One Flew Over The Developers Nest 2018
 
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google CloudDrupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
 
State of Search, Solr and Facets in Drupal 8 - Drupalcamp Belgium 2015
State of Search, Solr and Facets in Drupal 8 - Drupalcamp Belgium 2015State of Search, Solr and Facets in Drupal 8 - Drupalcamp Belgium 2015
State of Search, Solr and Facets in Drupal 8 - Drupalcamp Belgium 2015
 
Search api d8
Search api d8Search api d8
Search api d8
 
Apache Solr Search Course Drupal 7 Acquia
Apache Solr Search Course Drupal 7 AcquiaApache Solr Search Course Drupal 7 Acquia
Apache Solr Search Course Drupal 7 Acquia
 
Slideshare cscw - How to use slideshare
Slideshare cscw - How to use slideshareSlideshare cscw - How to use slideshare
Slideshare cscw - How to use slideshare
 
Drupal + ApacheSolr
Drupal + ApacheSolrDrupal + ApacheSolr
Drupal + ApacheSolr
 

Recently uploaded

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
Health
 

Recently uploaded (20)

Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 

Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more

  • 1. Scaling Drupal in the Cloud with AWS Nick Veenhof
  • 2. Who? +8  Years  in  Drupal Fairly  heavily  invested  in  Search +3  Years  at  Acquia Tech  Lead  @  MollomBelgium Boston Barcelona Belgium @Nick_vh
  • 3. Components →Let’s get physical! Well.. Sort of. →I want you all to regroup in all the components that a website needs. One row = One Component →I will be a site visitor, so I want you to start from the front to the end. What is the first layer?
  • 4. 3 Layers Webserver   EC2  Instance MySQL   RDS Domain   Route  53
  • 6. Is Theory boring? Describes  the  optimal  environment  and   how  this  relates  to  reality.  A  very   digestible  book    for  designing   distributed  systems.  This  book  exposes   software  patterns  that  every  self-­‐ respecting  cloud  infrastructure   engineer    should  know.   http://the-­‐cloud-­‐book.com/
  • 7. Cap Principle Limoncelli,  Thomas  A.;  Chalup,  Strata  R.;   Hogan,  Christina  J.  (2014-­‐09-­‐01).  The  Practice   of  Cloud  System  Administration:  Designing  and   Operating  Large  Distributed  Systems,  Volume  2   (p.  21).  Pearson  Education.  Kindle  Edition.   The  CAP  Principle  CAP  stands  for   consistency,  availability,  and  partition   resistance.  The  CAP  Principle  states  that   it  is  not  possible  to  build  a  distributed   system  that  guarantees  consistency,   availability,  and  resistance  to   partitioning.  Any  one  or  two  can  be   achieved  but  not  all  three   simultaneously.
  • 9. Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Horizontal Scaling of Web Servers
  • 10. Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Database Scaling Replica Primary
  • 11. Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Caching Replica Primary Memcache   ElastiCache
  • 12. Spof Caching Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Replica Primary Memcache   ElastiCache
  • 13. Spof Caching Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Replica Primary Memcache   ElastiCache
  • 14. Permanent Storage Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Replica Primary Memcache   ElastiCache Backup  Storage   S3
  • 15. Version Control Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Replica Primary Memcache   ElastiCache Backup  Storage   S3 GitHub
  • 16. Persistent Storage Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Replica Primary Memcache   ElastiCache Backup  Storage   S3 GitHub
  • 17. Reverse Proxy Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Replica Primary Memcache   ElastiCache Backup  Storage   S3GitHub Varnish   EC2  Instances http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/
  • 18. Reverse Proxy (v2) Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Replica Primary Memcache   ElastiCache Backup  Storage   S3GitHub Varnish   EC2  Instances http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/ Nginx   EC2  Instances
  • 19. Reverse Proxy (v3) Webservers   EC2  Instances MySQL   RDS Domain   Route  53 Replica Primary Memcache   ElastiCache Backup  Storage   S3 GitHub http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/ Varnish  &  Nginx   Elastic  Beanstalk     Docker  (ECS) +
  • 20.
  • 21.
  • 22. Unexpected Spikes →You could be hosting the next World Cup website →Or under some page load DDOS from a script kiddie →A website that is marketed heavily in the next weeks. But is fairly idle in the rest of the year →Former slashdot effect (now Reddit) →…
  • 23. Stacking up WebServer  Stack MySQL   RDS Replica Primary Object  Caching   Stack Backup  Storage   S3 GitHub http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/ + Database  Stack Watch  out  for  Aurora.     RDS  is  limited  by  Instance  Size Load  Balancing  +     Page  Caching  Stack
  • 24. Scaling Up WebServer  Stack MySQL   RDS Replica Primary Caching  Stack Backup  Storage   S3 GitHub http://www.cloudreach.com/gb-­‐en/2013/01/varnish-­‐autoscaling-­‐love-­‐story/ + Database  Stack Watch  out  for  Aurora.     RDS  is  limited  by  Instance  Size Load  Balancing  +     Page  Caching  Stack
  • 26. AutoScaling Policies →CPUUtilization →IF CPU(combined) > ’80% for 5+ min’ THEN ‘add instance’ →Custom CloudWatch Metrics →Infinite possibilities
  • 27. Cloudformation Components {          "ElasticLoadBalancer":  {                  "Type":  "AWS::ElasticLoadBalancing::LoadBalancer",                    "Properties":  {                          "CrossZone":  "true",                            "AvailabilityZones":  {                                  "Fn::GetAZs":  ""                          },                            "LBCookieStickinessPolicy":  [                                  {                                          "PolicyName":  "CookieBasedPolicy",                                            "CookieExpirationPeriod":  "30"                                  }                          ],    
  • 28. Cloudformation Sub Stacks        "CacheStack":  {              "Type":  "AWS::CloudFormation::Stack",              "Properties":  {                  "TemplateURL":  {                      "Fn::Join":  [  "",                          [  "https://s3.amazonaws.com/drupaljam.",  {  "Ref":  "AWS::Region"  },".",  {  "Ref":   "EnvironmentName"  },  "/cloudformation/",  "cache.template"  ]                      ]                  },
  • 29. Example →Make a Scalable Static Hosted Website that can handle gradual increase of visitors beyond 2 web servers. →Finance wise we are limited to 5 web servers. →PHP, MySQL, Load Balancer. →No Object Caching or Page Caching required
  • 30. Parameters →database password →ssh key →ssh IP restrictions →etc… "Parameters"  :  {   !        "KeyName":  {              "Description"  :  "EC2  KeyPair  to  enable  SSH  access  to  the  instances",              "Default"  :  "drupaljam",              "Type":  "String",              "MinLength":  "1",              "MaxLength":  "255",              "AllowedPattern"  :  "[x20-­‐x7E]*",              "ConstraintDescription"  :  "can  contain  only  ASCII  characters."          },   !        "InstanceType"  :  {              "Description"  :  "WebServer  EC2  instance  type",              "Type"  :  "String",              "Default"  :  "m3.medium",              "ConstraintDescription"  :  "must  be  a  valid  EC2  instance  type."          },   !        "SiteName":  {              "Default":  "Drupal",              "Description"  :  "Drupal  Web  Site",              "Type":  "String"          },
  • 31. AWS::ElasticLoadBalancing::LoadBalancer →Define Listening Ports →Define Instance Ports →Define Cookie Stickiness Policies →Defines HealthCheck so it can take instances out rotation "ElasticLoadBalancer"  :  {              "Type"  :  "AWS::ElasticLoadBalancing::LoadBalancer",              "Metadata"  :  {                  "Comment"  :  "Configure  the  Load  Balancer  with  a  simple  health  check            },              "Properties"  :  {                  "AvailabilityZones"  :  [  "us-­‐east-­‐1b","us-­‐east-­‐1d"  ],                  "LBCookieStickinessPolicy"  :  [  {                      "PolicyName"  :  "CookieBasedPolicy",                      "CookieExpirationPeriod"  :  "30"                  }  ],                  "Listeners"  :  [  {                      "LoadBalancerPort"  :  "80",                      "InstancePort"  :  "80",                      "Protocol"  :  "HTTP",                      "PolicyNames"  :  [  "CookieBasedPolicy"  ]                  }  ],                  "HealthCheck"  :  {                      "Target"  :  "HTTP:80/",                      "HealthyThreshold"  :  "2",                      "UnhealthyThreshold"  :  "5",                      "Interval"  :  "10",                      "Timeout"  :  "5"                  }  
  • 32. AWS::AutoScaling::AutoScalingGroup →Define Minimum & Maximum →Define Availability Zones we can use →Define Configuration to execute "WebServerGroup1"  :  {              "Type"  :  "AWS::AutoScaling::AutoScalingGroup",              "Properties"  :  {                  "AvailabilityZones"  :  [  "us-­‐east-­‐1b","us-­‐east-­‐1d"  ],                  "LaunchConfigurationName"  :  {  "Ref"  :  "LaunchConfig1"  },                  "MinSize"  :  "1",                  "MaxSize"  :  "5",                  "DesiredCapacity"  :  {  "Ref"  :  "WebServerCapacity"  },                  "LoadBalancerNames"  :  [  {  "Ref"  :  "ElasticLoadBalancer"  }  ],                  "Tags"  :  [                        {                              "Key"    :  "Name",                              "Value"  :  "Drupaljam  Drupal  Instance",                              "PropagateAtLaunch"  :  “true"                        }                  ]              }
  • 33. AWS::AutoScaling::LaunchConfiguration →Define Packages (apt/yum) →Define Sources to extract to folders (Drupal) →Define files →Define commands →Define services to run →Execute Script to initialize "LaunchConfig1":  {              "Type"  :  "AWS::AutoScaling::LaunchConfiguration",              "Metadata"  :  {                  "AWS::CloudFormation::Init"  :  {                      "config"  :  {                          "packages"  :  {                              "yum"  :  {                                  "httpd"  :  [],                                  "php"  :  [],                                  "php-­‐mysql"  :  [],                                  "php-­‐gd"  :  [],                                  "php-­‐xml"  :  [],                                  "php-­‐mbstring"  :  [],                                  "mysql"  :  [],                                  "gcc"  :  [],                                  "make"  :  [],                                  "libstdc++-­‐devel"  :  [],                                  "gcc-­‐c++"  :  [],                                  "fuse"  :  [],                                  "fuse-­‐devel"  :  [],                                  "libcurl-­‐devel"  :  [],                                  "libxml2-­‐devel"  :  [],                                  "openssl-­‐devel"  :  [],                                  "mailcap"  :  []   !                            }                          },   !                        "sources"  :  {                              "/var/www/html"  :  "http://ftp.drupal.org/files/projects/drupal-­‐7.36.tar.gz",                              "/home/ec2-­‐user"  :  "http://ftp.drupal.org/files/projects/drush-­‐7.x-­‐4.5.tar.gz",                              "/home/ec2-­‐user/s3fs"  :  "http://s3fs.googlecode.com/files/s3fs-­‐1.61.tar.gz"                          },   !                        "files"  :  {                              "/etc/passwd-­‐s3fs"  :  {                                  "content"  :  {  "Fn::Join"  :  ["",  [  {  "Ref"  :  "S3Keys"  },  ":",  {"Fn::GetAtt":  ["S3Keys",  "SecretAccessKey"]},  "n"  ]]},                                  "mode"  :  "000400",                                  "owner"  :  "root",                                  "group"  :  "root"                              },   !                            "/home/ec2-­‐user/settings.php"  :  {                                  "content"  :  {  "Fn::Join"  :  ["",  [                                      "<?phpn",                                      "n",                                      "$databases  =  array  (n",                                      "  'default'  =>n",                                      "  array  (n",                                      "  'default'  =>n",                                      "  array  (n",                                      "  'database'  =>  '",  {  "Ref"  :  "DBName"  },  "',n",                                      "  'username'  =>  '",  {  "Ref"  :  "DBUsername"  },  "',n",                                      "  'password'  =>  '",  {  "Ref"  :  "DBPassword"  },  "',n",                                      "  'host'  =>  '",  {"Fn::GetAtt"  :  ["MasterDB",  "Endpoint.Address"]},  "',n",                                      "  'port'  =>  '",  {"Fn::GetAtt"  :  ["MasterDB",  "Endpoint.Port"]},  "',n",                                      "  'driver'  =>  'mysql',n",                                      "  'prefix'  =>  'drupal_',n",                                      "  ),n",                                      "  ),n",                                      ");n",                                      "n",                                      "$update_free_access  =  FALSE;n",                                      "n",                                      "$drupal_hash_salt  =  '0c3R8noNALe3shsioQr5hK1dMHdwRfikLoSfqn0_xpA';n",                                      "n",                                      "ini_set('session.gc_probability',  1);n",                                      "ini_set('session.gc_divisor',  100);n",                                      "ini_set('session.gc_maxlifetime',  200000);n",                                      "ini_set('session.cookie_lifetime',  2000000);n"                                  ]]},                                  "mode"  :  "000444",                                  "owner"  :  "root",                                  "group"  :  "root"                              }                          },   !                        "services"  :  {                              "sysvinit"  :  {                                  "httpd"  :  {  "enabled"  :  "true",  "ensureRunning"  :  "true"  },                                  "sendmail"  :  {  "enabled"  :  "false",  "ensureRunning"  :  "false"  }                              }                          }                      }                  }              },              "Properties":  {                  "ImageId"  :  {  "Fn::FindInMap"  :  [  "AWSRegionArch2AMI",  {  "Ref"  :  "AWS::Region"  },                                                      {  "Fn::FindInMap"  :  [  "AWSInstanceType2Arch",  {  "Ref"  :  "InstanceType"  },  "Arch"  ]  }  ]  },                  "InstanceType"  :  {  "Ref"  :  "InstanceType"  },                  "SecurityGroups"  :  [  {"Ref"  :  "WebServerSecurityGroup"}  ],                  "KeyName"  :  {  "Ref"  :  "KeyName"  },                  "UserData"  :  {  "Fn::Base64"  :  {  "Fn::Join"  :  ["",  [                      "#!/bin/bash  -­‐vn",                      "yum  update  -­‐y  aws-­‐cfn-­‐bootstrapn",   !                    "#  Helper  functionn",                      "function  error_exitn",                      "{n",                      "  /opt/aws/bin/cfn-­‐signal  -­‐e  1  -­‐r  "$1"  '",  {  "Ref"  :  "WaitHandle"  },  "'n",                      "  exit  1n",                      "}n",   !                    "#  Install  Apache  Web  Server,  MySQL  and  Drupaln",                      "/opt/aws/bin/cfn-­‐init  -­‐s  ",  {  "Ref"  :  "AWS::StackId"  },  "  -­‐r  LaunchConfig1  ",                      "  -­‐-­‐region  ",  {  "Ref"  :  "AWS::Region"  },  "  ||  error_exit  'Failed  to  run  cfn-­‐init'n",   !                    "#  Install  s3fsn",   Let’s  make  this  bigger  shall  we?
  • 34. "LaunchConfig1":  {              "Type"  :  "AWS::AutoScaling::LaunchConfiguration",              "Metadata"  :  {                  "AWS::CloudFormation::Init"  :  {                      "config"  :  {                          "packages"  :  {                              "yum"  :  {                                  "httpd"  :  [],                                  "php"  :  [],                                  "php-­‐mysql"  :  [],                                  "php-­‐gd"  :  [],                                  "php-­‐xml"  :  [],                                  "php-­‐mbstring"  :  [],                                  "mysql"  :  [],                                  "gcc"  :  [],                                  "make"  :  [],                                  "libstdc++-­‐devel"  :  [],                        "sources"  :  {                              "/var/www/html"  :  "http://ftp.drupal.org/files/projects/drupal-­‐7.36.tar.gz",                              "/home/ec2-­‐user"  :  "http://ftp.drupal.org/files/projects/drush-­‐7.x-­‐4.5.tar.gz",                              "/home/ec2-­‐user/s3fs"  :  "http://s3fs.googlecode.com/files/s3fs-­‐1.61.tar.gz"                          },                          "files"  :  {                              "/etc/passwd-­‐s3fs"  :  {                                  "content"  :  {  "Fn::Join"  :  ["",  [  {  "Ref"  :  "S3Keys"  },  ":",  {"Fn::GetAtt":  ["S3Keys",  "SecretAccessKey"]},  "n"  ]]},                                  "mode"  :  "000400",                                  "owner"  :  "root",                                  "group"  :  "root"                              },                              …                      },
  • 35. "Properties":  {                  "ImageId"  :  {  "Fn::FindInMap"  :  [  "AWSRegionArch2AMI",  {  "Ref"  :  "AWS::Region"  },                                                      {  "Fn::FindInMap"  :  [  "AWSInstanceType2Arch",  {  "Ref"  :  "InstanceType"  },   "Arch"  ]  }  ]  },                  "InstanceType"  :  {  "Ref"  :  "InstanceType"  },                  "SecurityGroups"  :  [  {"Ref"  :  "WebServerSecurityGroup"}  ],                  "KeyName"  :  {  "Ref"  :  "KeyName"  },                  "UserData"  :  {  "Fn::Base64"  :  {  "Fn::Join"  :  ["",  [                      "#!/bin/bash  -­‐vn",                      "yum  update  -­‐y  aws-­‐cfn-­‐bootstrapn”,                    ….  
  • 36. AWS::RDS::DBInstance →Define size of MySQL Instance →Define MySQL Version →Define MultiAZ or not "MasterDB"  :  {              "Type"  :  "AWS::RDS::DBInstance",              "Properties"  :  {                  "DBName"  :  {  "Ref"  :  "DBName"  },                  "AllocatedStorage"  :  {  "Ref"  :  "DBAllocatedStorage"  },                  "DBInstanceClass"  :  {  "Ref"  :  "DBClass"  },                  "Engine"  :  "MySQL",                  "EngineVersion"  :  "5.6",                  "DBInstanceIdentifier"  :  "DrupalJamMasterDB",                  "DBSecurityGroups":  [  {  "Ref":  "DBSecurityGroup"  }  ],                  "MasterUsername"  :  {  "Ref"  :  "DBUsername"  },                  "MasterUserPassword"  :  {  "Ref"  :  "DBPassword"  },                  "MultiAZ"  :  {  "Ref"  :  "MultiAZDatabase"  },                  "Tags"  :  [{  "Key"    :  "Name",  "Value"  :  "Drupaljam  Drupal  Master  Database"  }]              },              "DeletionPolicy"  :  "Snapshot"          },
  • 37. AWS::EC2::SecurityGroup →Define Security Levels between AWS Services →Eg. Only allow traffic between Load Balancer and Instances on port 80 →Eg. Allow port 22 for the IP range in the inputs "WebServerSecurityGroup"  :  {              "Type"  :  "AWS::EC2::SecurityGroup",              "Properties"  :  {                  "GroupDescription"  :  "Enable  HTTP  access  via  port  80,  locked  down  to  requests   from  the  load  balancer  only  and  SSH  access",                  "SecurityGroupIngress"  :  [                      {"IpProtocol"  :  "tcp",  "FromPort"  :  "80",  "ToPort"  :  "80",   "SourceSecurityGroupOwnerId"  :  {"Fn::GetAtt"  :  ["ElasticLoadBalancer",   "SourceSecurityGroup.OwnerAlias"]},"SourceSecurityGroupName"  :  {"Fn::GetAtt"  :   ["ElasticLoadBalancer",  "SourceSecurityGroup.GroupName"]}},                      {"IpProtocol"  :  "tcp",  "FromPort"  :  "22",  "ToPort"  :  "22",  "CidrIp"  :  {  "Ref"  :   "SSHLocation"}}                  ]              }          }
  • 38. And more… →Make sure to start with VPC →Be Region Agnostic as some are VPC Only →Internal ELB, Internal IP’s →Private Puppet/Chef Servers →Define Security Model first →Do not create tribal knowledge
  • 39.