I have two AWS Accounts configured in my local. One with the default profile and another with a named profile. I am able to use the AWS CLI to connect to both the accounts and perform operations as follows.
I need to do the same using python and I am using VSCode. I have installed the AWS Toolkit for VSCode and now I can view the list of buckets from both accounts by selecting the correct AWS profile.
However, when I run my python code with the named profile selected, I receive the list of buckets from the default profile and not from the named profile. This is true for all AWS services and not only S3. It seems changing the AWS Profile in VSCode does not affect the runtime. It connects to the default AWS profile only.
Did anyone else face similar issues in the past? How can I mitigate this and connect to the named profile without explicitly creating a Boto3 session?