Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(credential-provider-ini): add DurationSeconds to assumeRole params #4938

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

RanVaknin
Copy link
Contributor

Issue

#4589

Description

This expands the assume role interface to be able to read DurationSeconds that is already provided by the ini file. Until now that value was not read even though it was technically available to consume, thus preventing from explicitly setting a duration on the session.

Reproduction:

ini file:

[profile myrole]
role_arn=arn:aws:iam::1234567890123:role/my_role
duration_seconds=1534
source_profile=default

[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
region = us-east-1

repro code:

import { decorateDefaultCredentialProvider } from '@aws-sdk/client-sts'
import { defaultProvider } from '@aws-sdk/credential-provider-node'

const provider = decorateDefaultCredentialProvider(defaultProvider)({})
const now = Date.now()
provider()
  .then((credentials) => {
    console.log(credentials)
    console.log(((credentials.expiration?.valueOf() ?? now) - now) / 1_000)
})

Output before change:

$ AWS_PROFILE=myrole node test.mjs                                                                
{
  accessKeyId: 'REDACTED',
  secretAccessKey: 'REDACTED',
  sessionToken: 'REDACTED',
  expiration: 2023-07-07T23:58:12.000Z
}
3599.726

Ouput after change:

$ AWS_PROFILE=myrole node test.mjs       
{
  accessKeyId: 'REDACTED',
  secretAccessKey: 'REDACTED',
  sessionToken: 'REDACTED',
  expiration: 2023-07-07T23:24:30.000Z
}
1534.216

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@RanVaknin RanVaknin requested a review from a team as a code owner July 7, 2023 23:24
@RanVaknin RanVaknin requested review from kuhe and trivikr July 7, 2023 23:26
@trivikr trivikr changed the title fix(credential-provider-ini): add DurationSeconds to assumeRole inter… fix(credential-provider-ini): add DurationSeconds to assumeRole params Aug 31, 2023
@RanVaknin RanVaknin force-pushed the add-duration-to-assumeRole branch from 934f5b1 to 438a6c3 Compare September 13, 2023 22:44
@trivikr trivikr merged commit 915b12d into aws:main Sep 14, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants