aws cred to env
Rafaf Tahsin

Rafaf Tahsin @rafaftahsin

About: Mostly, a DevOps Engineer

Location:
Dhaka, Bangladesh
Joined:
May 10, 2023

aws cred to env

Publish Date: Jul 12 '23
0 0

Sometimes it's tidy to export aws credentials manually. It can be done by the following script

#!/bin/bash

echo "# Environment for AWS profile '$1'"
export AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id --profile $1)
export AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key --profile $1)
export AWS_DEFAULT_REGION=$(aws configure get region --profile $1)
Enter fullscreen mode Exit fullscreen mode

source the script and you are done.

Note:

Saving script as script.sh and calling it with ./script.sh won't work. Need to source it like source script.sh or . script.sh.

Inspired by https://gist.github.com/mjul/f93ee7d144c5090e6e3c463f5f312587

Comments 0 total

    Add comment