Hi @fideloper thanks for the reply!
I see but wouldn't that fallback to the DefaultCredentialsProvider?
I was under the assumption that there is some performance concerns over using DefaultCredentialsProvider and if possible we should use a specific credentials provider depending on our use case.
As per the docs
Create a default credential provider that first checks for environment variables, then checks for assumed role via web identity, then checks for cached SSO credentials from the CLI, then check for credential_process in the "default" profile in ~/.aws/credentials, then checks for the "default" profile in ~/.aws/credentials, then for credential_process in the "default profile" profile in ~/.aws/config, then checks for "profile default" profile in ~/.aws/config (which is the default profile of AWS CLI), then tries to make a GET Request to fetch credentials if ECS environment variable is presented, finally checks for EC2 instance profile credentials.
As mentioned, it will check credentials in so many places before actually using EC2 instance profile credentials.
Let's say you are running this code on AWS Lambda, then you should use credentials provider which loads data from environment variables, while when running in EC2 you should be using the InstanceProfileProvider
Was wondering if there is a way to specify the credentials provider as InstanceProfileProvider here
Let me know what you think @fideloper