SlideShare a Scribd company logo
Building your Cloud
Infrastructure with Python
George Goh
14 June 2013
PyCon SG
1
+
1Friday, 14 June, 13
Agenda
• Python boto
• Examples
• Putting it together
2
2Friday, 14 June, 13
Using the infrastructure cloud,
we the programmers:
• see infrastructure as code.
• are able to version our infrastructure
configs, just like software.
• can experiment with different deployment
topologies as easily as experimenting with
different algorithms.
3
3Friday, 14 June, 13
4
boto
4Friday, 14 June, 13
A Simple Example 1
5
1. Create an AWS EC2 instance in Singapore.
2. Using SSH-only login.
3. With firewall closing all ports except port
22 (for SSH).
5Friday, 14 June, 13
A Simple Example 1
6
import time
from boto.ec2 import connect_to_region
 
ec2_conn = connect_to_region("ap-southeast-1")
 
# create security group allowing SSH.
demo_sg = ec2_conn.create_security_group("demo-sg", "Demo Sec Group")
demo_sg.authorize("tcp", 22, 22, "0.0.0.0/0")
 
# create and save a public key for SSH login.
demo_key = ec2_conn.create_key_pair("demo-key")
demo_key.save(".")
 
# create the an instance using AMZN Linux.
resrv = ec2_conn.run_instances("ami-fade91a8",
                               key_name="demo-key",
                               instance_type="t1.micro",
                               security_groups=["demo-sg"])
 
# get the demo instance IP address.
demo = resrv.instances[0]
while demo.update() != 'running':
    time.sleep(1)
print demo.ip_address
6Friday, 14 June, 13
boto
• http://docs.pythonboto.org/
• https://github.com/boto/boto
• It’s a python interface to Amazon Web
Services (AWS).
7
7Friday, 14 June, 13
Helicoptor view of boto
• Compute
• Elastic Compute Cloud (EC2)
• Elastic MapReduce (EMR)
• Auto Scaling
• Data Pipeline
• Elastic Transcoder
• Content Delivery
• CloudFront
• Database
• SimpleDB
• DynamoDB2
• DynamoDB
• Relational Data Services (RDS)
• ElastiCache
• Redshift
• Deployment and Management
• CloudFormation
• ElasticBeanstalk
• Identity & Access
• Identity and Access Management (IAM)
• Security Token Service (STS)
8
• Application Services
• Simple Workflow Service (SWF)
• Simple Queue Service (SQS)
• Simple Notification Service (SNS)
• Simple Email Service (SES)
• Cloudsearch
• Monitoring
• CloudWatch
• Networking
• Route 53
• Virtual Private Cloud (VPC)
• Elastic Load Balancer (ELB)
• Payments & Billing
• Flexible Payments Service
• Storage
• Simple Storage Service (S3)
• Amazon Glacier
• Google Cloud Storage
• Workforce
• Mechanical Turk
• Other
• Marketplace Web Services
8Friday, 14 June, 13
A Simple Example 2
9
1. Create an S3 bucket in Singapore.
2. Make it open for putting images.
9Friday, 14 June, 13
A Simple Example 2
10
import boto
from boto.s3.cors import CORSConfiguration
 
s3_conn = boto.connect_s3()
 
# create bucket with _globally_unique_ name.
bucket = s3_conn.create_bucket("unique_name", location="ap-southeast-1")
 
# create CORS config.
cors = CORSConfiguration()
cors.add_rule(allowed_method="GET", allowed_origin="*", allowed_header="*")
cors.add_rule(allowed_method="POST", allowed_origin="*", allowed_header="*")
cors.add_rule(allowed_method="PUT", allowed_origin="*", allowed_header="*")
 
# apply CORS config to our bucket.
bucket.set_cors(cors)
10Friday, 14 June, 13
11
Putting it together
11Friday, 14 June, 13
12
Photo Uploader
12Friday, 14 June, 13
13
Photo Uploader
• Flask application on EC2 instance
• https://github.com/georgegoh/FlaskDirectUploader
• S3 bucket to store photos
13Friday, 14 June, 13
Instance initialization
• Do the following when an instance is
created:
• install software prerequisites
• clone the code from github
• initialize environment variables
• run the server
14
14Friday, 14 June, 13
Instance init - init.sh
15
#!/bin/sh
 
# Install software prerequisites.
yum install -y git
easy_install flask
 
# Clone the code from github.
git clone https://github.com/georgegoh/FlaskDirectUploader
 
# Initialize environment variables. BTW, these creds will be deleted
export AWS_ACCESS_KEY_ID=AKIAJH6C25DY6YS3Q7UQ
export AWS_SECRET_ACCESS_KEY=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
export S3_BUCKET=george.goh-pyconsg2013
 
# Run the server.
cd FlaskDirectUploader
python application.py
15Friday, 14 June, 13
Instance Initialization
16
• Attach init.sh to EC2 instance as user-data.
• init.sh runs once when the instance is
created.
16Friday, 14 June, 13
Modified from Simple Example 1
17
import time
import base64
from boto.ec2 import connect_to_region
 
ec2_conn = connect_to_region("ap-southeast-1")
 
# create security group allowing SSH and WWW.
demo_sg = ec2_conn.create_security_group("demo-sg", "Demo Sec Group")
demo_sg.authorize("tcp", 22, 22, "0.0.0.0/0")
demo_sg.authorize("tcp", 80, 80, "0.0.0.0/0")
 
# create and save a public key for SSH login.
demo_key = ec2_conn.create_key_pair("demo-key")
demo_key.save(".")
 
# Base64 encode the userdata.
with open('init.sh') as f:
    userdata = f.read()
 
# create the an instance using AMZN Linux.
resrv = ec2_conn.run_instances("ami-fade91a8",
                               key_name="demo-key",
                               instance_type="t1.micro",
                               security_groups=["demo-sg"],
                               user_data=userdata)
 
# get the demo instance IP address.
demo = resrv.instances[0]
while demo.update() != 'running':
    time.sleep(1)
print demo.ip_address
17Friday, 14 June, 13
Demo
18
18Friday, 14 June, 13
Recap
• boto
• createVM instances
• create storage
• use user-data to initializeVM instances
• too much to cover here
19
19Friday, 14 June, 13
What to do next
• fabric - http://docs.fabfile.org
• saltstack - http://saltstack.com/
• CloudFormation - http://aws.amazon.com/
cloudformation/
20
20Friday, 14 June, 13
Thank you
21
@georgegoh
21Friday, 14 June, 13

More Related Content

What's hot

CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a Nutshell
CoreOS
 
CoreOS @Codetalks Hamburg
CoreOS @Codetalks HamburgCoreOS @Codetalks Hamburg
CoreOS @Codetalks Hamburg
Timo Derstappen
 
CoreOS introduction - Johann Romefort
CoreOS introduction - Johann RomefortCoreOS introduction - Johann Romefort
CoreOS introduction - Johann Romefort
Stylight
 
Couch to OpenStack: Glance - July, 23, 2013
Couch to OpenStack: Glance - July, 23, 2013Couch to OpenStack: Glance - July, 23, 2013
Couch to OpenStack: Glance - July, 23, 2013
Trevor Roberts Jr.
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
Philip Zheng
 
Docker techzone
Docker techzoneDocker techzone
Docker techzone
Bjørn Nordlund
 
2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.com2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.com
Mathieu Buffenoir
 
Containerize! Between Docker and Jube.
Containerize! Between Docker and Jube.Containerize! Between Docker and Jube.
Containerize! Between Docker and Jube.
Henryk Konsek
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
Henryk Konsek
 
Docker consul-registrator
Docker consul-registratorDocker consul-registrator
Docker consul-registrator
laonap166
 
Docker n co
Docker n coDocker n co
Docker n co
Rohit Jnagal
 
Docker orchestration using core os and ansible - Ansible IL 2015
Docker orchestration using core os and ansible - Ansible IL 2015Docker orchestration using core os and ansible - Ansible IL 2015
Docker orchestration using core os and ansible - Ansible IL 2015
Leonid Mirsky
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
Bryan Yang
 
Clair, A Container Image Security Analyzer
Clair, A Container Image Security AnalyzerClair, A Container Image Security Analyzer
Clair, A Container Image Security Analyzer
CoreOS
 
Docker build #1
Docker build #1Docker build #1
Docker build #1
Eric Ahn
 
OSS AWS 핸즈온 강의
OSS AWS 핸즈온 강의OSS AWS 핸즈온 강의
OSS AWS 핸즈온 강의
Juhong Jung
 
On MongoDB backup
On MongoDB backupOn MongoDB backup
On MongoDB backup
William Yeh
 
Container & kubernetes
Container & kubernetesContainer & kubernetes
Container & kubernetes
Ted Jung
 
Couch to OpenStack: Nova - July, 30, 2013
Couch to OpenStack: Nova - July, 30, 2013Couch to OpenStack: Nova - July, 30, 2013
Couch to OpenStack: Nova - July, 30, 2013
Trevor Roberts Jr.
 
QNAP COSCUP Container Station
QNAP COSCUP Container StationQNAP COSCUP Container Station
QNAP COSCUP Container Station
Wu Fan-Cheng
 

What's hot (20)

CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a Nutshell
 
CoreOS @Codetalks Hamburg
CoreOS @Codetalks HamburgCoreOS @Codetalks Hamburg
CoreOS @Codetalks Hamburg
 
CoreOS introduction - Johann Romefort
CoreOS introduction - Johann RomefortCoreOS introduction - Johann Romefort
CoreOS introduction - Johann Romefort
 
Couch to OpenStack: Glance - July, 23, 2013
Couch to OpenStack: Glance - July, 23, 2013Couch to OpenStack: Glance - July, 23, 2013
Couch to OpenStack: Glance - July, 23, 2013
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
 
Docker techzone
Docker techzoneDocker techzone
Docker techzone
 
2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.com2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.com
 
Containerize! Between Docker and Jube.
Containerize! Between Docker and Jube.Containerize! Between Docker and Jube.
Containerize! Between Docker and Jube.
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
 
Docker consul-registrator
Docker consul-registratorDocker consul-registrator
Docker consul-registrator
 
Docker n co
Docker n coDocker n co
Docker n co
 
Docker orchestration using core os and ansible - Ansible IL 2015
Docker orchestration using core os and ansible - Ansible IL 2015Docker orchestration using core os and ansible - Ansible IL 2015
Docker orchestration using core os and ansible - Ansible IL 2015
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Clair, A Container Image Security Analyzer
Clair, A Container Image Security AnalyzerClair, A Container Image Security Analyzer
Clair, A Container Image Security Analyzer
 
Docker build #1
Docker build #1Docker build #1
Docker build #1
 
OSS AWS 핸즈온 강의
OSS AWS 핸즈온 강의OSS AWS 핸즈온 강의
OSS AWS 핸즈온 강의
 
On MongoDB backup
On MongoDB backupOn MongoDB backup
On MongoDB backup
 
Container & kubernetes
Container & kubernetesContainer & kubernetes
Container & kubernetes
 
Couch to OpenStack: Nova - July, 30, 2013
Couch to OpenStack: Nova - July, 30, 2013Couch to OpenStack: Nova - July, 30, 2013
Couch to OpenStack: Nova - July, 30, 2013
 
QNAP COSCUP Container Station
QNAP COSCUP Container StationQNAP COSCUP Container Station
QNAP COSCUP Container Station
 

Viewers also liked

PyCon Singapore 2013 Keynote
PyCon Singapore 2013 KeynotePyCon Singapore 2013 Keynote
PyCon Singapore 2013 Keynote
Wes McKinney
 
StackWatch: A prototype CloudWatch service for CloudStack
StackWatch: A prototype CloudWatch service for CloudStackStackWatch: A prototype CloudWatch service for CloudStack
StackWatch: A prototype CloudWatch service for CloudStack
Chiradeep Vittal
 
Oracle ADF Presentation
Oracle ADF PresentationOracle ADF Presentation
Oracle ADF Presentation
Farzad Babamiri
 
DadehKavan,Mashhad,Oracle ADF,Oracle Business Architectre
DadehKavan,Mashhad,Oracle ADF,Oracle Business ArchitectreDadehKavan,Mashhad,Oracle ADF,Oracle Business Architectre
DadehKavan,Mashhad,Oracle ADF,Oracle Business Architectre
Hamed Roknizadeh
 
Webstock 2012
Webstock 2012Webstock 2012
Webstock 2012
Madalina Uceanu
 
Social media employment - Webstock 2015
Social media employment - Webstock 2015Social media employment - Webstock 2015
Social media employment - Webstock 2015
Madalina Uceanu
 
Delaware GIS Strategic Planning Workshop (10/20/09)
Delaware GIS Strategic Planning Workshop (10/20/09)Delaware GIS Strategic Planning Workshop (10/20/09)
Delaware GIS Strategic Planning Workshop (10/20/09)
Delaware Geographic Data Committee
 
Esri South Africa GIS In The Cloud
Esri South Africa GIS In The CloudEsri South Africa GIS In The Cloud
Esri South Africa GIS In The Cloud
Esri South Africa
 
Oregon Strategic Plan
Oregon Strategic PlanOregon Strategic Plan
Salariile in social media in Romania Webstock 2014
Salariile in social media in Romania Webstock 2014Salariile in social media in Romania Webstock 2014
Salariile in social media in Romania Webstock 2014
Madalina Uceanu
 
HIGICC Strategic Planning Process
HIGICC Strategic Planning ProcessHIGICC Strategic Planning Process
HIGICC Strategic Planning Process
Hawaii Geographic Information Coordinating Council
 
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best PracticesWindows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
Sriram Krishnan
 
CORS and (in)security
CORS and (in)securityCORS and (in)security
CORS and (in)security
n|u - The Open Security Community
 
Microsoft Azure 08.2014
Microsoft Azure 08.2014Microsoft Azure 08.2014
Microsoft Azure 08.2014
Mustafa Kuğu
 
Surveying
Surveying Surveying
Surveying
GAURAV. H .TANDON
 
Accenture Cloud Platform: Control, Manage and Govern the Enterprise Cloud
Accenture Cloud Platform: Control, Manage and Govern the Enterprise CloudAccenture Cloud Platform: Control, Manage and Govern the Enterprise Cloud
Accenture Cloud Platform: Control, Manage and Govern the Enterprise Cloud
accenture
 
Microsoft Azure vs Amazon Web Services (AWS) Services & Feature Mapping
Microsoft Azure vs Amazon Web Services (AWS) Services & Feature MappingMicrosoft Azure vs Amazon Web Services (AWS) Services & Feature Mapping
Microsoft Azure vs Amazon Web Services (AWS) Services & Feature Mapping
Ilyas F ☁☁☁
 
Business Plan Powerpoint 1
Business Plan Powerpoint 1Business Plan Powerpoint 1
Business Plan Powerpoint 1
haleydawn
 

Viewers also liked (18)

PyCon Singapore 2013 Keynote
PyCon Singapore 2013 KeynotePyCon Singapore 2013 Keynote
PyCon Singapore 2013 Keynote
 
StackWatch: A prototype CloudWatch service for CloudStack
StackWatch: A prototype CloudWatch service for CloudStackStackWatch: A prototype CloudWatch service for CloudStack
StackWatch: A prototype CloudWatch service for CloudStack
 
Oracle ADF Presentation
Oracle ADF PresentationOracle ADF Presentation
Oracle ADF Presentation
 
