title: Retrieve file from S3 with curl from EC2 using IAM role
body: <p>I created an IAM role and assigned it to my EC2 instance. I created an IAM role policy and linked it to my S3 bucket. I can now list the files on my S3 bucket using the <code>aws-cli</code> on my EC2 instance.</p>
  
  <pre><code>[root@ec2.hostname.aws.com ~]# aws --region eu-west-1 s3 ls s3://s3-bucket-name
  2017-05-02 02:37:39        137 index.html
  </code></pre>
  
  <p>Now if I try to <code>curl</code> that file I get an access denied error:</p>
  
  <pre><code>[root@ec2.hostname.aws.com ~]# curl https://s3-eu-west-1.amazonaws.com/s3-bucket-name/index.html
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Error&gt;&lt;Code&gt;AccessDenied&lt;/Code&gt;&lt;Message&gt;Access Denied&lt;/Message&gt;&lt;RequestId&gt;782176F442A4995A&lt;/RequestId&gt;&lt;HostId&gt;qZWZTXZdlgtD4BiVYfp5+Mj/gU3UXRiYQmsSyaAhwED1JtzUWs9QKE99RmsQ6w0uDB
  </code></pre>
  
  <p>Is there a way I could make this <code>curl</code> request work without relaxing the permissions on the S3 bucket? Something like authentication, headers etc etc.</p>