SlideShare uma empresa Scribd logo
1 de 55
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?
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!
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
Write by hand?
Write by hand?
Paws is autogenerated
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
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
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
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

Mais conteúdo relacionado

Mais procurados

Introducing Drools
Introducing DroolsIntroducing Drools
Introducing Drools
Mario Fusco
 
Intro to Vertex AI, unified MLOps platform for Data Scientists & ML Engineers
Intro to Vertex AI, unified MLOps platform for Data Scientists & ML EngineersIntro to Vertex AI, unified MLOps platform for Data Scientists & ML Engineers
Intro to Vertex AI, unified MLOps platform for Data Scientists & ML Engineers
Daniel Zivkovic
 

Mais procurados (20)

Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
KSUG 스프링캠프 2019 발표자료 - "무엇을 테스트할 것인가, 어떻게 테스트할 것인가"
KSUG 스프링캠프 2019 발표자료 - "무엇을 테스트할 것인가, 어떻게 테스트할 것인가"KSUG 스프링캠프 2019 발표자료 - "무엇을 테스트할 것인가, 어떻게 테스트할 것인가"
KSUG 스프링캠프 2019 발표자료 - "무엇을 테스트할 것인가, 어떻게 테스트할 것인가"
 
Introducing Drools
Introducing DroolsIntroducing Drools
Introducing Drools
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in Scala
 
10 Tips for Configuring Your Builds with Bamboo Specs
10 Tips for Configuring Your Builds with Bamboo Specs10 Tips for Configuring Your Builds with Bamboo Specs
10 Tips for Configuring Your Builds with Bamboo Specs
 
(DEV301) Automating AWS with the AWS CLI
(DEV301) Automating AWS with the AWS CLI(DEV301) Automating AWS with the AWS CLI
(DEV301) Automating AWS with the AWS CLI
 
Athena & Step Function 으로 통계 파이프라인 구축하기 - 변규현 (당근마켓) :: AWS Community Day Onl...
Athena & Step Function 으로 통계 파이프라인 구축하기 - 변규현 (당근마켓) :: AWS Community Day Onl...Athena & Step Function 으로 통계 파이프라인 구축하기 - 변규현 (당근마켓) :: AWS Community Day Onl...
Athena & Step Function 으로 통계 파이프라인 구축하기 - 변규현 (당근마켓) :: AWS Community Day Onl...
 
A Hands-on Introduction on Terraform Best Concepts and Best Practices
A Hands-on Introduction on Terraform Best Concepts and Best Practices A Hands-on Introduction on Terraform Best Concepts and Best Practices
A Hands-on Introduction on Terraform Best Concepts and Best Practices
 
추천시스템 이제는 돈이 되어야 한다.
추천시스템 이제는 돈이 되어야 한다.추천시스템 이제는 돈이 되어야 한다.
추천시스템 이제는 돈이 되어야 한다.
 
Ad-Tech on AWS 세미나 | AWS와 데이터 분석
Ad-Tech on AWS 세미나 | AWS와 데이터 분석Ad-Tech on AWS 세미나 | AWS와 데이터 분석
Ad-Tech on AWS 세미나 | AWS와 데이터 분석
 
Intro to Vertex AI, unified MLOps platform for Data Scientists & ML Engineers
Intro to Vertex AI, unified MLOps platform for Data Scientists & ML EngineersIntro to Vertex AI, unified MLOps platform for Data Scientists & ML Engineers
Intro to Vertex AI, unified MLOps platform for Data Scientists & ML Engineers
 
Towards Light-weight and Real-time Line Segment Detection
Towards Light-weight and Real-time Line Segment DetectionTowards Light-weight and Real-time Line Segment Detection
Towards Light-weight and Real-time Line Segment Detection
 
Trees In The Database - Advanced data structures
Trees In The Database - Advanced data structuresTrees In The Database - Advanced data structures
Trees In The Database - Advanced data structures
 
Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)
 
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기
 
Neovim으로 생산성 퀀텀점프하기 by 이재열
Neovim으로 생산성 퀀텀점프하기 by 이재열Neovim으로 생산성 퀀텀점프하기 by 이재열
Neovim으로 생산성 퀀텀점프하기 by 이재열
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3
 
