Amazon S3 signed URL, when I am using accesskey and secret key the signed URL validation is working fine which is 7 days but with IAM role it is getting expired soon (within 1 day).
I am expecting the similar result with both accesskey and IAM role
An Amazon S3 pre-signed URL is just like a normal URL pointing to an object in Amazon S3, except that it has additional information appended:
The pre-signed URL will use the permissions of the credentials that were used to 'sign' the URL. Thus, if a user who does not have access to an object creates a pre-signed URL, then that pre-signed URL will not grant access.
Similarly, if the pre-signed URL is created by temporary credentials associated with an IAM Role, then the pre-signed URL will not work beyond the validity period of the IAM Role credentials. This is because those underlying credentials are no longer valid, so any pre-signed URLs created by those credentials will not be valid. The pre-signed URL is effectively saying "I am these credentials and I permit access", but if the credentials don't have access then the object can't have access.
Therefore, your options are:
DurationSeconds
of up to 12 hours. This is, however, less than the 7 days you wanted.