Skip to content

A command line app for appending awscli assume-role output to ~/.aws/credentials in a new profile

Notifications You must be signed in to change notification settings

JoshuaSchlichting/create-aws-profile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

create-aws-profile

BuildUnit Tests

create-aws-profile is a command line tool designed for managing AWS profiles within the ~/.aws/credentials file. It operates by having the output of aws sts assume-role piped into the program, like so:

aws sts assume-role --role-arn arn:aws:iam::000000000000:role/role-name --role-session-name AWSCLI-Session | create-aws-profile --profile desired-profile-name

The above command will create or modify the ~/.aws/credentials file and add the requested role under the --profile name passed to it. Any existing records for the --profile will be overwritten in ~/.aws/credentials.

How to use

Call the standard AWS CLI and pipe the output into create-aws-profile. Be sure to add a profile name with --profile. This is the profile name that you'll need to use to access the AWS CLI.

NOTE: Existing profiles with the same --profile name will be overwritten.

Install from GitHub

macOS

curl -o "/usr/local/bin/create-aws-profile" -L "https://github.com/JoshuaSchlichting/create-aws-profile/releases/download/v0.1.1/create-aws-profile_macos_x86_64" && chmod +x "/usr/local/bin/create-aws-profile/create-aws-profile"

Building

create bin/create-aws-profile_<os>_<arch> by executing ./build.sh

Install

Adding the --install flag, as shown below, will install the binary to /usr/local/bin. ./build.sh --install

aws sts assume-role --role-arn arn:aws:iam::<account>:role/OrganizationAccountAccessRole --role-session-name build-cicd | create-aws-profile --profile <local role name>

Next, you can specify the AWS_PROFILE you want your command to use, as shown below: AWS_PROFILE=<local role name> aws s3 ls

About

A command line app for appending awscli assume-role output to ~/.aws/credentials in a new profile

Resources

Stars

Watchers

Forks

Packages

No packages published