DynamoDB connector for loopback-datasource-juggler. Because Dynamo doesn't get enough love.
- Installation
- Creating a DynamoDB data source
- Properties
- Using the DynamoDB connector
- Local development with DynamoDB Local
In your application root directory, enter:
$ npm install loopback-connector-dynamodb --save
This will install the module from npm and add it as a depenency to the application's package.json file.
Use the Datasource generator to add a DynamoDB data source to your application. The entry in the application's /server/datasources.json
will look like this:
"mydb": {
"name": "mydb",
"connector": "dynamodb"
}
Edit datasources.json
to add other properties to enable you to connect the data source to a DynamoDB database.
Property | Type | Description |
---|---|---|
connector | String | Connector name, either loopback-connector-dynamodb or dynamodb |
region | String | AWS Region to connect to. May also be set to local to use an instance of DynamoDB Local. |
debug | Boolean | If true , turn on verbose mode to debug requests and lifecycle. |
credentials | String | Method to locate credentials for the AWS SDK for Javascript. Valid values are: env , shared , iamrole , file . Default value: shared . |
credfile | String | If credentials method is file , specify the location of the JSON file to load. |
profile | String | Name the profile to use if using the shared credentials method. |
endpoint | Number | URL to use connecting to DynamoDB Local. Default is 8000 . Example: http://localhost:8000/ Note: this property is ignored if region is not local . |
For example:
Example datasources.json file
{
"dynamo_dev": {
"name": "dynamo_dev",
"connector": "dynamodb",
"region": "local",
"credentials": "shared",
"profile": "localdev",
"port": 4567
},
"dynamo_qa": {
"name": "dynamo_qa",
"connector": "dynamodb",
"region": "us-west-2",
"credentials": "iamrole"
}
}
aws_access_key_id
and aws_secret_access_key
directly in your datasources.json
file.
This is intentional. Putting credentials like that into a file are A Very Bad Thing. Quit trying to do that.