AWS Lambda For The Impatient Part 3
Written by Nikos Vaggalis   
Monday, 20 February 2017
Article Index
AWS Lambda For The Impatient Part 3
Paws::STS

 

Paws::STS

Paws once more showcases its versatility catering for this case also, through Paws::STS, the Perl interface to the AWS Security Token Service.


We could have used Paws::STS to make the call but since we've already gone through the trouble of setting up the AWS CLI, we'll instead go with the command line and  'aws sts assume-role':

9b

 

aws sts assume-role --role-arn arn:aws:iam::395313573989:role/lamb
da_basic_execution_helloWorldNodeJS_auth --role-session-name paws_session

assume-role takes as inputs the arn (--role-arn) of the role and a user defined session name (-role-session-name), in this instance 'paws_session', to be used for identification purposes. This gives back an access key ID, a secret access key, and a security token:

9c

 

We'll now use those to fill the corresponding environmental variables from which Paws is going to draw in order to make the call:

use Paws;
use Data::Dumper;
use JSON::MaybeXS;
use strict;

$ENV{'AWS_ACCESS_KEY'} = 'ASIAJRQMLG4R5Q';


$ENV{'AWS_SECRET_KEY'} = 'oGxCrDJ/Tm658jmYAx3y0svddsT4dhyy';


$ENV{'AWS_SESSION_TOKEN'} ='FQoDYXdzEC8aDHb+Y+D/0BIwSgft2yLPAU6w9aREKJ4I/k1rp+YitA
WZvHS/JrjMqmWRNvk3sAghjJMeUTRWEe9TQ74ckErUsS9Y9F13/URpvz
4eYz1sQ6lXdUclPvILHRarBNZHRjdj1zMzZnojmCyTxZnJfhEVxjcbvj
5GRrR2Ji/fB5KWl8LmKzBqK9kBXvTO2pCiyDp82Fp15GneHDxwgIBUGE
HgSWvbmEkfpY1uAcqnpbiiRp9rCBQ==';


my $lambda = Paws->service('Lambda',
                   region => 'eu-west-1' );


my $data_structure={key1=>value1};

my $json_text = encode_json($data_structure);

my $response=$lambda->Invoke(
     FunctionName => 'helloWorldNodeJsAuth',
     Payload=>$json_text,

     InvocationType => 'RequestResponse');

print Dumper $response;

print $response->Payload;

11

 

Hence, Paws does not just render the calling of an AWS Lambda function easy, but dies it for any AWS service in general. It is just a matter of pinpointing the same named as the service module and go through its documentation to find out how it is called.

Of course, to get to the step of making the actual call, a lot of initial background work has to be done.

It's what we set out to do in this three-part tutorial series, aiming not just at an overview of AWS Lambda's infrastructure, but rather going through the whole set of steps necessary, before we even attempted to make the function's call.

Therefore, we started our exploration with setting up users and roles, policies and permissions, role-based as well as user-based authentication, accessing the lambda through public HTTP endpoints and finally accessing the lambda programmatically by leveraging NodeJs on the server and Perl on the client.

Given AWS's high prevalence and ever growing expansion in powering up applications of any kind, ranging from databases to artificial intelligence, acquiring expertise on the platform is knowledge that is certain to prove extremely valued.

What's more, the AWS free tier makes it pretty easy to get started, so why don't you give it a try?

 

 aws logo. v400518270

More Information

Hello, Perl Developers!

Paws - Perl AWS SDK Update on SlideShare

Paws on MetaCPAN

AWS entire documentation

Related Articles

AWS Lambda For The Impatient Part 1

AWS Lambda For The Impatient Part 2

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


MongoDB 8 Reduces Memory Use And Increases Speed
07/10/2024

MongoDb 8 has been released, and the developers have said this is the most secure, durable, available, and performant version of MongoDB yet, with significantly reduced memory usage and query times, a [ ... ]



JetBrains Makes WebStorm and Rider Free for Non-Commercial Use
24/10/2024

JetBrains has launched a non-commercial license for its JavaScript and TypeScript IDE, WebStorm, and for Rider, its cross-platform .NET and game development IDE.


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info



Last Updated ( Tuesday, 21 February 2017 )