вторник, 17 марта 2009 г.

Getting started with Amazon CloudFront

Amazon does not provide rich tools for interacting with S3/CloudFront services. In fact, it barely provides any tools. Instead, they publish and document their API and let developers community to build the tools they want. Reminds me of Twitter.

There is big selection of tools/solutions available but it took me some time to find one that fits my needs.

The gem I found is s3cmd. This is a simple, command-line tool that supports nearly all Amazon S3 API functionality and recently got support for CloudFront APIs as well. Command-line is critical, since it allows to be used in batch jobs and be re-used from my own tools. It is also written in Python, language I prefer, which means it is easy for me to embed/extend/debug it.

Here is the gist of getting CloudFront distribution up and running:

$ s3cmd --configure # setup S3 keys on local machine
$ s3cmd mb s3://dou-static # create a bucket
$ s3cmd put -P images/logo-new.png s3://dou-static/images/ # upload a file
$ s3cmd cfcreate s3://dou-static/ # request new dist from CloudFront
# a couple of minutes for CloudFront to activate new dist
$ s3cmd cfinfo # Status: online
$ wget http://d15ewwxci4mze.cloudfront.net/images/logo-new.png # It works!

For more information refer to excellent s3cmd documentation.

Комментариев нет:

Отправить комментарий