Skip to content

How to override the default session duration when using IAM For Service AccountsΒ #2681

@auswells

Description

@auswells

Describe the issue

How can I override the default session duration when using IAM for Service Accounts? We are generating presigned S3 urls that are expiring after 1 hour. I'd like to extend the session duration so the presigned Urls are not expiring when the session that created them expires.

We are using AWS SDK version 1.11.955

Here's how we are initializing the S3 client:

            AmazonS3ClientBuilder.EndpointConfiguration endpointConfiguration = new AmazonS3ClientBuilder.EndpointConfiguration(repositoryConfig.getAwsServiceEndpoint(), repositoryConfig.getAwsSigningRegion());
            s3Client = AmazonS3ClientBuilder.standard().withEndpointConfiguration(endpointConfiguration).withPathStyleAccessEnabled(repositoryConfig.isAwsPathStyleAccessEnabled()).build();

Then here's the code to generate the presigned url

           // Generate the presigned URL.
            GeneratePresignedUrlRequest generatePresignedUrlRequest =
                    new GeneratePresignedUrlRequest(bucketName, objectKey)
                            .withMethod(HttpMethod.GET)
                            .withExpiration(Date.from(Instant.now().plus(7,ChronoUnit.DAYS)));

            return s3Client.generatePresignedUrl(generatePresignedUrlRequest);

But with the expiration set to 7 days on the presigned URL, the session used in the presigned URL is expiring after an hour.

I've extended the IAM role's max session duration to 12 hours, but that does not appear to have changed the behavior. I'm assuming I need to override the default 1hr session duration in the credentials provider when creating the S3 client, or mount an aws config file that sets duration_seconds to our container(s)

Steps to Reproduce

n/a

Current behavior

n/a

AWS Java SDK version used

1.11.955

JDK version used

11

Operating System and version

Alpine Linux

Metadata

Metadata

Assignees

Labels

guidanceQuestion that needs advice or information.response-requestedWaiting on additional info or feedback. Will move to "closing-soon" in 5 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions