Sep 12, 2014; 11:37
Fletcher Sandbeck
Lasso 8.6 Amazon Web Services API at GitHub
I=92ve done a complete rethink of the AWS API for Lasso. Rather than relying on their REST interface which works, but requires a lot of finicky low-level details, I have rewritten the API to use their CLI tools. This makes for a much simpler implementation and allows me to piggyback on their existing authentication, request signing, automatic retry, and error handling functionality.
This is the basic structure of calls listing the module, command, and then parameters. This lists the load balancers in the current account.
aws('elb=92, 'describe-load-balancers', -max_items=10);
This second call has a filter which searches for specific instances, those that are running, and a query which allows pre-processing of the JSON return value. This lists the running instances from the current account, but returns just an array of PublicDnsNames. For specific needs the queries can be quite a bit more efficient than equivalent Lasso code drilling down into maps and arrays.
aws('ec2', 'describe-instances', -filters=map('instance-state-name'='running'),
-query='Reservations[].Instances[].[ImageId,PublicDnsName]');
In addition to the raw commands, I have the Simple Queue Service (SQS) module complete. What I like about using SQS is that allows me to separate some of this transactional data from my main MySQL data store, it has built-in monitoring through the AWS console and CloudWatch alerts, and the same queues can be accessed through Lasso or the CLI so I can transfer messages between these different domains. Here=92s an example of the types of commands.
var('myqueue' = sqs_create_queue('myqueue', -attributes=map('DelaySeconds'=30)));
sqs_send_message($myqueue, 'Message sent at: ' + date->format('%Q %T'));
var('messages' = sqs_receive_message($myqueue, -max_number_of_messages=10));
if($messages->size > 0);
iterate($messages->find('messages'), var('message'));
var('body' = $message->find('body'));
... process body ...
sqs_delete_message($queue, $message);
/iterate;
/if;
sqs_delete_queue(sqs_get_queue_url('myqueue'));
I will be adding additional modules like DynamoDB, parts of EC2, and S3 and would welcome collaboration.
https://github.com/fletc3her/aws-lasso8
[fletcher]
#############################################################
Attend the Lasso Developer Conference 2014!
October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
http://www.lassosoft.com/LDC-newmarket-2014
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>