(t) 514 312 4307 (email) hello@giraffesoft.ca

[FLOSS Week]: Cliaws: Easy Command-Line Access to EC2, SQS and S3

Posted by: François Beausoleil on 2009-02-19

This release announcement is part of FLOSS week.

What if you didn't have to find and setup X.509 certificates to quickly use Amazon's EC2, SQS and S3 from your applications? Or from the command-line for that matter? Well, search no more.

$ clis3 list BUCKET
BUCKET/file0
BUCKET/file1
BUCKET/file2

$ clis3 put localfile BUCKET/newfile

# Get a secure URL valid for a couple of hours
$ clis3 url BUCKET/newfile

# Gets the content of the file, unmodified
$ clis3 get BUCKET/newfile

# Gets the contents of the file, but appends a single newline at the end
$ clis3 cat BUCKET/newfile
$ cliec2 list
DNS Name                                           State        Groups
------------------------------------------------------------------------------------------------------------------------
ec2-97-162-23-218.compute-1.amazonaws.com          running      app, web
ec2-73-121-216-98.compute-1.amazonaws.com          running      db
# Create a named queue
$ clisqs create giraffesoft_power
Queue giraffesoft_power was created.

# Push a single message to the queue
$ clisqs push --data "message" giraffesoft_power
Pushed 7 bytes to queue giraffesoft_power

# Retrieve one message from the named queue
$ clisqs pop giraffesoft_power
message

Of course, this library wouldn't be complete if it wasn't also available from your Ruby code.

# Returns an array of the files available in this bucket
Cliaws.s3.list "BUCKET"

# Puts the File, IO stream or String to the named file
Cliaws.s3.put "localfile", "BUCKET/newfile"

# Retrieves the contents from S3
Cliaws.s3.get "BUCKET/newfile"

# Returns an Array of Cliaws::Ec2::Instance objects
Cliaws.ec2.list

# Instances have interesting methods such as #running?

# Push a new message to the named queue
Cliaws.sqs.push "giraffesoft_power", {:adapter => "mysql", :username => "root", :password => "tada!!!"}.to_yaml

# Get said message from the queue
Cliaws.sqs.pop "giraffesoft_power"

Get It!

Installation could not be simpler:

$ gem install cliaws

Cliaws depends on 2 environment variables: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Set them to the correct values before calling into the library. I have mine setup in my ~/.bashrc.

Fork Cliaws on github.

This release announcement is part of FLOSS week. If you're interested in more open source software, consider subscribing or following us on twitter to get the next announcements asap.

blog comments powered by Disqus