AWS Certified Developer - Associate (DVA-C03) free question 4 / 10 · Domain 2: Security
A service that runs with an IAM role creates presigned URLs for report downloads and asks for an expiration of 7 days. Customers report that the links stop working after a few hours. The links must stay valid for the full 7 days. What should the developer change?
- Keep the role credentials and request an expiration that is longer than 7 days to have the role session extended further
- Add a bucket policy statement that sets the lifetime of presigned URLs for the report prefix to 7 days
- Create the presigned URLs in the Amazon S3 console and request an expiration of up to 7 days
- Create the presigned URLs with the access keys of an IAM user and Signature Version 4, and request an expiration of 7 days
Show the answer and explanation
Answer: D
Why this is correct
A presigned URL stays valid for the time that is specified when it is generated, but never longer than the credentials that were used to create it. A URL that is created with IAM role credentials expires when the role session expires, even if a longer expiration time was specified, which explains the links that stop after a few hours. An IAM user's access keys used with Signature Version 4 make URLs that are valid for up to 7 days, and the AWS CLI or an SDK can set that expiration.
Why the other options are wrong
"Keep the role credentials and request an expiration that is longer than 7 days to have the role session extended further" … A presigned URL that is created with role credentials expires when the role session expires, even if a longer expiration time is specified. A longer request does not extend the session.
"Create the presigned URLs in the Amazon S3 console and request an expiration of up to 7 days" … In the console, the expiration time can be set between 1 minute and 12 hours. Only the AWS CLI and the SDKs can set it as high as 7 days.
"Add a bucket policy statement that sets the lifetime of presigned URLs for the report prefix to 7 days" … Presigned URLs grant time-limited access without updating the bucket policy. The lifetime is decided when the URL is generated and by the credentials that signed it, not by a bucket policy.
Key points
Presigned URL lifetime = the shorter of the requested expiry and the signing credentials. IAM user with SigV4: up to 7 days. Console: up to 12 hours.