SlideShare a Scribd company logo
Paws – A Perl AWS SDK
@pplu_io
03/09/2015 - Granada
YAPC::EU 2015
Jose Luis Martinez
AWS is…
• Cloud Computing
• Consume computing/database/queuing/etc services via an API
• Everything is an API 
AWS is…
Programmers wet dream
Why?
Isn’t there support for AWS on CPAN?
AWS Services on CPAN
• There are a LOT
• EC2, SQS, S3, RDS, DynamoDB, etc
• But lots are were missing
• AWS::CLIWrapper is a generic solution too
• Shells off to the oficial AWS CLI (python)
I want Perl support for ALL of them
Different authors, different opinions
• Default region (eu-west-1 for some, us-east-1 for others)
• Different HTTP clients
• LWP, HTTP::Tiny, Furl, etc
I want explicit, required, region. Croak if not specified
Pluggable HTTP client?
Paws - A Perl AWS SDK
Paws - A Perl AWS SDK
Different authors, different photo
• Some regions not supported due to bugs
• Subtle name changes in region endpoints
• Credential handling
• Module just covers their needs
I want as broad support as we can get
Credential handling
• Roles in AWS help you not have to distribute credentials (AccessKey
and SecretKey)
• Support depends on author of module knowing of them / needing them
I want support for Instance Roles, STS AssumeRole, Federation for all
services
UpToDate-ness
• Being up to date depends on authors needs, time, etc
• AWS APIs are updated a lot
I want up to date APIs
Lets write an SDK!
Paws - A Perl AWS SDK
Some numbers
52 services
Some numbers
52 services
~1600 actions
Some numbers
52 services
~1600 actions
~3700 distinct input/output objects
Some numbers
52 services
~1600 actions
~3700 distinct input/output objects
~12000 attributes
Paws - A Perl AWS SDK
Write by hand?
Write by hand?
Paws is autogenerated
Paws - A Perl AWS SDK
Paws is autogenerated
• AWS has some JSON definition files in their SDKs (data-driven)
• Pick them up to generate classes for:
• Actions
• Inputs to actions (parameters)
• Outputs from actions (outputs)
• HTML documentation -> POD
make gen-classes
Paws - A Perl AWS SDK
Code generators
• In builder-lib (not distributed on CPAN)
• Paws::API::Builder
• Paws::API::Builder::EC2
• Paws::API::Builder::query
• Paws::API::Builder::json
• Paws::API::Builder::restjson
• Paws::API::Builder::restxml
• Leaves all auto-generated code in auto-lib (distributed on CPAN)
• Hand-written code is in lib
Note: this is not needed if you only want to use Paws. This is intended for developers. We’ll see more internals later 
Using Paws
Each AWS API is a “Service Class”
• Each Action in the API is a method on the Service Class
• EC2 API -> Paws::EC2 service class
• Paws::EC2 objects have methods like
• RunInstances
• TerminateInstances
• DescribeInstances
How do I get an instance of a service
class?
use Paws;
my $ec2 = Paws->service(‘EC2’, region => ‘eu-west-1’);
my $iam = Paws->service(‘IAM’);
# $ec2 and $iam are instances of Paws::EC2 and
Paws::IAM
# they use Paws default config (they just work )
How do I get an instance of a service
class? (II)
my $paws = Paws->new(config => {
region => ‘eu-west-1’,
caller => ‘Paws::Net::LWPCaller’,
credentials => ‘My::Custom::Credential::Provider’
});
my $ec2 = $paws->service(‘EC2’);
# ec2 is bound to region ‘eu-west-1’
# and called with LWP
# and gets it’s credentials from some custom source
Calling a method
$ec2->Method1(
Param1 => ‘Something’,
Param2 => 42,
Complex1 => {
x => 1,
y => 2,
z => 3
},
Complex2 => [
{ x => 1, y => 2 },
{ x => 2, y => 3 }
])
Calling a method
$ec2->Method1(
Param1 => ‘Something’,
Param2 => 42,
Complex1 => {
x => 1,
y => 2,
z => 3
},
Complex2 => [
{ x => 1, y => 2 },
{ x => 2, y => 3 }
])
Docs tell you that this is a Paws::Service::XXX object, but you don’t have
to instance it !!!
Just pass the attributes and the values as a hashref 
Calling a method: maps
• Arbitrary key/value pairs
• Don’t build an object either. Paws will handle it for you
• $ec2->Method1(
Map1 => {
x => 1,
y => 2,
z => 3
});
Methods return objects
my $object = $x->Method1(…)
Method1 returns Paws::Service::Method1Result
has ‘X’, has ‘Y’, has ‘Complex’ => (isa => ‘Paws::Service::Complex1’)
$object->X
$object->Complex->Complex1Attribute
Tricks
Tricks: CLI
• Paws ships with a CLI
paws SERVICE --region xx-east-1 DescribeFoo Arg1 Val1
Uses ARGV::Struct to convey nested datastructures via command line
Tricks: open_aws_console
• Opens a browser with the AWS console (using the SignIn service)
• Uses your current credentials (extends a temporary token)
Tricks: Changing endpoints
my $predictor = $paws->service('ML', region_rules =>
[ { uri => $endpoint_url } ]);
• Works for any service: SQS, EC2…
Tricks: Credential providers
• Default one tries to behave like AWS SDKs
• Environment (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY)
• File (~/.aws/credentials, an ini file)
• From the metadata service (Instance Roles)
• Your own
• Just attach Role “Paws::Credential” and get the credentials from wherever
Internals
Note: actual implementation as of Sept 2015
Read the code / changelog to get a hold of changes
Paws - A Perl AWS SDK
Each method has parameters
• Parameters are converted into Moose objects for validation
package Paws::EC2
sub Method(Param1 => Str, Param2 => Int)
Coerces its @_ into Paws::EC2::Method (has ‘Param1’, has
‘Param2’)
Note: not using Moose coercion. Using new_with_coercions
Each method has parameters
• Parameters are converted into Moose objects for validation
package Paws::EC2
sub Method(Param3 => Complex1)
Complex1 has it’s own “input class”
Paws::EC2::Complex1 has [‘X’, ‘Y’, ‘Z’ ]
new_with_coercions knows how to coerce { x => 1, y => 2, z => 3 }
into a Paws::EC2::Complex1
After coercing parameters into an object
• $self->caller->do_call($self, $call_object)
• Service classes have a “caller”. Caller is defined when constructing the
service object.
• Callers are responsable for
• Getting a Paws::Net::APIRequest (via prepare_request_for_call)
• Prepare_request_for_call is specialized for each type of service in Paws::Net::*Caller roles
• Doing I/O
• Paws::Net::Caller uses HTTP::Tiny (Paws default)
• Paws::Net::LWPCaller uses LWP (contributed)
• Paws::Net::MojoAsyncCaller uses Mojo::UserAgent (experimental)
• Passing results to handle_response
Call Object to APIRequest
(prepare_request_for_call)
• Looks in the call object where it has to place parameters to the API
• Headers
• In a serialized body
• JSON
• Query Parameters
• Arrays get coded in f(x) of the API
• att.0=xxx
• att.members.0=xxx
• In the body
• In the URL (REST APIs)
• Signs the request (via roles that know how to sign for that service)
handle_response
• Takes a look if there were error conditions in the HTTP call
• Future: should determine how to retry
• Deserializes the response
• XML
• JSON
• Deserializes into objects
• Note: sometimes decides it wants an exception
• Doesn’t throw: just creates an exception object
Callers
• Do the IO
• Have to handle some common logic (still)
• Asyc callers don’t need to return the result immediately
• The experimental Mojo caller returns a Future 
• The future fails if the result was an exception
Future
Paws - A Perl AWS SDK
Future (hint: help needed and accepted)
• Testing Async stuff
• Retrying
• Some APIs return temporary failures
• Want automatic exponential backoff with jitter
• Paging
• Some APIs return paged results
• Want a “give me all of them”
• Waiters
• Wait until some condition is met
• Want a call to wait until Instance is in running state
• A lot more: take a look at GitHub issues
Future (hint: help needed and accepted)
• Object Oriented results
• $ec2->TerminateInstances(InstanceIds => [ ‘i-12345678’ ])
• $instance->Terminate
• Special properties
• En/Decode base64, URIescape, etc
• Better access to ArrayRefs
• Use ArrayRef Moose trait for
• Number of elements
• Get element i
• Get list of elements
Future (hint: help needed and accepted)
• Refactoring generator clases
• MooseX::DataModel
• Template::Toolkit
• Split Paws into separately instalable modules
• Rinse and Repeat
• For other APIs
• AWS API as a Service
Support for APIs
0
5
10
15
20
25
30
35
40
45
50
REST Plain
Types of APIs
Query+XML JSON EC2
Support for APIs
0
5
10
15
20
25
30
35
40
45
50
REST Plain
Types of APIs
Query+XML JSON EC2
Implemented
Support for APIs
0
5
10
15
20
25
30
35
40
45
50
REST Plain
Types of APIs
Query+XML JSON EC2
Implemented
Need love and testing
S3 not working
Route53?
Lambda?
…
Fork your heart out
https://github.com/pplu/aws-sdk-perl/
Contact me:
Twitter: @pplu_io
Mail: joseluis.martinez@capside.com
CPAN: JLMARTIN
CAPSiDE
Twitter: @capside
Mail: hello@capside.com

More Related Content

PDF
AI-driven product innovation: from Recommender Systems to COVID-19
Xavier Amatriain
 
PPT
UNIT-1-PPTS-DAA.ppt
racha49
 
PPTX
Quantum computing COMPLETE LECTURE
SMALAIAPPANSRIKANTH
 
PPTX
ARTIFICIAL INTELLIGENCE ppt.pptx
VinodhKumar658343
 
PDF
Natural Language Processing in Artificial Intelligence - Codeup #5 - PayU
Artivatic.ai
 
PPT
Hidden Markov Models with applications to speech recognition
butest
 
PPT
Chapter 6 Intermediate Code Generation
Radhakrishnan Chinnusamy
 
PDF
Interactions in Multi Agent Systems
SSA KPI
 
AI-driven product innovation: from Recommender Systems to COVID-19
Xavier Amatriain
 
UNIT-1-PPTS-DAA.ppt
racha49
 
Quantum computing COMPLETE LECTURE
SMALAIAPPANSRIKANTH
 
ARTIFICIAL INTELLIGENCE ppt.pptx
VinodhKumar658343
 
Natural Language Processing in Artificial Intelligence - Codeup #5 - PayU
Artivatic.ai
 
Hidden Markov Models with applications to speech recognition
butest
 
Chapter 6 Intermediate Code Generation
Radhakrishnan Chinnusamy
 
Interactions in Multi Agent Systems
SSA KPI
 

What's hot (20)

PPTX
Computability - Tractable, Intractable and Non-computable Function
Reggie Niccolo Santos
 
PDF
Recurrence relation solutions
subhashchandra197
 
DOC
vishal_sharma: python email sending software
vishal sharma
 
PPT
Greedy Algorihm
Muhammad Amjad Rana
 
PPTX
Asymptotic Notation and Data Structures
Amrinder Arora
 
PPTX
Word2 vec
ankit_ppt
 
PPTX
Knowledge representation
Md. Tanvir Masud
 
PPT
Basic Garbage Collection Techniques
An Khuong
 
PPTX
Computability, turing machines and lambda calculus
Edward Blurock
 
PPT
Intelligent agents
Karam Munir Butt
 
PPTX
Neuro-Fuzzy Controller
Ishwar Bhoge
 
PPT
Greedy algorithms
Rajendran
 
PPTX
Hate speech detection
NASIM ALAM
 
PPT
Hebbian Learning
ESCOM
 
PPTX
Heuristics Search Techniques in AI
Bharat Bhushan
 
PPT
Primitive Recursive Functions
Radhakrishnan Chinnusamy
 
PPTX
Forward and Backward chaining in AI
Megha Sharma
 
PDF
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
EditorIJAERD
 
PPTX
Software Educativo
Evelyn López
 
PPTX
Quantum error correcting codes
bhaskar reddy gurram
 
Computability - Tractable, Intractable and Non-computable Function
Reggie Niccolo Santos
 
Recurrence relation solutions
subhashchandra197
 
vishal_sharma: python email sending software
vishal sharma
 
Greedy Algorihm
Muhammad Amjad Rana
 
Asymptotic Notation and Data Structures
Amrinder Arora
 
Word2 vec
ankit_ppt
 
Knowledge representation
Md. Tanvir Masud
 
Basic Garbage Collection Techniques
An Khuong
 
Computability, turing machines and lambda calculus
Edward Blurock
 
Intelligent agents
Karam Munir Butt
 
Neuro-Fuzzy Controller
Ishwar Bhoge
 
Greedy algorithms
Rajendran
 
Hate speech detection
NASIM ALAM
 
Hebbian Learning
ESCOM
 
Heuristics Search Techniques in AI
Bharat Bhushan
 
Primitive Recursive Functions
Radhakrishnan Chinnusamy
 
Forward and Backward chaining in AI
Megha Sharma
 
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
EditorIJAERD
 
Software Educativo
Evelyn López
 
Quantum error correcting codes
bhaskar reddy gurram
 
Ad

Viewers also liked (20)

PPTX
Paws - Perl AWS SDK Update - November 2015
Jose Luis Martínez
 
PPTX
Perl and AWS
Jose Luis Martínez
 
PPTX
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
Jose Luis Martínez
 
PPTX
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
Jose Luis Martínez
 
PPTX
Boosting MySQL (for starters)
Jose Luis Martínez
 
PPTX
Building an aws sdk for Perl - Granada Perl Workshop 2014
Jose Luis Martínez
 
PPTX
Plenv and carton
Jose Luis Martínez
 
PDF
How To Use Blogger
Marcus9000
 
PPSX
Proposal
ramcoza
 
PPTX
Bloedsomloop versie 1.0
RIBW Arnhem & Veluwe Vallei
 
PDF
Arxaia b gymn
Efi Manousaka
 
PPTX
Feedback from the first versions of my music
kamar95
 
PDF
Huidobro&Sepulveda_2010
Ernesto Sepulveda
 
PDF
introduccion
Ernesto Sepulveda
 
PPT
Grade 8 9 course selection 2014-2015
SteveAyling
 
PPTX
My music based magazine evaluation
kamar95
 
PPT
Daniel & Ernesto's presentation
Ernesto Sepulveda
 
PPT
Pptplan morgenjuli2011 pptbehandelcoordinatoren
RIBW Arnhem & Veluwe Vallei
 
PPT
Make Extra Income Online
webwhisker
 
PDF
Polifonia_6.16
Ernesto Sepulveda
 
Paws - Perl AWS SDK Update - November 2015
Jose Luis Martínez
 
Perl and AWS
Jose Luis Martínez
 
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
Jose Luis Martínez
 
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
Jose Luis Martínez
 
Boosting MySQL (for starters)
Jose Luis Martínez
 
Building an aws sdk for Perl - Granada Perl Workshop 2014
Jose Luis Martínez
 
Plenv and carton
Jose Luis Martínez
 
How To Use Blogger
Marcus9000
 
Proposal
ramcoza
 
Bloedsomloop versie 1.0
RIBW Arnhem & Veluwe Vallei
 
Arxaia b gymn
Efi Manousaka
 
Feedback from the first versions of my music
kamar95
 
Huidobro&Sepulveda_2010
Ernesto Sepulveda
 
introduccion
Ernesto Sepulveda
 
Grade 8 9 course selection 2014-2015
SteveAyling
 
My music based magazine evaluation
kamar95
 
Daniel & Ernesto's presentation
Ernesto Sepulveda
 
Pptplan morgenjuli2011 pptbehandelcoordinatoren
RIBW Arnhem & Veluwe Vallei
 
Make Extra Income Online
webwhisker
 
Polifonia_6.16
Ernesto Sepulveda
 
Ad

Similar to Paws - A Perl AWS SDK (20)

KEY
DjangoCon 2010 Scaling Disqus
zeeg
 
KEY
Counters with Riak on Amazon EC2 at Hackover
Andrei Savu
 
PDF
AWS Lambda at JUST EAT
Andrew Brown
 
PDF
10 minutes fun with Cloud API comparison
Laurent Cerveau
 
PPTX
Containerize all the things!
Mike Melusky
 
PDF
A 60-mn tour of AWS compute (March 2016)
Julien SIMON
 
PPTX
Кирилл Безпалый, .NET Developer, Ciklum
Alina Vilk
 
PPTX
Meteor Boulder meetup #1
Robert Dickert
 
PDF
Nyc big datagenomics-pizarroa-sept2017
delagoya
 
KEY
Introdution to Node.js
Ariejan de Vroom
 
PPTX
Java 8
Raghda Salah
 
PPTX
Workflow All the Things with Azure Logic Apps
Josh Lane
 
PDF
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
Amazon Web Services Japan
 
PDF
Lecture: Advanced Reflection. MetaLinks
Marcus Denker
 
PDF
Treasure Data Summer Internship 2016
Yuta Iwama
 
PDF
Lecture. Advanced Reflection: MetaLinks
Marcus Denker
 
PPTX
AWS Batch: Simplifying batch computing in the cloud
Adrian Hornsby
 
PDF
Amazon Web Services for PHP Developers
Jeremy Lindblom
 
PDF
Building Dynamic AWS Lambda Applications with BoxLang
Ortus Solutions, Corp
 
PDF
Building Dynamic AWS Lambda Applications with BoxLang
Ortus Solutions, Corp
 
DjangoCon 2010 Scaling Disqus
zeeg
 
Counters with Riak on Amazon EC2 at Hackover
Andrei Savu
 
AWS Lambda at JUST EAT
Andrew Brown
 
10 minutes fun with Cloud API comparison
Laurent Cerveau
 
Containerize all the things!
Mike Melusky
 
A 60-mn tour of AWS compute (March 2016)
Julien SIMON
 
Кирилл Безпалый, .NET Developer, Ciklum
Alina Vilk
 
Meteor Boulder meetup #1
Robert Dickert
 
Nyc big datagenomics-pizarroa-sept2017
delagoya
 
Introdution to Node.js
Ariejan de Vroom
 
Java 8
Raghda Salah
 
Workflow All the Things with Azure Logic Apps
Josh Lane
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
Amazon Web Services Japan
 
Lecture: Advanced Reflection. MetaLinks
Marcus Denker
 
Treasure Data Summer Internship 2016
Yuta Iwama
 
Lecture. Advanced Reflection: MetaLinks
Marcus Denker
 
AWS Batch: Simplifying batch computing in the cloud
Adrian Hornsby
 
Amazon Web Services for PHP Developers
Jeremy Lindblom
 
Building Dynamic AWS Lambda Applications with BoxLang
Ortus Solutions, Corp
 
Building Dynamic AWS Lambda Applications with BoxLang
Ortus Solutions, Corp
 

More from Jose Luis Martínez (10)

PDF
Being cloudy with perl
Jose Luis Martínez
 
PPTX
Modern Perl toolchain (help building microservices)
Jose Luis Martínez
 
PDF
Escribir plugins para Nagios en Perl
Jose Luis Martínez
 
PPTX
NRD: Nagios Result Distributor
Jose Luis Martínez
 
PDF
Writing nagios plugins in perl
Jose Luis Martínez
 
PPTX
Ficheros y directorios
Jose Luis Martínez
 
PPTX
DBIx::Class
Jose Luis Martínez
 
PPTX
The modern perl toolchain
Jose Luis Martínez
 
PPTX
Introducción a las Expresiones Regulares
Jose Luis Martínez
 
Being cloudy with perl
Jose Luis Martínez
 
Modern Perl toolchain (help building microservices)
Jose Luis Martínez
 
Escribir plugins para Nagios en Perl
Jose Luis Martínez
 
NRD: Nagios Result Distributor
Jose Luis Martínez
 
Writing nagios plugins in perl
Jose Luis Martínez
 
Ficheros y directorios
Jose Luis Martínez
 
DBIx::Class
Jose Luis Martínez
 
The modern perl toolchain
Jose Luis Martínez
 
Introducción a las Expresiones Regulares
Jose Luis Martínez
 

Recently uploaded (20)

PPTX
Perkembangan Perangkat jaringan komputer dan telekomunikasi 3.pptx
Prayudha3
 
PPTX
Pengenalan perangkat Jaringan komputer pada teknik jaringan komputer dan tele...
Prayudha3
 
PDF
Data Protection & Resilience in Focus.pdf
AmyPoblete3
 
PPT
Transformaciones de las funciones elementales.ppt
rirosel211
 
PPTX
Google SGE SEO: 5 Critical Changes That Could Wreck Your Rankings in 2025
Reversed Out Creative
 
PDF
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
PDF
BGP Security Best Practices that Matter, presented at PHNOG 2025
APNIC
 
PPTX
Black Yellow Modern Minimalist Elegant Presentation.pptx
nothisispatrickduhh
 
PPTX
Crypto Recovery California Services.pptx
lionsgate network
 
PPTX
Blue and Dark Blue Modern Technology Presentation.pptx
ap177979
 
PPTX
How tech helps people in the modern era.
upadhyayaryan154
 
PDF
PDF document: World Game (s) Great Redesign.pdf
Steven McGee
 
PPT
Introduction to dns domain name syst.ppt
MUHAMMADKAVISHSHABAN
 
PDF
DNSSEC Made Easy, presented at PHNOG 2025
APNIC
 
PDF
KIPER4D situs Exclusive Game dari server Star Gaming Asia
hokimamad0
 
PPTX
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
PPTX
原版北不列颠哥伦比亚大学毕业证文凭UNBC成绩单2025年新版在线制作学位证书
e7nw4o4
 
PDF
LB# 820-1889_051-7370_C000.schematic.pdf
matheusalbuquerqueco3
 
PPTX
LESSON-2-Roles-of-ICT-in-Teaching-for-learning_123922 (1).pptx
renavieramopiquero
 
PDF
Latest Scam Shocking the USA in 2025.pdf
onlinescamreport4
 
Perkembangan Perangkat jaringan komputer dan telekomunikasi 3.pptx
Prayudha3
 
Pengenalan perangkat Jaringan komputer pada teknik jaringan komputer dan tele...
Prayudha3
 
Data Protection & Resilience in Focus.pdf
AmyPoblete3
 
Transformaciones de las funciones elementales.ppt
rirosel211
 
Google SGE SEO: 5 Critical Changes That Could Wreck Your Rankings in 2025
Reversed Out Creative
 
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
BGP Security Best Practices that Matter, presented at PHNOG 2025
APNIC
 
Black Yellow Modern Minimalist Elegant Presentation.pptx
nothisispatrickduhh
 
Crypto Recovery California Services.pptx
lionsgate network
 
Blue and Dark Blue Modern Technology Presentation.pptx
ap177979
 
How tech helps people in the modern era.
upadhyayaryan154
 
PDF document: World Game (s) Great Redesign.pdf
Steven McGee
 
Introduction to dns domain name syst.ppt
MUHAMMADKAVISHSHABAN
 
DNSSEC Made Easy, presented at PHNOG 2025
APNIC
 
KIPER4D situs Exclusive Game dari server Star Gaming Asia
hokimamad0
 
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
原版北不列颠哥伦比亚大学毕业证文凭UNBC成绩单2025年新版在线制作学位证书
e7nw4o4
 
LB# 820-1889_051-7370_C000.schematic.pdf
matheusalbuquerqueco3
 
LESSON-2-Roles-of-ICT-in-Teaching-for-learning_123922 (1).pptx
renavieramopiquero
 
Latest Scam Shocking the USA in 2025.pdf
onlinescamreport4
 

