Skip to content

Commit

Permalink
update console script for aws-credential-process-from-system
Browse files Browse the repository at this point in the history
  • Loading branch information
snigdhasjg committed Nov 10, 2023
1 parent 499f815 commit 8c0b547
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AWS Console Login Utility

## Command line tool
- `aws-console`
- `aws-system-credential`
- `aws-credential-process-from-system`

## Installation
### Via Pip
Expand Down Expand Up @@ -91,7 +91,7 @@ The docs
- https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html

---
## Usage of `aws-system-credential`
## Usage of `aws-credential-process-from-system`
The tool provides two main commands: `store` and `get`.
- Store AWS credentials in system default credential store
- Retrieve AWS credentials from system default credential store. Optionally plug the CLI to aws external credential process.
Expand All @@ -101,7 +101,7 @@ To store IAM user credential in the system credential store for best security ra

Manully the save the credential in the store using
```bash
aws-system-credential store \
aws-credential-process-from-system store \
--access-key 'AKIAIOSFODNN7EXAMPLE' \
--secret-key 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' \
--account-id '123456789012' \
Expand All @@ -114,10 +114,10 @@ Configure aws config file to use credential process
[profile iam-user]
region = us-east-1
output = json
credential_process = aws-system-credential get --account-id 123456789012 --username 'my-iam-user' --access-key 'AKIAIOSFODNN7EXAMPLE' --credential-process
credential_process = aws-credential-process-from-system get --account-id 123456789012 --username 'my-iam-user' --access-key 'AKIAIOSFODNN7EXAMPLE'
```

> Try `aws-system-credential --help` for detailed parameter
> Try `aws-credential-process-from-system --help` for detailed parameter
### Refer
The docs
Expand Down
4 changes: 2 additions & 2 deletions aws_console/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def aws_console():
open_console(url, args.clip, args.stdout)


def aws_system_credential():
def aws_credential_process_from_system():
args = credential_process_arguments()

if args.command == 'store':
store_aws_credential(args.account_id, args.username, args.access_key, args.secret_key)
elif args.command == 'get':
get_aws_credential(args.account_id, args.username, args.access_key, args.credential_process)
get_aws_credential(args.account_id, args.username, args.access_key)
2 changes: 0 additions & 2 deletions aws_console/input_output/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,5 @@ def credential_process_arguments():
# Subparser for 'get' command
get_parser = subparsers.add_parser('get',
help='Get AWS credentials', parents=[global_parser, get_store_common_parser])
get_parser.add_argument('--credential-process',
action='store_true', help='Use credential process')

return parser.parse_args()
17 changes: 7 additions & 10 deletions aws_console/system_credential_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ def store_aws_credential(account_id, username, access_key, secret_key):
keyring.set_password(service_name, access_key, secret_key)


def get_aws_credential(account_id, username, access_key, for_credential_process):
def get_aws_credential(account_id, username, access_key):
service_name = '-'.join(filter(None, ['aws', account_id, username]))
secret_key = keyring.get_password(service_name, access_key)

if for_credential_process:
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html
print(json.dumps({
"Version": 1,
"AccessKeyId": access_key,
"SecretAccessKey": secret_key
}))
else:
print(secret_key)
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html
print(json.dumps({
"Version": 1,
"AccessKeyId": access_key,
"SecretAccessKey": secret_key
}))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def find_version(*file_paths):
entry_points={
'console_scripts': [
'aws-console = aws_console:aws_console',
'aws-system-credential = aws_console:aws_system_credential'
'aws-credential-process-from-system = aws_console:aws_credential_process_from_system'
]
},
install_requires=[
Expand Down

0 comments on commit 8c0b547

Please sign in to comment.