DadehKavan,Mashhad,Oracle ADF,Oracle Business Architectre
DadehKavan,Mashhad,Oracle ADF,Oracle Business ArchitectreDadehKavan,Mashhad,Oracle ADF,Oracle Business Architectre
DadehKavan,Mashhad,Oracle ADF,Oracle Business Architectre
 
Webstock 2012
Webstock 2012Webstock 2012
Webstock 2012
 
Social media employment - Webstock 2015
Social media employment - Webstock 2015Social media employment - Webstock 2015
Social media employment - Webstock 2015
 
Delaware GIS Strategic Planning Workshop (10/20/09)
Delaware GIS Strategic Planning Workshop (10/20/09)Delaware GIS Strategic Planning Workshop (10/20/09)
Delaware GIS Strategic Planning Workshop (10/20/09)
 
Esri South Africa GIS In The Cloud
Esri South Africa GIS In The CloudEsri South Africa GIS In The Cloud
Esri South Africa GIS In The Cloud
 
Oregon Strategic Plan
Oregon Strategic PlanOregon Strategic Plan
Oregon Strategic Plan
 
Salariile in social media in Romania Webstock 2014
Salariile in social media in Romania Webstock 2014Salariile in social media in Romania Webstock 2014
Salariile in social media in Romania Webstock 2014
 
HIGICC Strategic Planning Process
HIGICC Strategic Planning ProcessHIGICC Strategic Planning Process
HIGICC Strategic Planning Process
 
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best PracticesWindows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
 
CORS and (in)security
CORS and (in)securityCORS and (in)security
CORS and (in)security
 
Microsoft Azure 08.2014
Microsoft Azure 08.2014Microsoft Azure 08.2014
Microsoft Azure 08.2014
 
Surveying
Surveying Surveying
Surveying
 
Accenture Cloud Platform: Control, Manage and Govern the Enterprise Cloud
Accenture Cloud Platform: Control, Manage and Govern the Enterprise CloudAccenture Cloud Platform: Control, Manage and Govern the Enterprise Cloud
Accenture Cloud Platform: Control, Manage and Govern the Enterprise Cloud
 
Microsoft Azure vs Amazon Web Services (AWS) Services & Feature Mapping
Microsoft Azure vs Amazon Web Services (AWS) Services & Feature MappingMicrosoft Azure vs Amazon Web Services (AWS) Services & Feature Mapping
Microsoft Azure vs Amazon Web Services (AWS) Services & Feature Mapping
 
Business Plan Powerpoint 1
Business Plan Powerpoint 1Business Plan Powerpoint 1
Business Plan Powerpoint 1
 

Similar to 2013 PyCon SG - Building your cloud infrastructure with Python

From localhost to the cloud: A Journey of Deployments
From localhost to the cloud: A Journey of DeploymentsFrom localhost to the cloud: A Journey of Deployments
From localhost to the cloud: A Journey of Deployments
Tegar Imansyah
 
How automated cloud infrastructure setups can help with Continuous Delivery
How automated cloud infrastructure setups can help with Continuous DeliveryHow automated cloud infrastructure setups can help with Continuous Delivery
How automated cloud infrastructure setups can help with Continuous Delivery
Edmund Siegfried Haselwanter
 
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
Murat Yener
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
Javan Rasokat
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
Jérôme Petazzoni
 
Discovering OpenBSD on AWS
Discovering OpenBSD on AWSDiscovering OpenBSD on AWS
Discovering OpenBSD on AWS
Laurent Bernaille
 
IoT-javascript-2019-fosdem
IoT-javascript-2019-fosdemIoT-javascript-2019-fosdem
IoT-javascript-2019-fosdem
Phil www.rzr.online.fr
 
Advanced iOS Build Mechanics, Sebastien Pouliot
Advanced iOS Build Mechanics, Sebastien PouliotAdvanced iOS Build Mechanics, Sebastien Pouliot
Advanced iOS Build Mechanics, Sebastien Pouliot
Xamarin
 
Backend, app e internet das coisas com NodeJS no Google Cloud Platform
Backend, app e internet das coisas com NodeJS no Google Cloud PlatformBackend, app e internet das coisas com NodeJS no Google Cloud Platform
Backend, app e internet das coisas com NodeJS no Google Cloud Platform
Alvaro Viebrantz
 
