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

Adding additional argument to provide custom Credentials file #82

Open
wants to merge 1 commit 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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ Usage
-----

```
--credentials-filepath '\custom_path\.aws\credentials'
Specify AWS Credentials filepath to be used
instead of default Credentials file.'.
--device arn:aws:iam::123456788990:mfa/dudeman
The MFA Device ARN. This value can also be provided
via the environment variable 'MFA_DEVICE' or the
Expand Down
10 changes: 10 additions & 0 deletions awsmfa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@


def main():
global AWS_CREDS_PATH
parser = argparse.ArgumentParser()
parser.add_argument('--credentials-filepath',
required=False,
metavar='\custom_path\.aws\credentials',
help="Specify AWS Credentials filepath to be used "
"instead of default Credentials file.")
parser.add_argument('--device',
required=False,
metavar='arn:aws:iam::123456788990:mfa/dudeman',
Expand Down Expand Up @@ -88,6 +94,10 @@ def main():
level = getattr(logging, args.log_level)
setup_logger(level)

# Use user provided Credentials file
if args.credentials_filepath:
AWS_CREDS_PATH = args.credentials_filepath;

if not os.path.isfile(AWS_CREDS_PATH):
console_input = prompter()
create = console_input("Could not locate credentials file at {}, "
Expand Down