From 7c270a85cdeb002722659d5e5f80083e3012621e Mon Sep 17 00:00:00 2001 From: ad-m-ss <99484706+ad-m-ss@users.noreply.github.com> Date: Fri, 25 Feb 2022 01:36:13 +0100 Subject: [PATCH] Add support for store MFA duration in config of profile --- awsmfa/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/awsmfa/__init__.py b/awsmfa/__init__.py index 21e7096..beb4998 100755 --- a/awsmfa/__init__.py +++ b/awsmfa/__init__.py @@ -37,7 +37,8 @@ def main(): "Defaults to 43200 (12 hours), or 3600 (one " "hour) when using '--assume-role'. This value " "can also be provided via the environment " - "variable 'MFA_STS_DURATION'. ") + "variable 'MFA_STS_DURATION' or the" + " ~/.aws/credentials variable 'aws_mfa_duration'.") parser.add_argument('--profile', help="If using profiles, specify the name here. The " "default profile name is 'default'. The value can " @@ -189,6 +190,8 @@ def validate(args, config): if not args.duration: if os.environ.get('MFA_STS_DURATION'): args.duration = int(os.environ.get('MFA_STS_DURATION')) + elif config.has_option(long_term_name, 'aws_mfa_duration'): + args.duration = int(config.get(long_term_name, 'aws_mfa_duration')) else: args.duration = 3600 if args.assume_role else 43200