Created
August 7, 2025 21:55
-
-
Save ddoc/fb6ebe615cfe71a0752ec4c02b1dd8b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Description: Generate AWS config file from Britive Profiles with proper space handling | |
| # Requires: | |
| # - Bash v4 or higher: brew install bash | |
| # - Britive CLI: pip3 install --upgrade pybritive | |
| # Usage: | |
| # # make sure to backup your original ~/.aws/config | |
| # sh ./aws-generate-profiles | tee ~/.aws/config | |
| set -eou pipefail | |
| BRITIVE_PROFILES="$(pybritive ls profiles --format=csv | awk -F',' '$1 ~ /AWS|reltio-organization/ && $3 ~ /Team-DevOps|team-devops/ { print $0 }')" | |
| while read -r BRITIVE_PROFILE; do | |
| BRITIVE_ENV_NAME_RAW="$(echo "${BRITIVE_PROFILE}" | awk -F '[()]' '{print $2}')" | |
| BRITIVE_ENV_NAME="${BRITIVE_ENV_NAME_RAW// /-}" # Replace spaces with dashes | |
| BRITIVE_ENV_ID="$(echo "${BRITIVE_PROFILE}" | awk -F',' '{print $2}' | awk '{print $1}')" | |
| BRITIVE_APP_NAME="$(echo "${BRITIVE_PROFILE}" | awk -F',' '{print $1}')" | |
| BRITIVE_PROFILE_NAME="$(echo "${BRITIVE_PROFILE}" | awk -F',' '{print $3}')" | |
| BRITIVE_PROFILE_FULLNAME="${BRITIVE_APP_NAME}/${BRITIVE_ENV_NAME_RAW}/${BRITIVE_PROFILE_NAME}" | |
| echo "[profile ${BRITIVE_ENV_NAME}]" | |
| echo "credential_process=pybritive-aws-cred-process --profile \"${BRITIVE_PROFILE_FULLNAME}\"" | |
| echo "[profile ${BRITIVE_ENV_ID}]" | |
| echo "credential_process=pybritive-aws-cred-process --profile \"${BRITIVE_PROFILE_FULLNAME}\"" | |
| done < <(echo "${BRITIVE_PROFILES}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment