Created
January 22, 2018 19:57
-
-
Save bortels/8556ed6c670dcae81890d045cbe84c9b to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
# export the AWS environment for a given profile | |
import boto3 | |
import argparse | |
parser = argparse.ArgumentParser(prog="exportaws", | |
description="Extract AWS credentials for a profile as env variables.") | |
parser.add_argument("profile", help="profile name in ~/.aws/config.") | |
args = parser.parse_args() | |
creds = boto3.session.Session(profile_name=args.profile).get_credentials() | |
print(f'export AWS_ACCESS_KEY={creds.access_key}') | |
print(f'export AWS_SECRET_ACCESS_KEY={creds.secret_key}') | |
print(f'export AWS_SESSION_TOKEN={creds.token}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment