Signature Version 4 is maximum for a week. In Python I did:
s3_client = boto3.client('s3',
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
config=botocore.client.Config(signature_version='s3')
)
return s3_client.generate_presigned_url(
'get_object',
Params={
'Bucket': bucket_name,
'Key': key
},
ExpiresIn=400000000) # this is a max: ~ten years
But for Go I found only func (*Request) Presign:
req, _ := s3Client.GetObjectRequest(&s3.GetObjectInput{
Bucket: aws.String(bucketName),
Key: &key,
})
tenYears := time.Now().AddDate(10, 0, 0).Sub(time.Now())
url, err := req.Presign(tenYears)
HTTP response for such URL is: AuthorizationQueryParametersError: X-Amz-Expires must be less than a week (in seconds); that is, the given X-Amz-Expires must be less than 604800 seconds.
No way to presign URL in Go using AWS SDK for years?
If you want to pre-sign URL for longer than a week, then your use case for pre-signed URLs is not valid. According to the spec it is really just one week.
Pre-signed URLs are often used to serve content from S3 to authenticated users only.