Interview Prep/Python for DevOps/boto3 & AWS automation

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.

All Python for DevOps questions Roadmap: Python for automation

More on boto3 & AWS automation