for user in $(aws iam list-users --query 'Users[*].UserName' --output text); do
# 사용자가 속한 그룹 목록을 가져오기
user_groups=$(aws iam list-groups-for-user --user-name $user --query 'Groups[*].GroupName' --output text)
# 사용자가 그룹에 속해 있는지 확인 (그룹이 없으면 건너뜀)
if [ -n "$user_groups" ]; then
# 사용자가 Application 또는 application 그룹에 속해 있는지 확인 (대소문자 무시)
if [[ ! "$user_groups" =~ [Aa]pplication ]]; then
# MFA 설정 여부 확인
mfa_count=$(aws iam list-mfa-devices --user-name $user --query 'MFADevices | length(@)')
# MFA가 설정되지 않은 경우, 사용자 그룹 / 사용자 이름 출력
if [ $mfa_count -eq 0 ]; then
echo "$user_groups / $user"
fi
fi
fi
done