Skip to content

RDSAuthTokenGenerator.GenerateAuthTokenAsync to provide for expiration parameter #4067

@jano-petras

Description

@jano-petras

Describe the feature

At the moment, RDS token expiry is hardcoded to 15 minutes when generating the token.

It would be good to have a parameter / overload added that provides a way to specify the token expiry.

In a scenario where we assume role for 1 hour and then generate RDS token, we cannot use the temporary credentials for 1 hour due to this hardcoded duration.

Use Case

This is a super simple change which will reduce the wastefulness of generating temporary credentials so frequently, only because of this hardcoded limitation.

Proposed Solution

sdk/src/Services/RDS/Custom/Util/RDSAuthTokenGenerator.cs

Add new overload:

private static string GenerateAuthToken(ImmutableCredentials immutableCredentials, RegionEndpoint region, string hostname, int port, string dbUser)
{
    return GenerateAuthToken(immutableCredentials, region, hostname, port, dbUser, FifteenMinutes);
}

Change existing one to:

private static string GenerateAuthToken(ImmutableCredentials immutableCredentials, RegionEndpoint region, string hostname, int port, string dbUser, TimeSpan tokenDuration)
{
    // ...
    request.Parameters.Add(XAmzExpires, ((int)Math.Ceiling(tokenDuration.TotalSeconds)).ToString(CultureInfo.InvariantCulture));
    // ...
}

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS .NET SDK and/or Package version used

Targeted .NET Platform

.NET Core 8

Operating System and version

AmazonLinux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions