<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cory O&#039;Daniel - These are just words &#187; amazon</title>
	<atom:link href="http://coryodaniel.com/index.php/tag/amazon/feed/" rel="self" type="application/rss+xml" />
	<link>http://coryodaniel.com</link>
	<description>Software development, thoughts, and randomness</description>
	<lastBuildDate>Thu, 17 Nov 2011 21:18:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Lower ACL Permissions on Amazon S3 items with ruby</title>
		<link>http://coryodaniel.com/index.php/2010/02/11/lower-acl-permissions-on-amazon-s3-items-with-ruby/</link>
		<comments>http://coryodaniel.com/index.php/2010/02/11/lower-acl-permissions-on-amazon-s3-items-with-ruby/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 01:10:21 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[RubyDevelopment]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[s3]]></category>

		<guid isPermaLink="false">http://coryodaniel.com/?p=473</guid>
		<description><![CDATA[I recently had to change a bunch of permissions on some items on S3. Unfortunately the items were mixed in with items that I didn't want to change the permissions on and the file names are all kinda jumbled, so I couldn't pinpoint what I needed to change by eyeballing the file names. 
So I [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to change a bunch of permissions on some items on S3. Unfortunately the items were mixed in with items that I didn't want to change the permissions on and the file names are all kinda jumbled, so I couldn't pinpoint what I needed to change by eyeballing the file names. </p>
<p>So I wrote a little ruby method to go in and change something given a key and bucket name.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'aws/s3'</span>
&nbsp;
<span style="color:#6666ff; font-weight:bold;">AWS::S3::Base</span>.<span style="color:#9900CC;">establish_connection</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>
  <span style="color:#ff3333; font-weight:bold;">:access_key_id</span>     <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;YOUR_ACCESS_KEY&quot;</span>,
  <span style="color:#ff3333; font-weight:bold;">:secret_access_key</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;YOUR_SECRET_KEY&quot;</span>
<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#6666ff; font-weight:bold;">AWS::S3</span>
<span style="color:#9966CC; font-weight:bold;">def</span> s3_set_public_read<span style="color:#006600; font-weight:bold;">&#40;</span>key, bucket<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Processing: #{key}&quot;</span>  
&nbsp;
  policy = S3Object.<span style="color:#9900CC;">acl</span><span style="color:#006600; font-weight:bold;">&#40;</span>key, bucket<span style="color:#006600; font-weight:bold;">&#41;</span>
  policy.<span style="color:#9900CC;">grants</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#6666ff; font-weight:bold;">ACL::Grant</span>.<span style="color:#9900CC;">grant</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:public_read</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  policy.<span style="color:#9900CC;">grants</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#6666ff; font-weight:bold;">ACL::Grant</span>.<span style="color:#9900CC;">grant</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:public_read_acp</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  S3Object.<span style="color:#9900CC;">acl</span><span style="color:#006600; font-weight:bold;">&#40;</span>key, bucket, policy<span style="color:#006600; font-weight:bold;">&#41;</span>      
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Now I can just run a loop of ActiveRecord objects around that method and convert them all to public read.</p>
<p>If you want a GUI tool for managing S3 stuff, I totally recommend <a href="http://s3hub.com/">S3Hub</a>. Its a really sexy tool for managing S3.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Lower+ACL+Permissions+on+Amazon+S3+items+with+ruby+http://coryodaniel.com/?p=473" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2010/02/11/lower-acl-permissions-on-amazon-s3-items-with-ruby/&amp;title=Lower+ACL+Permissions+on+Amazon+S3+items+with+ruby" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2010/02/11/lower-acl-permissions-on-amazon-s3-items-with-ruby/&amp;t=Lower+ACL+Permissions+on+Amazon+S3+items+with+ruby" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2010/02/11/lower-acl-permissions-on-amazon-s3-items-with-ruby/&amp;title=Lower+ACL+Permissions+on+Amazon+S3+items+with+ruby" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2010/02/11/lower-acl-permissions-on-amazon-s3-items-with-ruby/&amp;title=Lower+ACL+Permissions+on+Amazon+S3+items+with+ruby" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2010/02/11/lower-acl-permissions-on-amazon-s3-items-with-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

