Aws-sdk-js: Local DynamoDB doesn't work.

Created on 20 Jan 2016  路  14Comments  路  Source: aws/aws-sdk-js

I'm trying to configure the DynamoDB client to connect to a local dynamodb for dev like this:

var db = new AWS.DynamoDB({
  endpoint: new AWS.Endpoint(url)
});

It throws this config error here: https://github.com/aws/aws-sdk-js/blob/07e0bb831e777918538ef724a6665f109b5f3852/lib/event_listeners.js#L82

Setting region doesn't make sense when connecting to local dynamodb, but If I put it in anyway, it then fails on: https://github.com/aws/aws-sdk-js/blob/07e0bb831e777918538ef724a6665f109b5f3852/lib/event_listeners.js#L73

guidance

Most helpful comment

@chrisradek
I'm using vogels (vogels.AWS is AWS) and after updating aws-sdk i'm getting error there

import vogels from 'vogels'
import requireDir from 'require-dir'

vogels.AWS.config.update({
  endpoint: process.env.AWS_DYNAMODB_ENDPOINT,
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  region: process.env.AWS_REGION
})

module.exports = async function() { // create tables

  return new Promise(function (resolve, reject) {
    requireDir()

    vogels.createTables((err) => {
      if (err) {
        console.log(`Error creating tables: ${err}`)
        return reject(`Error creating tables: ${err}`)
      }
      resolve()
    })
  })

}

All 14 comments

@Qard
You also need to specify credentials. Since you're working with your local dynamodb, I don't believe your credentials have to be valid, but the SDK needs something otherwise it will continue to display the Missing credentials in config error.

Let me know if that helps or if you need an example!

Yeah, I figured that much out. It seems broken to me that I'd have to set a bunch of configs that it doesn't actually use to get it to work properly though.

@Qard Your credentials are used by DynamoDB local to maintain separate databases for different users. Your credentials won't be checked, but those configuration parameters do serve a purpose.

If you scroll up on the page you've linked to, you'll see documentation on the --sharedDb option. If not set, your database will be saved in a file named {myaccesskeyid}_{region}.db.

I'll let the doc author know that "Regions and distinct AWS accounts are not supported at the client level" is confusingly worded.

Getting same error
UnrecognizedClientException: The security token included in the request is invalid. when trying to create tables in local db

when i provided valid credentials, table created, but on aws service, not local

This functionality become broken on npm 2.2.32 version

@chrisradek

@Alex0007
Can you provide a code snippet? Are you updating the endpoint to look at your local database?

@chrisradek
I'm using vogels (vogels.AWS is AWS) and after updating aws-sdk i'm getting error there

import vogels from 'vogels'
import requireDir from 'require-dir'

vogels.AWS.config.update({
  endpoint: process.env.AWS_DYNAMODB_ENDPOINT,
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  region: process.env.AWS_REGION
})

module.exports = async function() { // create tables

  return new Promise(function (resolve, reject) {
    requireDir()

    vogels.createTables((err) => {
      if (err) {
        console.log(`Error creating tables: ${err}`)
        return reject(`Error creating tables: ${err}`)
      }
      resolve()
    })
  })

}

@chrisradek @jeskew
Please, reopen this issue, because the problem really exist

@Alex0007 I'm unable to reproduce the behavior you're experiencing. Have you verified that process.env.AWS_DYNAMODB_ENDPOINT is properly set?

@jeskew
it seems that code working again on aws-sdk latest version

Glad to hear everything worked out. Let me know if you have any further questions.

Getting the same error now.
Just npmd the latest release a few minutes ago,
I get this from dynamo
UnrecognizedClientException: The security token included in the request is invalid

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings