Rake task to sync your assets to Amazon S3/Cloudfront

With my move to Heroku I felt bad about having Heroku’s app servers serve static content for me. It’s not really a problem, but I just like to use the best tool available for the job. Because is a rack app, it has a public directory with all static assets in once place. There are, however, a few problems that need adressing. ~ These are the problems I want to resolve:

Public Readable Amazon S3 Bucket Policy

Amazon S3 allows you to set per-file permissions to grant read and/or write access. This is nice, but sometimes you just want to share your whole bucket with the world. Luckily, Amazon features bucket policies, which allow you to define permissions for an entire bucket. ~ This example will give read access to Everyone on all files in your bucket. { "Version":"2008-10-17", "Statement":[{ "Sid":"AllowPublicRead", "Effect":"Allow", "Principal": { "AWS": "*" }, "Action":["s3:GetObject"], "Resource":["arn:aws:s3:::bucket/*" ] } ] } Make sure you replace bucket in arn:aws:s3:::bucket/* with your bucket name.