RxJS Operators - Real World Use Cases (FULL VERSION)
RxJS Operators - Real World Use Cases (FULL VERSION)RxJS Operators - Real World Use Cases (FULL VERSION)
RxJS Operators - Real World Use Cases (FULL VERSION)
 
Ad-Tech on AWS 세미나 | AWS와 실시간 입찰
Ad-Tech on AWS 세미나 | AWS와 실시간 입찰Ad-Tech on AWS 세미나 | AWS와 실시간 입찰
Ad-Tech on AWS 세미나 | AWS와 실시간 입찰
 

Destaque

Feedback from the first versions of my music
Feedback from the first versions of my musicFeedback from the first versions of my music
Feedback from the first versions of my music
kamar95
 
Grade 8 9 course selection 2014-2015
Grade 8 9 course selection 2014-2015Grade 8 9 course selection 2014-2015
Grade 8 9 course selection 2014-2015
SteveAyling
 
My music based magazine evaluation
My music based magazine evaluationMy music based magazine evaluation
My music based magazine evaluation
kamar95
 
Daniel & Ernesto's presentation
Daniel & Ernesto's presentationDaniel & Ernesto's presentation
Daniel & Ernesto's presentation
Ernesto Sepulveda
 

Destaque (20)

Perl and AWS
Perl and AWSPerl and AWS
Perl and AWS
 
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talkMooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
 
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
Writing plugins for Nagios and Opsview - CAPSiDE Tech TalksWriting plugins for Nagios and Opsview - CAPSiDE Tech Talks
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
 
Boosting MySQL (for starters)
Boosting MySQL (for starters)Boosting MySQL (for starters)
Boosting MySQL (for starters)
 
Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014
 
Plenv and carton
Plenv and cartonPlenv and carton
Plenv and carton
 
How To Use Blogger
How To Use BloggerHow To Use Blogger
How To Use Blogger
 
Proposal
ProposalProposal
Proposal
 
Bloedsomloop versie 1.0
Bloedsomloop versie 1.0Bloedsomloop versie 1.0
Bloedsomloop versie 1.0
 
Arxaia b gymn
Arxaia b gymnArxaia b gymn
Arxaia b gymn
 
Feedback from the first versions of my music
Feedback from the first versions of my musicFeedback from the first versions of my music
Feedback from the first versions of my music
 
Huidobro&Sepulveda_2010
Huidobro&Sepulveda_2010Huidobro&Sepulveda_2010
Huidobro&Sepulveda_2010
 
introduccion
introduccionintroduccion
introduccion
 
Grade 8 9 course selection 2014-2015
Grade 8 9 course selection 2014-2015Grade 8 9 course selection 2014-2015
Grade 8 9 course selection 2014-2015
 
My music based magazine evaluation
My music based magazine evaluationMy music based magazine evaluation
My music based magazine evaluation
 
Daniel & Ernesto's presentation
Daniel & Ernesto's presentationDaniel & Ernesto's presentation
Daniel & Ernesto's presentation
 
Pptplan morgenjuli2011 pptbehandelcoordinatoren
Pptplan morgenjuli2011 pptbehandelcoordinatorenPptplan morgenjuli2011 pptbehandelcoordinatoren
Pptplan morgenjuli2011 pptbehandelcoordinatoren
 
Make Extra Income Online
Make Extra Income OnlineMake Extra Income Online
Make Extra Income Online
 
Polifonia_6.16
Polifonia_6.16Polifonia_6.16
Polifonia_6.16
 
jul-ago-00
jul-ago-00jul-ago-00
jul-ago-00
 

Semelhante a Paws - A Perl AWS SDK

Counters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at HackoverCounters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at Hackover
Andrei Savu
 
Кирилл Безпалый, .NET Developer, Ciklum
Кирилл Безпалый, .NET Developer, CiklumКирилл Безпалый, .NET Developer, Ciklum
Кирилл Безпалый, .NET Developer, Ciklum
Alina Vilk
 

Semelhante a Paws - A Perl AWS SDK (20)

DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
Counters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at HackoverCounters with Riak on Amazon EC2 at Hackover
Counters with Riak on Amazon EC2 at Hackover
 
