Home > Enterprise >  AWS Toolkit Visual Studio Code Mac Unable to locate credentials
AWS Toolkit Visual Studio Code Mac Unable to locate credentials

Time:11-25

I successfully installed aws toolkit in my visual studio code. I set all the credentials with region and the file is at .aws. In Visual Studio the aws explorer shows my profile.

But when i try to run the following code:

import boto3 
import pprint as pp

dynamodb_client = boto3.client('dynamodb')

table_name = 'Test_Dynamo' 

pk = 'U-0001'
stmt = f"SELECT * FROM {table_name} WHERE pk=? and begins_with(sk,'#U')" 
pmt =[{ "S": pk }] 

resp = dynamodb_client.execute_statement( Statement=stmt , Parameters= pmt ) 

pp.pprint(resp['Items']) 

I get the following Error

Unable to locate credentials

I was expecting to fetch a Item from the DynamoDB.

Im running the code in the jupyter notebook extension of Visual Studio Code and my aws account is a free tier, if this has something to do with it.

CodePudding user response:

You are saying you set all the credentials with region. As far as i know, the credentials are stored in a credentials file and the region is stored in a config file. Maybe it has something to do with that, that you probably put both in the same file which causes problems, can you check?

  • Related