Backend, app e internet das coisas com NodeJS no Google Cloud Platform
Backend, app e internet das coisas com NodeJS no Google Cloud PlatformBackend, app e internet das coisas com NodeJS no Google Cloud Platform
Backend, app e internet das coisas com NodeJS no Google Cloud Platform
DevMT
 
Supercharge your IOT toolbox with MQTT and Node-RED
Supercharge your IOT toolbox with MQTT and Node-REDSupercharge your IOT toolbox with MQTT and Node-RED
Supercharge your IOT toolbox with MQTT and Node-RED
Simen Sommerfeldt
 
OGCE Project Overview
OGCE Project OverviewOGCE Project Overview
OGCE Project Overview
marpierc
 
Fabric8 CI/CD
Fabric8 CI/CDFabric8 CI/CD
Fabric8 CI/CD
Izzet Mustafaiev
 
Apache Deltacloud: Speaking EC2 and CIMI to Openstack (and others)
Apache Deltacloud: Speaking EC2 and CIMI to Openstack (and others)Apache Deltacloud: Speaking EC2 and CIMI to Openstack (and others)
Apache Deltacloud: Speaking EC2 and CIMI to Openstack (and others)
lutter
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
NCCOMMS
 
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
DEF CON 27 - workshop - RICHARD GOLD - mind the gapDEF CON 27 - workshop - RICHARD GOLD - mind the gap
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
Felipe Prado
 
Programming IoT with Docker: How to Start?
Programming IoT with Docker: How to Start?Programming IoT with Docker: How to Start?
Programming IoT with Docker: How to Start?
msyukor
 
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS FargateBuilding a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
datree
 
Internals of OpenRuko PaaS, an open source Heroku clone implementation
Internals of OpenRuko PaaS, an open source Heroku clone implementationInternals of OpenRuko PaaS, an open source Heroku clone implementation
Internals of OpenRuko PaaS, an open source Heroku clone implementation
Roger Leite
 
PyWPS at COST WPS Workshop
PyWPS at COST WPS WorkshopPyWPS at COST WPS Workshop
PyWPS at COST WPS Workshop
Jachym Cepicky
 

Similar to 2013 PyCon SG - Building your cloud infrastructure with Python (20)

From localhost to the cloud: A Journey of Deployments
From localhost to the cloud: A Journey of DeploymentsFrom localhost to the cloud: A Journey of Deployments
From localhost to the cloud: A Journey of Deployments
 
How automated cloud infrastructure setups can help with Continuous Delivery
How automated cloud infrastructure setups can help with Continuous DeliveryHow automated cloud infrastructure setups can help with Continuous Delivery
How automated cloud infrastructure setups can help with Continuous Delivery
 
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
 
Discovering OpenBSD on AWS
Discovering OpenBSD on AWSDiscovering OpenBSD on AWS
Discovering OpenBSD on AWS
 
IoT-javascript-2019-fosdem
IoT-javascript-2019-fosdemIoT-javascript-2019-fosdem
IoT-javascript-2019-fosdem
 
Advanced iOS Build Mechanics, Sebastien Pouliot
Advanced iOS Build Mechanics, Sebastien PouliotAdvanced iOS Build Mechanics, Sebastien Pouliot
Advanced iOS Build Mechanics, Sebastien Pouliot
 
Backend, app e internet das coisas com NodeJS no Google Cloud Platform
Backend, app e internet das coisas com NodeJS no Google Cloud PlatformBackend, app e internet das coisas com NodeJS no Google Cloud Platform
Backend, app e internet das coisas com NodeJS no Google Cloud Platform
 
Backend, app e internet das coisas com NodeJS no Google Cloud Platform
Backend, app e internet das coisas com NodeJS no Google Cloud PlatformBackend, app e internet das coisas com NodeJS no Google Cloud Platform
Backend, app e internet das coisas com NodeJS no Google Cloud Platform
 
