It turns out that if you set an environment variable named AWS_PROFILE, all AWS SDKs (including the CLI) will respect that value when looking for credentials for the current command.

Thanks to my brother, Ben, for pointing this out to me. It cleaned up a ton of boilerplate in some Ruby code I’ve been writing.