-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
[WIP] Add option for Role session name to EKS subcommands #8994
Open
murshed-panorama
wants to merge
2
commits into
aws:v2
Choose a base branch
from
murshed-panorama:eks/role_session_name_option_v2
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ def setUp(self): | |
super(TestGetTokenCommand, self).setUp() | ||
self.cluster_name = 'MyCluster' | ||
self.role_arn = 'arn:aws:iam::012345678910:role/RoleArn' | ||
self.session_name = 'CustomSessionName123' | ||
self.access_key = 'ABCDEFGHIJKLMNOPQRST' | ||
self.secret_key = 'TSRQPONMLKJUHGFEDCBA' | ||
self.session_token = 'TOKENTOKENTOKENTOKEN' | ||
|
@@ -174,6 +175,28 @@ def test_url_with_arn(self): | |
) | ||
self.assert_url_correct(response, has_session_token=True) | ||
|
||
def test_url_with_arn_and_session_name(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is mostly copied from |
||
cmd = 'eks get-token --cluster-name %s' % self.cluster_name | ||
cmd += ' --role-arn %s' % self.role_arn | ||
cmd += ' --session-name %s' % self.session_name | ||
self.parsed_responses = [ | ||
{ | ||
"Credentials": { | ||
"AccessKeyId": self.access_key, | ||
"SecretAccessKey": self.secret_key, | ||
"SessionToken": self.session_token, | ||
}, | ||
} | ||
] | ||
response = self.run_get_token(cmd) | ||
assume_role_call = self.operations_called[0] | ||
self.assertEqual(assume_role_call[0].name, 'AssumeRole') | ||
self.assertEqual( | ||
assume_role_call[1], | ||
{'RoleArn': self.role_arn, 'RoleSessionName': self.session_name}, | ||
) | ||
self.assert_url_correct(response, has_session_token=True) | ||
|
||
def test_token_has_no_padding(self): | ||
cmd = 'eks get-token --cluster-name %s' % self.cluster_name | ||
num_rounds = 100 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have preferred to name this option
--role-session-name
instead of--session-name
for clarity, but that would mean having two options with names that begin with--role
.This causes an ambiguity with this section of the file
update_kubeconfig.py
, where it adds an option--role
, which normally gets matched to--role-arn
in this file.To minimize changes and preserve backwards compatibility, I instead use
--session-name
for the option.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is consistent with
aws-iam-authenticator
s flag name, no objection to the name