title: amazon cloudfront Error "AccessDenied"
body: <p>This is my code i am getting Access Denied message. Anyone tell me how to fix this.</p>
  
  <blockquote>
    <p>My Bucket Policy</p>
  </blockquote>
  
  <p>"cloudfront:user/CloudFront Origin Access Identity [ID]" with s3.</p>
  
  <blockquote>
    <p>Bucket Policy Resource</p>
  </blockquote>
  
  <p>"Resource": "arn:aws:s3:::bucket_name/*"
  
  
  <pre><code>use Aws\CloudFront\CloudFrontClient;
  require 'vendor/autoload.php';
  
  $cloudFront = CloudFrontClient::factory([
      'version' =&gt; 'latest',
      'region'  =&gt; 'ap-south-1'
  ]);
  
  // Setup parameter values for the resource
  $streamHostUrl = 'http://example.cloudfront.net';
  $resourceKey = 'Bucket/1.jpg';
  $expires = new DateTime('+1 minute');
  
  // Create a signed URL for the resource using the canned policy
  $url = $cloudFront-&gt;getSignedUrl([
      'url'         =&gt; $streamHostUrl . '/' . $resourceKey,
      'expires'     =&gt; $expires-&gt;getTimestamp(),
      'private_key' =&gt; 'pk-private_key.pem',
      'key_pair_id' =&gt; '&lt;key_pair_id&gt;'
  ]);
  
  echo $url;
  </code></pre>
  
  <blockquote>
    <p>Error "AccessDenied"</p>
  </blockquote>
  
  <pre><code>&lt;Error&gt;
  &lt;Code&gt;AccessDenied&lt;/Code&gt;
  &lt;Message&gt;Access Denied&lt;/Message&gt;
  &lt;RequestId&gt;EE8B43497F516AD3&lt;/RequestId&gt;
  &lt;HostId&gt;
  jghWRjO1Rnvv0/hRaeBS4pThCFJcGN26r3wDcMAiyqWeVHRVLbNaSUiIQmR7dDiQus/j8QjUWhM=
  &lt;/HostId&gt;
  &lt;/Error&gt;
  </code></pre>