Skip to content

Commit 5334deb

Browse files
authored
Merge pull request #23 from plinde/plinde/token-as-argument
Adds --token as an optional argument
2 parents e3b25fc + bcb6544 commit 5334deb

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

awsmfa/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def main():
7979
help="Setup a new log term credentials section",
8080
action="store_true",
8181
required=False)
82+
parser.add_argument('--token', '--mfa-token',
83+
type=str,
84+
help="Provide MFA token as an argument",
85+
required=False)
8286
args = parser.parse_args()
8387

8488
level = getattr(logging, args.log_level)
@@ -273,10 +277,14 @@ def validate(args, config):
273277

274278

275279
def get_credentials(short_term_name, lt_key_id, lt_access_key, args, config):
276-
console_input = prompter()
277-
mfa_token = console_input('Enter AWS MFA code for device [%s] '
278-
'(renewing for %s seconds):' %
279-
(args.device, args.duration))
280+
if args.token:
281+
logger.debug("Received token as argument")
282+
mfa_token = '%s' % (args.token)
283+
else:
284+
console_input = prompter()
285+
mfa_token = console_input('Enter AWS MFA code for device [%s] '
286+
'(renewing for %s seconds):' %
287+
(args.device, args.duration))
280288

281289
client = boto3.client(
282290
'sts',

0 commit comments

Comments
 (0)