By default, all Amazon S3 objects are private and object owner can access them. No one can access other then owner , however Pre-signed URL for an Amazon S3 object allows anyone who receives the S3 presigned URL to retrieve the S3 object with an HTTP GET request. All presigned URL’s now can use sigv4 so the region needs to be configured explicitly.
Method 1- Sharing Object using AWS console.
A Test file Uploaded in S3 bucket.
Try to access object with S3 URL. we can see it is not accessible.
Select the object and drop down ActionsTab and select Share with presigned URL
object>>Actions>> Share with a presigned URL
Only 12 hrs lifetime can be selected only and hit create presigend URL
Copy URL and share with user
S3 Presigned URL is vailable for 120 Min only
Now if we access s3 object it is now accessible
Method 2- Sharing Object using AWS CLI.
Please refer below link for CLI Installation and Usage.
Get started with the AWS CLI – AWS Command Line Interface (amazon.com)
Check If AWS is installed else refer the link for installation.
Upload one test file(S3test2.txt) for CLI example
Now try to access it , it is acess denied
Example 1: Pre-signed URL with the default one hour lifetime for an object in an S3 bucket
The following presign
command generates a pre-signed URL for a specified bucket and key that is valid for one hour.
aws s3 presign s3://BUCKET-NAME/test2.txt
It is now accessble for everyone who has this link for 1 hr
Example 2: Pre-signed URL with a custom lifetime for an object in an S3 bucket
The following presign
command generates a pre-signed URL for a specified bucket and key that is valid for one week.
aws s3 presign s3://BUCKET-NAME/test2.txt --expires-in 604800(min)