So you want to develop an app that will be deployed on AWS. And, obviously, you want to do it in Perl, but there is was not a Perl SDK for AWS.
Luckily for us, at Perl we have CPAN and an active community. When looking at CPAN, we find different modules that are convenient for some AWS Services. However, each module had its own author, which usually leads to some issues.
- Inconsistencies (method naming, arbitrary defaults…)
- Some modules had default regions.
- Some regions were not supported due to bugs.
- Some modules had a preferred HTTP library.
- Not all services were covered.
- Credential handlings were not always supported.
- Not all modules are updated at the same pace as AWS innovates (keeping up with AWS is hard!).
Well, you know, there is more than one way to do it!
Anyway, as we are heavy AWS users, we need native Perl support for all AWS services. Also, we want up-to-date APIs. That’s how Paws was born. And as we like cats, Perl and AWS, we thought Paws (meow) was a good name for it. 😉
We’re proud to say that the team at Amazon.com is one happy user of PAWS!
The challenge of building a Perl SDK for AWS
As it was something we needed, why not building an entire Perl SDK for AWS? It is not impossible, but it isn’t, for sure, an easy task.
- The number of services: AWS innovates at a really fast pace, so it makes it harder to maintain a Perl SDK for AWS when they keep adding new services. The solution: classifying services (they do have commonalities!).
- Endpoints: AWS uses two different kinds of endpoints: regional and single. Also, each service endpoint is also specific for a concrete region.
- WebService Types: There are two different WebService Types. First, one which parameters are a Query file but the response is always an XML. The second one has both parameters and responses as a JSON file.
- Signatures: 4 different types – v2, v3https, CloudFront and v4.
- API versions: as AWS is improving their services constantly, usually, more than one API version is live.
So we started writing. As you may imagine, it can be a daunting task. Handwriting classes, methods and parameters were not an option. So, to build Paws, we based our developing on Modern Perl.
- We created moose classes that validate the parameters passed to the call.
- We chose to hide all possible implementation from the user.
- We inspected objects with Meta. Like this, call objects get marshalled into data structure.
- We decided to use roles. All functionalities get pulled in via a role.
The Perl SDK for AWS
Paws is a data driven SDK, which means that the definitions for the method calls are stored in a data structure describing input and output parameters. If you want to install it, you can do it via CPAN, CPANM, Carton or the likes.
The perks of using the Perl SDK for AWS:
- Authentication: no need to burn credentials in your code. These are the keys to the biggest data centres in the world, so you may want to protect them. You’ll be able to use both Access Keys and Secret Keys, with session tokens for temporal access with Paws:Credential::XXX classes. Also, there is a default credential provider: Paws::Credential::ProviderChain. With Paws, PRO and DEV can be the same, as the machines have its own Instance Role attached.
- Classes: Each service in AWS has its own class in Paws. If you’re using the EC2 API, you can go for Paws::EC2.
- Pluggable Callers: you can select which caller you want to operate with. By default, it uses P::N::Caller, but you can choose also P::N::LWPCaller,P::N::FurlCaller and P::N::MojoAsyncCaller. There are also special callers, like Paws::Kinesis::MemoryCaller, that emulates Kinesis without the HTTP code, and some hidden callers like record and replay mode.
- Changing Endpoints: Paws allows you to change endpoints for any AWS service (SQS, EC2…).
- Regions: you can work with more than one region by using more than one instance.
- Accounts: you can work with more than one account.
- CLI utility: Paws comes with a command-line utility to exercise the SDK, just use “paws” (in /bin) to list all services.
So now you know about Paws, feel free to use it and remember that contributions are always welcome. Fork your heart out!