Skip to content

Add session duration as an option for aws roles. #22

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.5.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jbuck:master was already 1.5.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Master is at 1.4.0 at the moment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@buptliuhs buptliuhs Dec 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, but in npm, 1.5.0 is already released.
https://www.npmjs.com/package/assume-aws-role/v/1.5.0

------------------
- Add session duration

1.4.0
------------------
- Update contributors list
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you currently manage multiple AWS accounts and use role switching to do work

First, you need to install the tool from NPM:

`npm install -g assume-aws-role`
`npm install -g nbrys/assume-aws-role`

Next, you need to add a role that you'd like to assume. As an example, lets say I wanted to add the Administrator role for my sandbox account with MFA required:

Expand Down Expand Up @@ -49,6 +49,8 @@ You can delete a defined alias with a single command:

Any roles you add are stored in `~/.assume-aws-role/config`. It's optional but highly recommended that you use a MFA device.

You can add `DurationSeconds` for each AWS profile. If you don't set this value, the default of 3600 will be used.

`assume-aws-role` uses the [STS:AssumeRole API](http://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) to assume the role you specified.

After receiving valid credentials `assume-aws-role` will spawn the shell specified in `$SHELL` with the environment modified to include `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN`. The environment also includes an overridden `PS1` with a minimal custom prompt, and `ASSUME_AWS_ROLE` with the role so you can fully customize the `PS1` prompt by yourself.
4 changes: 3 additions & 1 deletion bin/assume-aws-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ STS.assumeRole({
RoleArn: role.RoleArn,
RoleSessionName: "assume-aws-role-cli",
SerialNumber: role.SerialNumber,
TokenCode: token
TokenCode: token,
DurationSeconds: role.DurationSeconds
}, function(error, data) {
if (error) {
console.error(error);
Expand All @@ -134,6 +135,7 @@ STS.assumeRole({
modEnv.AWS_ACCESS_KEY_ID = data.Credentials.AccessKeyId;
modEnv.AWS_SECRET_ACCESS_KEY = data.Credentials.SecretAccessKey;
modEnv.AWS_SESSION_TOKEN = data.Credentials.SessionToken;
modEnv.AWS_SESSION_TOKEN_EXPIRATION = data.Credentials.Expiration

// required for boto sts to work
modEnv.AWS_SECURITY_TOKEN = data.Credentials.SessionToken;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "assume-aws-role",
"version": "1.4.0",
"version": "1.5.0",
"description": "Work with multiple AWS accounts more easily",
"homepage": "https://github.com/jbuck/assume-aws-role",
"bugs": {
Expand Down