AWS Lambda at JUST EAT
AWS Lambda at JUST EATAWS Lambda at JUST EAT
AWS Lambda at JUST EAT
 
10 minutes fun with Cloud API comparison
10 minutes fun with Cloud API comparison10 minutes fun with Cloud API comparison
10 minutes fun with Cloud API comparison
 
Containerize all the things!
Containerize all the things!Containerize all the things!
Containerize all the things!
 
AWS Lambda in C#
AWS Lambda in C#AWS Lambda in C#
AWS Lambda in C#
 
A 60-mn tour of AWS compute (March 2016)
A 60-mn tour of AWS compute (March 2016)A 60-mn tour of AWS compute (March 2016)
A 60-mn tour of AWS compute (March 2016)
 
NEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# ApplicationsNEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# Applications
 
Кирилл Безпалый, .NET Developer, Ciklum
Кирилл Безпалый, .NET Developer, CiklumКирилл Безпалый, .NET Developer, Ciklum
Кирилл Безпалый, .NET Developer, Ciklum
 
Meteor Boulder meetup #1
Meteor Boulder meetup #1Meteor Boulder meetup #1
Meteor Boulder meetup #1
 
Nyc big datagenomics-pizarroa-sept2017
Nyc big datagenomics-pizarroa-sept2017Nyc big datagenomics-pizarroa-sept2017
Nyc big datagenomics-pizarroa-sept2017
 
WKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot Instances
WKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot InstancesWKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot Instances
WKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot Instances
 
Introdution to Node.js
Introdution to Node.jsIntrodution to Node.js
Introdution to Node.js
 
WKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot Instances
WKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot InstancesWKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot Instances
WKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot Instances
 
Java 8
Java 8Java 8
Java 8
 
Serverless Web Apps using API Gateway, Lambda and DynamoDB
Serverless Web Apps using API Gateway, Lambda and DynamoDBServerless Web Apps using API Gateway, Lambda and DynamoDB
Serverless Web Apps using API Gateway, Lambda and DynamoDB
 
Workflow All the Things with Azure Logic Apps
Workflow All the Things with Azure Logic AppsWorkflow All the Things with Azure Logic Apps
Workflow All the Things with Azure Logic Apps
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksLecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinks
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016
 

Mais de Jose Luis Martínez

Mais de Jose Luis Martínez (10)

Being cloudy with perl
Being cloudy with perlBeing cloudy with perl
Being cloudy with perl
 
Modern Perl toolchain (help building microservices)
Modern Perl toolchain (help building microservices)Modern Perl toolchain (help building microservices)
Modern Perl toolchain (help building microservices)
 
Escribir plugins para Nagios en Perl
Escribir plugins para Nagios en PerlEscribir plugins para Nagios en Perl
Escribir plugins para Nagios en Perl
 
NRD: Nagios Result Distributor
NRD: Nagios Result DistributorNRD: Nagios Result Distributor
NRD: Nagios Result Distributor
 
Writing nagios plugins in perl
Writing nagios plugins in perlWriting nagios plugins in perl
Writing nagios plugins in perl
 
Ficheros y directorios
Ficheros y directoriosFicheros y directorios
Ficheros y directorios
 
DBIx::Class
DBIx::ClassDBIx::Class
DBIx::Class
 
DBI
DBIDBI
DBI
 
The modern perl toolchain
The modern perl toolchainThe modern perl toolchain
The modern perl toolchain
 
Introducción a las Expresiones Regulares
Introducción a las Expresiones RegularesIntroducción a las Expresiones Regulares
Introducción a las Expresiones Regulares
 

Último

Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft DatingDubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...
VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...
VVIP Pune Call Girls Mohammadwadi WhatSapp Number 8005736733 With Elite Staff...
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
 

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?
  • 7.
  • 8.
  • 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
  • 13.
  • 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
  • 18.
  • 22.
  • 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
  • 24.
  • 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
  • 40.
  • 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
  • 48.
  • 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: joseluis.martinez@capside.com CPAN: JLMARTIN CAPSiDE Twitter: @capside Mail: hello@capside.com