Archive for November, 2008

Amazon CloudFront: Configuring a CDN in under 5 minutes

Tuesday, November 18th, 2008

I was very thrilled to hear about the public release of Amazon’s much awaited CDN service dubbed CloudFront. It took me 5 minutes to configure and start using it to serve static content off it (I used S3 for static content until now, so the transition was easy).

  1. Prepare an .aws-secrets file to store your AWS access identifiers and get the cfcurl.pl script (tutorial).
  2. Define a Distribution. Save this snippet in a file called create_request.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2008-06-30/">
    ..<Origin>YourBucketNameHere.s3.amazonaws.com</Origin>
    ..<CallerReference>20080930090000</CallerReference>
    ..<CNAME>cdn.example.com</CNAME>
    ..<Enabled>true</Enabled>
    </DistributionConfig>
  3. Run the following command:
    ./cfcurl.pl --keyname <key name from .aws-secrets file> -- -X POST -i -H "Content-Type:text/xml; charset=UTF-8" --upload-file create_request.xml https://cloudfront.amazonaws.com/2008-06-30/distribution
  4. Save the response (especially the E-Tag) for later, you may need it to update the configuration.
  5. Create a CNAME entry in your DNS server using the DomainName in the response.
  6. Done!

I’m trying to think about an elegant way to manage versioning from now on (in PHP). I used to add a query-string version parameter to each resource to deal with client-side caching. With CloudFront, I need actual filenames to change, since Amazon’s servers ignore the query-string parameters when fetching the file from the S3 origin. Any ideas would be greatly appreciated!

Update: see comment below.

oh my god the killed lilly1975

Thursday, November 13th, 2008

Aya Rosen‘s account, lilly1975 got deleted from Flickr, without warning, probably because someone repeatedly flagged her photos as inappropriate. She is an artist, and her Flickr photostream was very inspirational as well as popular. Flickr won’t restore her account nor give her access to her interactions history.

Post this photo to your Flickr / Facebook profile to show you care.

Read more here:
1. “This is not a question” – Aya’s post about the deletion
2. Yaniv Golan’s blog post
3. A discussion on Facebook started by Yael Givon

Update: She’s back on Flickr, with a new user name and a clean slate [NSFW].
Update 2: Read about it on her blog.

Cleaning Flickr Tags

Sunday, November 2nd, 2008

As part of an application I’m developing, I needed to store tags from multiple sources, and I chose to use Flickr’s method of storing raw and clean tags. I needed to figure out how Flickr converts raw tags to clean ones. This article by Terrell Russell helped a lot, but missed a few elements (and I needed it in Java).

The original regular expression by Russell did not include a comma, and I also found out certain special characters are substituted (I guess I will find more of them as I keep comparing Flickr tags).

public static String cleanRawTag(String raw, boolean isMachineTag)
{
    	if(isMachineTag)
    	{
    		// raw  = geo:lat=13.751193
    		// name = geo:lat=13751193
    		int equals = raw.indexOf('=');
    		return raw.substring(0, equals+1).toLowerCase() + cleanRawTag(raw.substring(equals+1), false);
    	}
    	else
    	{
    		String clean = raw.replaceAll("[s"!@#$%^&*():,-_+='/.;`<>[]?\]", "").toLowerCase();
    		return clean.replace('ß', 's').replace('ς', 'σ');
    	}
}