Note that there are some explanatory texts on larger screens.

plurals
  1. POEdit ACLs of S3 files accessed via Cloudfront through PHP SDK
    primarykey
    data
    text
    <p>I'm looking for a solution to update dynamically my S3 files ACLs and that it propagates instantly to Cloudfront.</p> <p>So far I can update the ACL on S3 but if I set a file private it will still be accessible via Cloudfront publicly and the other way around.</p> <p>I am using S3 PHP SDK to do so: Set file as public</p> <pre><code>$s3 = new S3($awsAccessKey, $awsSecretKey); if (($acp = S3::getAccessControlPolicy($bucket, $uri)) !== false) { $acp["acl"][] = array( "type" =&gt; "Group", "uri" =&gt; "http://acs.amazonaws.com/groups/global/AllUsers", "permission" =&gt; "READ" ); if (S3::setAccessControlPolicy($bucket, $uri, $acp)) { echo "true"; } } </code></pre> <p>Set file as private</p> <pre><code>$s3 = new S3($awsAccessKey, $awsSecretKey); if (($acp = S3::getAccessControlPolicy($bucket, $uri)) !== false) { foreach($acp['acl'] as $key =&gt; $val) { if(isset($val['uri']) &amp;&amp; $val['uri'] == 'http://acs.amazonaws.com/groups/global/AllUsers') unset($acp['acl'][$key]); } if (S3::setAccessControlPolicy($bucket, $uri, $acp)) { echo "true"; } } </code></pre> <p>I have read that to update a file you have to send an invalidation request to Cloudfront: <a href="https://stackoverflow.com/questions/1268158/force-cloudfront-distribution-file-update">Force CloudFront distribution/file update</a></p> <p>I haven't tried it but before I do it, I would like to know it this is the right solution. I've also read that it might take 15min to update. Isn't there any way to make it instantaneous?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload