Reorganise scripts

This commit is contained in:
pfych 2024-08-16 22:49:20 +10:00
parent 5ebf7f9b5c
commit 4ae0656da4
18 changed files with 196 additions and 104 deletions

View 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
}