Had an AWS STS AssumeRole problem today; digging in it turned out the problem was that AssumeRole was not actually being invoked. Digging around I was unsurprised to find that @ben11kehoe had already clearly stated the problem and GitHub user petitout had example Go code with the right way to do it.

https://github.com/aws/aws-sdk-go-v2/issues/1382#issuecomment-1010464182

Better AssumeRole example · Issue #1382 · aws/aws-sdk-go-v2

Is your feature request related to a problem? Please describe. On the cli, it's aws sts assume-role --role-arn "arn:aws:iam::XYZ:role/ViewLogsPlease" --role-session-name ViewOne And then you awkwar...

GitHub
Laughed out loud seeing this again and realizing that the “almost certainly not what you want” code ignores the potential error from config.LoadDefaultConfig and the “almost certainly what you do want” code checks it. That is not the only reason why the second code snippet is better 🤣