I am trying to see if an AWS user has more than one access key on an account. I get the number of access keys with this line:
readarray old_access_keys < <(aws iam list-access-keys --user-name "$aws_user_name" --profile="$aws_key" | jq -r '.AccessKeyMetadata[].AccessKeyId')
And if he has more than one access key, the script should return:
if (( "${!old_access_keys[@]}" > 1 )); then
printf "User already has maximum keys allowed for this account.\\n\\n"
return
else
...some commands...
fi
But when I run this script I get and error when I do that comparison:
./aws_key_utils.sh: line 480: ((: 0 1 > 1 : syntax error in expression (error token is "1 > 1 ")
How can I compare the number of elements in the array against 1 correctly?