0

I get: The security token included in the request is invalid

Where do I get a session token? The current documentation is confusing. On the one hand it says:

If you make a request using AWS::DynamoDB with long-term credentials a request is made to Amazon STS for temporary session credentials. These will be cached in the process and re-used.

and next it says:

Amazon DynamoDB requires that all requests are made with short-term credentials (e.g. requires a session token).

so exactly where does the session_token come from if I don't provide it? And if the call provides it, why would it be invalid?

requires 'aws-sdk'

cred = {:access_key_id => 'xxxx', 
:secret_access_key => 'yyyy'}

#:session_token => ''}

ddb = AWS::DynamoDB.new(cred)
items = {...}
ddb.batch_write do |batch|
  batch.put('my_mappings', items)
end
1
  • Note that in irb, the initiation of a DynamoDB.new works fine with only the :access_key_id and the :secret_access_key. No session_key is necessary. As well, in code, I can work with the 'ddb' handle. Commented Feb 26, 2013 at 15:55

2 Answers 2

0

The documentation is incorrect/old (its been changed on the master branch in GitHub). You no longer require session credentials to use DynamoDB. You should be able to configure just your :access_key_id and :secret_access_key.

If you do want session credentials, you can get them from AWS::STS.

Sign up to request clarification or add additional context in comments.

Comments

0

After some trial and error, I found that the following works.

cred = {:access_key_id => 'xxxx', 
:secret_access_key => 'yyyy', :session_token => nil}

ddb = AWS::DynamoDB.new(cred)

In my original example, the ddb handle would work for certain operations but not for batch_write. Passing the 'nil' works. The documentation is unclear and the API is inconsistent in the current version.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.