technogise / dynamo-data-migrations

Dynamo DB data migration tool
MIT License
29 stars 7 forks source link

Require support to connect to locally hosted DynamoDB #27

Open yogeshwar-chaudhari opened 4 weeks ago

yogeshwar-chaudhari commented 4 weeks ago

The current version requires specifying an AWS region for all profiles, which is not applicable to local DynamoDB setups. While using region for connecting to the local DynamoDB instance throws an exception of an invalid session token since it actually tries to connect with a table in that region.

# config.json
{
  "awsConfig": [
    {
      "profile": "default",
      "region": "ap-southeast-2"
    },
    {
      "profile": "local-dynamo-db",
      "region": "ap-southeast-2"
    }
  ],
  "migrationsDir": "build/migrations",
  "migrationType": "mjs"
}

dynamo-data-migrations status --profile local-dynamo-db
Error: UnrecognizedClientException: The security token included in the request is invalid.

Using any other value such as local the SDK will throw an error


# config.json
{
  "awsConfig": [
    {
      "profile": "default",
      "region": "ap-southeast-2"
    },
    {
      "profile": "local-dynamo-db",
      "region": "local"
    }
  ],
  "migrationsDir": "build/migrations",
  "migrationType": "mjs"
}

dynamo-data-migrations status --profile local-dynamo-db
Error: getaddrinfo ENOTFOUND dynamodb.local.amazonaws.com```

**Possible Solution:**

1. Introduce a property named `endpoint` in config.
2. Use optional param --local that will make use of this `endpoint` property while initialising the SDK.
jeggers-88 commented 1 week ago

I also would appreciate to support the use of a locally running dynamodb for example with localstack (for example for integration tests or testing the migration scripts locally first). For that we would need to make an endpoint configurable like it was proposed here.