Paws - A Perl AWS SDK

  • 1. Paws – A Perl AWS SDK @pplu_io 03/09/2015 - Granada YAPC::EU 2015 Jose Luis Martinez
  • 2. AWS is… • Cloud Computing • Consume computing/database/queuing/etc services via an API • Everything is an API 
  • 4. Why? Isn’t there support for AWS on CPAN?
  • 5. AWS Services on CPAN • There are a LOT • EC2, SQS, S3, RDS, DynamoDB, etc • But lots are were missing • AWS::CLIWrapper is a generic solution too • Shells off to the oficial AWS CLI (python) I want Perl support for ALL of them
  • 6. Different authors, different opinions • Default region (eu-west-1 for some, us-east-1 for others) • Different HTTP clients • LWP, HTTP::Tiny, Furl, etc I want explicit, required, region. Croak if not specified Pluggable HTTP client?
  • 9. Different authors, different photo • Some regions not supported due to bugs • Subtle name changes in region endpoints • Credential handling • Module just covers their needs I want as broad support as we can get
  • 10. Credential handling • Roles in AWS help you not have to distribute credentials (AccessKey and SecretKey) • Support depends on author of module knowing of them / needing them I want support for Instance Roles, STS AssumeRole, Federation for all services
  • 11. UpToDate-ness • Being up to date depends on authors needs, time, etc • AWS APIs are updated a lot I want up to date APIs
  • 16. Some numbers 52 services ~1600 actions ~3700 distinct input/output objects
  • 17. Some numbers 52 services ~1600 actions ~3700 distinct input/output objects ~12000 attributes
  • 23. Paws is autogenerated • AWS has some JSON definition files in their SDKs (data-driven) • Pick them up to generate classes for: • Actions • Inputs to actions (parameters) • Outputs from actions (outputs) • HTML documentation -> POD make gen-classes
  • 25. Code generators • In builder-lib (not distributed on CPAN) • Paws::API::Builder • Paws::API::Builder::EC2 • Paws::API::Builder::query • Paws::API::Builder::json • Paws::API::Builder::restjson • Paws::API::Builder::restxml • Leaves all auto-generated code in auto-lib (distributed on CPAN) • Hand-written code is in lib Note: this is not needed if you only want to use Paws. This is intended for developers. We’ll see more internals later 
  • 27. Each AWS API is a “Service Class” • Each Action in the API is a method on the Service Class • EC2 API -> Paws::EC2 service class • Paws::EC2 objects have methods like • RunInstances • TerminateInstances • DescribeInstances
  • 28. How do I get an instance of a service class? use Paws; my $ec2 = Paws->service(‘EC2’, region => ‘eu-west-1’); my $iam = Paws->service(‘IAM’); # $ec2 and $iam are instances of Paws::EC2 and Paws::IAM # they use Paws default config (they just work )
  • 29. How do I get an instance of a service class? (II) my $paws = Paws->new(config => { region => ‘eu-west-1’, caller => ‘Paws::Net::LWPCaller’, credentials => ‘My::Custom::Credential::Provider’ }); my $ec2 = $paws->service(‘EC2’); # ec2 is bound to region ‘eu-west-1’ # and called with LWP # and gets it’s credentials from some custom source
  • 30. Calling a method $ec2->Method1( Param1 => ‘Something’, Param2 => 42, Complex1 => { x => 1, y => 2, z => 3 }, Complex2 => [ { x => 1, y => 2 }, { x => 2, y => 3 } ])
  • 31. Calling a method $ec2->Method1( Param1 => ‘Something’, Param2 => 42, Complex1 => { x => 1, y => 2, z => 3 }, Complex2 => [ { x => 1, y => 2 }, { x => 2, y => 3 } ]) Docs tell you that this is a Paws::Service::XXX object, but you don’t have to instance it !!! Just pass the attributes and the values as a hashref 
  • 32. Calling a method: maps • Arbitrary key/value pairs • Don’t build an object either. Paws will handle it for you • $ec2->Method1( Map1 => { x => 1, y => 2, z => 3 });
  • 33. Methods return objects my $object = $x->Method1(…) Method1 returns Paws::Service::Method1Result has ‘X’, has ‘Y’, has ‘Complex’ => (isa => ‘Paws::Service::Complex1’) $object->X $object->Complex->Complex1Attribute
  • 35. Tricks: CLI • Paws ships with a CLI paws SERVICE --region xx-east-1 DescribeFoo Arg1 Val1 Uses ARGV::Struct to convey nested datastructures via command line
  • 36. Tricks: open_aws_console • Opens a browser with the AWS console (using the SignIn service) • Uses your current credentials (extends a temporary token)
  • 37. Tricks: Changing endpoints my $predictor = $paws->service('ML', region_rules => [ { uri => $endpoint_url } ]); • Works for any service: SQS, EC2…
  • 38. Tricks: Credential providers • Default one tries to behave like AWS SDKs • Environment (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) • File (~/.aws/credentials, an ini file) • From the metadata service (Instance Roles) • Your own • Just attach Role “Paws::Credential” and get the credentials from wherever
  • 39. Internals Note: actual implementation as of Sept 2015 Read the code / changelog to get a hold of changes
  • 41. Each method has parameters • Parameters are converted into Moose objects for validation package Paws::EC2 sub Method(Param1 => Str, Param2 => Int) Coerces its @_ into Paws::EC2::Method (has ‘Param1’, has ‘Param2’) Note: not using Moose coercion. Using new_with_coercions
  • 42. Each method has parameters • Parameters are converted into Moose objects for validation package Paws::EC2 sub Method(Param3 => Complex1) Complex1 has it’s own “input class” Paws::EC2::Complex1 has [‘X’, ‘Y’, ‘Z’ ] new_with_coercions knows how to coerce { x => 1, y => 2, z => 3 } into a Paws::EC2::Complex1
  • 43. After coercing parameters into an object • $self->caller->do_call($self, $call_object) • Service classes have a “caller”. Caller is defined when constructing the service object. • Callers are responsable for • Getting a Paws::Net::APIRequest (via prepare_request_for_call) • Prepare_request_for_call is specialized for each type of service in Paws::Net::*Caller roles • Doing I/O • Paws::Net::Caller uses HTTP::Tiny (Paws default) • Paws::Net::LWPCaller uses LWP (contributed) • Paws::Net::MojoAsyncCaller uses Mojo::UserAgent (experimental) • Passing results to handle_response
  • 44. Call Object to APIRequest (prepare_request_for_call) • Looks in the call object where it has to place parameters to the API • Headers • In a serialized body • JSON • Query Parameters • Arrays get coded in f(x) of the API • att.0=xxx • att.members.0=xxx • In the body • In the URL (REST APIs) • Signs the request (via roles that know how to sign for that service)
  • 45. handle_response • Takes a look if there were error conditions in the HTTP call • Future: should determine how to retry • Deserializes the response • XML • JSON • Deserializes into objects • Note: sometimes decides it wants an exception • Doesn’t throw: just creates an exception object
  • 46. Callers • Do the IO • Have to handle some common logic (still) • Asyc callers don’t need to return the result immediately • The experimental Mojo caller returns a Future  • The future fails if the result was an exception
  • 49. Future (hint: help needed and accepted) • Testing Async stuff • Retrying • Some APIs return temporary failures • Want automatic exponential backoff with jitter • Paging • Some APIs return paged results • Want a “give me all of them” • Waiters • Wait until some condition is met • Want a call to wait until Instance is in running state • A lot more: take a look at GitHub issues
  • 50. Future (hint: help needed and accepted) • Object Oriented results • $ec2->TerminateInstances(InstanceIds => [ ‘i-12345678’ ]) • $instance->Terminate • Special properties • En/Decode base64, URIescape, etc • Better access to ArrayRefs • Use ArrayRef Moose trait for • Number of elements • Get element i • Get list of elements
  • 51. Future (hint: help needed and accepted) • Refactoring generator clases • MooseX::DataModel • Template::Toolkit • Split Paws into separately instalable modules • Rinse and Repeat • For other APIs • AWS API as a Service
  • 52. Support for APIs 0 5 10 15 20 25 30 35 40 45 50 REST Plain Types of APIs Query+XML JSON EC2
  • 53. Support for APIs 0 5 10 15 20 25 30 35 40 45 50 REST Plain Types of APIs Query+XML JSON EC2 Implemented
  • 54. Support for APIs 0 5 10 15 20 25 30 35 40 45 50 REST Plain Types of APIs Query+XML JSON EC2 Implemented Need love and testing S3 not working Route53? Lambda? …
  • 55. Fork your heart out https://github.com/pplu/aws-sdk-perl/ Contact me: Twitter: @pplu_io Mail: [email protected] CPAN: JLMARTIN CAPSiDE Twitter: @capside Mail: [email protected]