In my case, i had a terraform apply task that takes much time to execute on an azure pipeline, in order to provision the infrastructure on aws.
I had to add this command to the aws connection task aws sts get-session-token --duration-seconds 3600 to extend the duration time for the session token