trap 'echo GOT ERROR, exiting' ERR
Simply saying "exiting" doesn't mean it's also true ;-)
An ERR trap will executed whenever a command fails, no matter if the script exit immediately afterwards (eg. because of set -e) or not:
$ bash -c 'trap "echo error, not exiting yet" ERR; false; echo DONE'
error, not exiting yet
DONE
In your case the command which fails may be date or aws, but it's most probably sleep (which is an external, not a built-in command). sleep exits with a non-zero status (= failure, thence the ERR trap triggered) because it's also killed by the signal sent by timeout: timeout first sends a signal to its child, and then to the entire process group it's part of:
$ strace -e trace=kill timeout 1s bash -c 'echo $$; while :; do sleep 3600; done
'
4851
...
kill(4851, SIGTERM) = 0
kill(0, SIGTERM) = 0
...
The shell won't run any trap until after any childthe foreground command it's waiting for has exited; and if timeout weren't signaling the whole process group (which can be achieved with the --foreground option), the childthat foreground command may nevernot exit, and the trap may nevernot run:
$ timeout 1s bash -c 'trap "echo TERM caught" TERM; sleep 36000; echo DONE'
Terminated
TERM caught
DONE
$ timeout --foreground 1s bash -c 'trap "echo TERM caught" TERM; sleep 36000; echo DONE'
<wait and wait>