Minio s3 access

Easiest way to use minio when you are using AWS SSO logins is to set a variable. This is a zsh function but bash function also works.

NOTE: I convert my AWS profile dash with underscore.

#!/bin/bash
if [ $# -eq 0 ]; then
  echo "Error: No AWS profile provided. Usage: $0 <argument>"
  #exit 1
else
  aws_profile=$1
  mc_alias="${aws_profile//-/_}"
  eval $(aws configure export-credentials --profile ${aws_profile} --format env)
  export MC_HOST_${mc_alias}="https://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}:${AWS_SESSION_TOKEN}@s3.amazonaws.com"
  echo "NOTE: MC alias to use is: ${mc_alias}"
fi