serverless-dynamodb-local
serverless-dynamodb-local copied to clipboard
dbPath property not taking relative path from current directory
I am running dynamodb with local env. I have specified below configuration in serverless.yml. dynamodb: start: port: 8000 dbPath: .\tmp migrate: true migration: dir: offline/migrations I expected to get db file created under tmp directory created in local project. But it gave error.
Invalid directory for database creation.Serverless:
the same here
Seems to work if you give it full path to directory rather than a relative path.
So you do something like this on Mac
dbPath: ${env:PWD}/tmp
This won't work in windows. And relative path works in other plugins like local S3.
Yep I get this error no matter what I do. On macos
dbPath: ${env:PWD}/tmp
This worked for me on Mac, if I mkdir tmp
before starting it up sls offline start
.
@rehrumesh @mjzone Will you be able to have a look into this?
still an issue. failed to use dbPath
with a relative path. the pwd
trick did it for me on osx
make your dbPath as below.
dbPath: ${env:HOME}/dynamodb-local
Looking at the code of the project, the relevent lines are:
let dbPath = options.dbPath;
if (dbPath) {
options.dbPath = path.isAbsolute(dbPath) ? dbPath : path.join(this.serverless.config.servicePath, dbPath);
}
So if your path isn't absolute, it'll take it from the serverless config servicePath
, which for me was <project root>/.build
and not in node_modules
as in the README
I created a new folder for my DB in my project root, and the following path works:
dbPath: ../.localdb_instance