Supercharge your IOT toolbox with MQTT and Node-RED
Supercharge your IOT toolbox with MQTT and Node-REDSupercharge your IOT toolbox with MQTT and Node-RED
Supercharge your IOT toolbox with MQTT and Node-RED
 
OGCE Project Overview
OGCE Project OverviewOGCE Project Overview
OGCE Project Overview
 
Fabric8 CI/CD
Fabric8 CI/CDFabric8 CI/CD
Fabric8 CI/CD
 
Apache Deltacloud: Speaking EC2 and CIMI to Openstack (and others)
Apache Deltacloud: Speaking EC2 and CIMI to Openstack (and others)Apache Deltacloud: Speaking EC2 and CIMI to Openstack (and others)
Apache Deltacloud: Speaking EC2 and CIMI to Openstack (and others)
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
 
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
DEF CON 27 - workshop - RICHARD GOLD - mind the gapDEF CON 27 - workshop - RICHARD GOLD - mind the gap
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
 
Programming IoT with Docker: How to Start?
Programming IoT with Docker: How to Start?Programming IoT with Docker: How to Start?
Programming IoT with Docker: How to Start?
 
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS FargateBuilding a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
Building a dev pipeline using GitHub Actions, Node.js, and AWS ECS Fargate
 
Internals of OpenRuko PaaS, an open source Heroku clone implementation
Internals of OpenRuko PaaS, an open source Heroku clone implementationInternals of OpenRuko PaaS, an open source Heroku clone implementation
Internals of OpenRuko PaaS, an open source Heroku clone implementation
 
PyWPS at COST WPS Workshop
PyWPS at COST WPS WorkshopPyWPS at COST WPS Workshop
PyWPS at COST WPS Workshop
 

Recently uploaded

Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 

Recently uploaded (20)

Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 

