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 aws-cli on my EC2 instance.
[[email protected] ~]# aws --region eu-west-1 s3 ls s3://s3-bucket-name
2017-05-02 02:37:39 137 index.html
Now if I try to curl that file I get an access denied error:
[[email protected] ~]# curl https://s3-eu-west-1.amazonaws.com/s3-bucket-name/index.html
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>782176F442A4995A</RequestId><HostId>qZWZTXZdlgtD4BiVYfp5+Mj/gU3UXRiYQmsSyaAhwED1JtzUWs9QKE99RmsQ6w0uDB
Is there a way I could make this curl request work without relaxing the permissions on the S3 bucket? Something like authentication, headers etc etc.
curl `aws --region eu-west-1 s3 presign s3://s3-bucket-name/index.html`