Warm tip: This article is reproduced from serverfault.com, please click

InvalidSignatureException when using boto3 for dynamoDB on aws

发布于 2016-02-08 15:53:26

Im facing some sort of credentials issue when trying to connect to my dynamoDB on aws. Locally it all works fine and I can connect using env variables for AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION and then

dynamoConnection = boto3.resource('dynamodb', endpoint_url='http://localhost:8000')

When changing to live creds in the env variables and setting the endpoint_url to the dynamoDB on aws this fails with:

"botocore.exceptions.ClientError: An error occurred (InvalidSignatureException) when calling the Query operation: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."

The creds are valid as they are used in a different app which talks to the same dynamoDB. Ive also tried not using env variables but rather directly in the method but the error persisted. Furthermore, to avoid any issues with trailing spaces Ive even used the credentials directly in the code. Im using Python v3.4.4.

Is there maybe a header that also should be set that Im not aware of? Any hints would be apprecihated.

EDIT

Ive now also created new credentials (to make sure there are only alphanumerical signs) but still no dice.

Questioner
KalleJuhans
Viewed
11
garnaat 2016-02-09 11:36:38

You shouldn't use the endpoint_url when you are connecting to the real DynamoDB service. That's really only for connecting to local services or non-standard endpoints. Instead, just specify the region you want:

dynamoConnection = boto3.resource('dynamodb', region_name='us-west-2')