Reorganise scripts
This commit is contained in:
parent
5ebf7f9b5c
commit
4ae0656da4
18 changed files with 196 additions and 104 deletions
33
.config/scripts/tool/aws-profile.sh
Executable file
33
.config/scripts/tool/aws-profile.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
function awsconfig {
|
||||
AWS_PROFILE=$(cat ~/.aws/credentials \
|
||||
| grep "\[" \
|
||||
| fzf \
|
||||
| tr -d "[" \
|
||||
| tr -d "]" \
|
||||
| xargs
|
||||
)
|
||||
|
||||
clear
|
||||
|
||||
vim /tmp/raw_keys.tmp
|
||||
|
||||
cat /tmp/raw_keys.tmp | grep -v "\[.*\]$" > /tmp/keys.tmp
|
||||
|
||||
export $(xargs < /tmp/keys.tmp)
|
||||
|
||||
rm /tmp/raw_keys.tmp /tmp/keys.tmp
|
||||
|
||||
aws configure set aws_access_key_id "${aws_access_key_id}" --profile "$AWS_PROFILE"
|
||||
aws configure set aws_secret_access_key "${aws_secret_access_key}" --profile "$AWS_PROFILE"
|
||||
aws configure set aws_session_token "${aws_session_token}" --profile "$AWS_PROFILE"
|
||||
|
||||
echo "Testing AWS Keys..."
|
||||
IAM_RESULT=$(aws sts get-caller-identity --query "Account" --output text --profile "$AWS_PROFILE")
|
||||
|
||||
if [ "$IAM_RESULT" ]; then
|
||||
echo "Credentials work!"
|
||||
else
|
||||
echo "AWS Keys did not work!"
|
||||
fi
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue