Download as pdf or txt
Download as pdf or txt
You are on page 1of 50

L07s: 

Setting up a IaaS, PaaS, 
SaaS and FaaS Blog in AWS

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 1
Blog in AWS
Outline
• Objective

• Overview of AWS
– Global Network of AWS Regions
– AWS Services

• Develop Cloud Applications using Different Cloud Service 
Models
1. IaaS: Build a WordPress using EC2
2. PaaS: Using ELB and RDS PaaS to Scale WordPress
3. SaaS: Using WordPress SaaS
4. FaaS: Serverless WordPress by AWS Lambda 

• Video

• Summary
L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 2
Blog in AWS
Objective
• To demonstrate how cloud applications are developed
using different cloud service models:

– Setup a WordPress on AWS EC2 (IaaS)

– Using AWS ELB and RDS to achieve auto‐scaling for


EC2 (PaaS)

– Setup a WordPress using AWS WordPress (SaaS)

– Setup a serverless blog use AWS lambda (FaaS)

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 3
Blog in AWS
What is AWS?

“Amazon Web Services (AWS), a subsidiary


of Amazon.com, offers a suite of cloud‐
computing services that make up an on‐
demand computing platform. These services operate
from multiple geographical regions across the world.”

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 4
Blog in AWS
Global Network of AWS Regions

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 5
Blog in AWS
Global Network of AWS Regions

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 6
Blog in AWS
Amazon Web Services

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 7
Blog in AWS
AWS Catalog

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 8
Blog in AWS
Target Cloud Consumers
• Application Developers
– Supports multiple languages
– Auto‐managed: version control, flexible capacity

• Businesses
– Ease of deployment ‐> faster time‐to‐market
– Lesser need for technical know‐how

• Users
– Needs are addressed fast
– Feature updates made sooner
• No need for special “going live mode” to update/release feature

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 9
Blog in AWS
Companies using AWS

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 10
Blog in AWS
AWS Architecture on Web Application Hosting

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 11
Blog in AWS
EXAMPLE 1: IaaS
Develop a WordPress blogging app using AWS
• Overview
• Architecture
• Main Steps: Launch EC2 instance, Check 
Environment, Install WordPress

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 12
Blog in AWS
Building a WordPress App using EC2
• Objective: set up a WordPress server on AWS EC2

• Services used: AWS EC2

• Environment Requirement: Apache, MySQL, PHP

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 13
Blog in AWS
Building a WordPress on EC2

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 14
Blog in AWS
Building a WordPress using EC2

WordPress

Apache PHP MySQL

Linux

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 15
Blog in AWS
Building a WordPress using EC2: Main Steps
• Setup an AWS EC2 instance

• Configure the security group

• Install Apache, MySQL and PHP

• Install WordPress

• Enable new site and restart Apache

• Create config file for WordPress

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 16
Blog in AWS
EC2 Instance Setup

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 17
Blog in AWS
Configure Security Group

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 18
Blog in AWS
Environment Checking
• Apache, PHP and MySQL are pre‐installed in this image

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 19
Blog in AWS
Install WordPress and Configuration
• Install WordPress by command
– apt‐get install wordpress

• Configure a site on Apache web server
– vim etc/apache2/sitesavailable/wordpress.conf
– Insert this text:
Alias /blog /usr/share/wordpress
<Directory /usr/share/wordpress>
Options FollowSymLinks
AllowOverride Limit Options FileInfo
DirectoryIndex index.php
Order allow,deny
Allow from all
</Directory>
<Directory /usr/share/wordpress/wp-content>
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory> L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 20
Blog in AWS
Install WordPress and Configuration
• Enable new site and restart Apache
– a2ensite wordpress
– service apache2 restart

• Configure a site on Apache web server
– vim /etc/wordpress/config‐HOSTNAME.php
– Insert this text:
<?php
define('DB_NAME', 'wordpress’);
define('DB_USER', 'wordpress’);
define('DB_PASSWORD', 'cloud12345’);
define('DB_HOST', 'localhost’);
define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content’);
?>

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 21
Blog in AWS
WordPress Output

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 22
Blog in AWS
EXAMPLE 2: PaaS
Scale WordPress app in example 1 using PaaS services ‐
ELB and RDS:
– Objective
– Architecture
– Main steps: Duplicate your EC2 instance, Setup ELB, 
Setup RDS

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 23
Blog in AWS
Scaling WordPress with ELB and RDS
• Objective: use PaaS service to scale your WordPress Server

• Services used: AWS EC2, ELB and RDS

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 24
Blog in AWS
Architecture

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 25
Blog in AWS
Duplicate EC2 Instances

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 26
Blog in AWS
Registered to ELB Target Group

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 27
Blog in AWS
EXAMPLE 3: SaaS
Directly use WordPress SaaS developed by AWS

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 28
Blog in AWS
Launch AWS Stack

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 29
Blog in AWS
Github Repo
• Link
– https://github.com/aws‐samples/aws‐refarch‐wordpress

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 30
Blog in AWS
AWS Lambda
• For the previous three approaches, we all use AWS EC2 as 
server to host the WordPress blog. Is there any other solution?

FaaS! Function‐as‐a‐Service

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 31
Blog in AWS
AWS Lambda
• allow users to run code without provisioning or managing
servers

• pay only for the compute time consumed

• you can run code for virtually any type of application or


backend service ‐ all with zero administration

• you can set up your code to automatically trigger from other


AWS services or call it directly from any web or mobile app

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 32
Blog in AWS
AWS Lambda ‐ Benefits
• No Servers to manage
– AWS Lambda automatically runs your code without
requiring you to provision or manage servers

• Continuous Scaling
– AWS Lambda automatically scales your application by
running code in response to each trigger

• Sub‐second Metering
– charged for every 100ms your code executes and the
number of times your code is triggered

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 33
Blog in AWS
AWS Lambda ‐ Example
File Processing
• use Amazon S3 to trigger AWS Lambda to process data 
immediately after an upload

• Github: https://github.com/aws‐samples/lambda‐refarch‐
fileprocessing

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 34
Blog in AWS
AWS Lambda ‐ Example
• File processing
– When upload a Markdown file, this action will trigger two 
lambda function – one turns .md to html and the other 
turns .md to plain text

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 35
Blog in AWS
L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 36
Blog in AWS
data‐processor‐1

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 37
Blog in AWS
EXAMPLE 4: FaaS
Objective: setup a serverless blog using AWS Lambda

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 38
Blog in AWS
Architecture
• Git Repo
– https://github.com/aws‐samples/lambda‐refarch‐webapp

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 39
Blog in AWS
Step 1: Static Web Hosting

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 40
Blog in AWS
Step 1: Static Web Hosting
• Create an S3 Bucket

• Upload content

• Add a Bucket policy to allow public reads

• Enable website hosting

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 41
Blog in AWS
Step 2: Manage Users

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 42
Blog in AWS
Step 2: Manage Users
• Create an Amazon Cognito User Pool

• Add an App to Your User Pool

• Update the config.js File in Your Website Bucket

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 43
Blog in AWS
Step 3: Build a Serverless Backend

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 44
Blog in AWS
Step 3: Build a Serverless Backend
• Create an Amazon DynamoDB Table

• Create an IAM Role for Your Lambda function

• Create a Lambda Function for Handling Requests

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 45
Blog in AWS
Step 4: RESTful APIs

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 46
Blog in AWS
Step 4: RESTful APIs
• Create a New REST API 

• Create a Cognito User Pools Authorizer 

• Create a new resource and method 

• Deploy Your API 

• Update the Website Config 

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 47
Blog in AWS
Video

AWS Lambda Introduction: 
https://www.youtube.com/watch?v=EBSdyoO3goc

AWS Lambda Getting Started:
https://www.youtube.com/watch?v=IrRMEclU8kU

AWS Lambda Tutorial:
https://www.youtube.com/watch?v=fSUEk6iMW88&list=PLzvRQ
MJ9HDiSQMe68cti8cupI0mzLk1Gc

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 48
Blog in AWS
Summary
• AWS datacenter organization and services

• 4 key cloud service models for developing app:
– IaaS: build WordPress using EC2
– PaaS: scale WordPress using AWS ELB and RDS
– SaaS: use WordPress SaaS from AWS
– FaaS: use AWS Lambda to setup a simple blog

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 49
Blog in AWS
References

• https://aws.amazon.com/lambda/

• https://aws.amazon.com/getting‐started/projects/build‐
serverless‐web‐app‐lambda‐apigateway‐s3‐dynamodb‐
cognito/

• https://github.com/aws‐samples/lambda‐refarch‐webapp

• https://github.com/aws‐samples/aws‐refarch‐wordpress

L07s: Setting up a IaaS, PaaS, SaaS and FaaS 
2 March 2020 50
Blog in AWS

You might also like