2013 PyCon SG - Building your cloud infrastructure with Python

  • 1. Building your Cloud Infrastructure with Python George Goh 14 June 2013 PyCon SG 1 + 1Friday, 14 June, 13
  • 2. Agenda • Python boto • Examples • Putting it together 2 2Friday, 14 June, 13
  • 3. Using the infrastructure cloud, we the programmers: • see infrastructure as code. • are able to version our infrastructure configs, just like software. • can experiment with different deployment topologies as easily as experimenting with different algorithms. 3 3Friday, 14 June, 13
  • 5. A Simple Example 1 5 1. Create an AWS EC2 instance in Singapore. 2. Using SSH-only login. 3. With firewall closing all ports except port 22 (for SSH). 5Friday, 14 June, 13
  • 6. A Simple Example 1 6 import time from boto.ec2 import connect_to_region   ec2_conn = connect_to_region("ap-southeast-1")   # create security group allowing SSH. demo_sg = ec2_conn.create_security_group("demo-sg", "Demo Sec Group") demo_sg.authorize("tcp", 22, 22, "0.0.0.0/0")   # create and save a public key for SSH login. demo_key = ec2_conn.create_key_pair("demo-key") demo_key.save(".")   # create the an instance using AMZN Linux. resrv = ec2_conn.run_instances("ami-fade91a8",                                key_name="demo-key",                                instance_type="t1.micro",                                security_groups=["demo-sg"])   # get the demo instance IP address. demo = resrv.instances[0] while demo.update() != 'running':     time.sleep(1) print demo.ip_address 6Friday, 14 June, 13
  • 7. boto • http://docs.pythonboto.org/ • https://github.com/boto/boto • It’s a python interface to Amazon Web Services (AWS). 7 7Friday, 14 June, 13
  • 8. Helicoptor view of boto • Compute • Elastic Compute Cloud (EC2) • Elastic MapReduce (EMR) • Auto Scaling • Data Pipeline • Elastic Transcoder • Content Delivery • CloudFront • Database • SimpleDB • DynamoDB2 • DynamoDB • Relational Data Services (RDS) • ElastiCache • Redshift • Deployment and Management • CloudFormation • ElasticBeanstalk • Identity & Access • Identity and Access Management (IAM) • Security Token Service (STS) 8 • Application Services • Simple Workflow Service (SWF) • Simple Queue Service (SQS) • Simple Notification Service (SNS) • Simple Email Service (SES) • Cloudsearch • Monitoring • CloudWatch • Networking • Route 53 • Virtual Private Cloud (VPC) • Elastic Load Balancer (ELB) • Payments & Billing • Flexible Payments Service • Storage • Simple Storage Service (S3) • Amazon Glacier • Google Cloud Storage • Workforce • Mechanical Turk • Other • Marketplace Web Services 8Friday, 14 June, 13
  • 9. A Simple Example 2 9 1. Create an S3 bucket in Singapore. 2. Make it open for putting images. 9Friday, 14 June, 13
  • 10. A Simple Example 2 10 import boto from boto.s3.cors import CORSConfiguration   s3_conn = boto.connect_s3()   # create bucket with _globally_unique_ name. bucket = s3_conn.create_bucket("unique_name", location="ap-southeast-1")   # create CORS config. cors = CORSConfiguration() cors.add_rule(allowed_method="GET", allowed_origin="*", allowed_header="*") cors.add_rule(allowed_method="POST", allowed_origin="*", allowed_header="*") cors.add_rule(allowed_method="PUT", allowed_origin="*", allowed_header="*")   # apply CORS config to our bucket. bucket.set_cors(cors) 10Friday, 14 June, 13
  • 13. 13 Photo Uploader • Flask application on EC2 instance • https://github.com/georgegoh/FlaskDirectUploader • S3 bucket to store photos 13Friday, 14 June, 13
  • 14. Instance initialization • Do the following when an instance is created: • install software prerequisites • clone the code from github • initialize environment variables • run the server 14 14Friday, 14 June, 13
  • 15. Instance init - init.sh 15 #!/bin/sh   # Install software prerequisites. yum install -y git easy_install flask   # Clone the code from github. git clone https://github.com/georgegoh/FlaskDirectUploader   # Initialize environment variables. BTW, these creds will be deleted export AWS_ACCESS_KEY_ID=AKIAJH6C25DY6YS3Q7UQ export AWS_SECRET_ACCESS_KEY=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 export S3_BUCKET=george.goh-pyconsg2013   # Run the server. cd FlaskDirectUploader python application.py 15Friday, 14 June, 13
  • 16. Instance Initialization 16 • Attach init.sh to EC2 instance as user-data. • init.sh runs once when the instance is created. 16Friday, 14 June, 13
  • 17. Modified from Simple Example 1 17 import time import base64 from boto.ec2 import connect_to_region   ec2_conn = connect_to_region("ap-southeast-1")   # create security group allowing SSH and WWW. demo_sg = ec2_conn.create_security_group("demo-sg", "Demo Sec Group") demo_sg.authorize("tcp", 22, 22, "0.0.0.0/0") demo_sg.authorize("tcp", 80, 80, "0.0.0.0/0")   # create and save a public key for SSH login. demo_key = ec2_conn.create_key_pair("demo-key") demo_key.save(".")   # Base64 encode the userdata. with open('init.sh') as f:     userdata = f.read()   # create the an instance using AMZN Linux. resrv = ec2_conn.run_instances("ami-fade91a8",                                key_name="demo-key",                                instance_type="t1.micro",                                security_groups=["demo-sg"],                                user_data=userdata)   # get the demo instance IP address. demo = resrv.instances[0] while demo.update() != 'running':     time.sleep(1) print demo.ip_address 17Friday, 14 June, 13
  • 19. Recap • boto • createVM instances • create storage • use user-data to initializeVM instances • too much to cover here 19 19Friday, 14 June, 13
  • 20. What to do next • fabric - http://docs.fabfile.org • saltstack - http://saltstack.com/ • CloudFormation - http://aws.amazon.com/ cloudformation/ 20 20Friday, 14 June, 13