How do you generate a presigned S3 URL, and what limits apply?
IntermediateConceptboto3 & AWS automation
Answer
url = s3.generate_presigned_url("get_object",
Params={"Bucket": "acme-reports", "Key": "audit/latest.html"},
ExpiresIn=3600)
It is generated locally (no API call) using your current credentials, and it stops working when those credentials expire, so a URL signed with a 1-hour STS session never lasts longer than that session regardless of ExpiresIn. SigV4 presigned URLs max out at 7 days. Pass region_name and, for newer regions, ensure the client uses the regional endpoint, or you get SignatureDoesNotMatch or redirects.
More on boto3 & AWS automation
What is the difference between a boto3 Session, client and resource?BeginnerHow does boto3 find credentials?BeginnerHow does boto3 decide the region, and what is the gotcha with `AWS_REGION`?AdvancedWhy do you need paginators, and how do you use them?BeginnerWhat is JMESPath `search()` on paginators?AdvancedHow do you handle errors from boto3?Beginner