Serverless start not creating local DynamoDB database from yaml file

Serverless start not creating local DynamoDB database from yaml file



Im new to AWS. I far as i read, to create tables on start we need migrate: true under custom.dynamodb in yaml file. I have written serverless.yml file as follows.


migrate: true


custom.dynamodb


provider:
name: aws
runtime: nodejs8.10
profile: default
region: us-east-1
memorySize: 512
target: 'node' # Below defined environment variables wont be accessible in lambda functions.
stage: $opt:stage, 'dev'
environment:
USERS_TABLE: Users_$self:provider.stage
DAILYACTIVITY_TABLE: DailyActivity_$self:provider.stage
plugins:
- serverless-dynamodb-local
- serverless-offline
custom:
dynamodb:
start:
migrate: true
resources:
Resources:
usersTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: emailid
AttributeType: S
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: emailid
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: gsi_id
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TableName: $self:provider.environment.USERS_TABLE
activityTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: date
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: date
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TableName: $self:provider.environment.DAILYACTIVITY_TABLE



But sls offline start does not create tables from resources section.
Please suggest what is wrong with the above config.


sls offline start





Not sure if it would be related, but I had to change the version of serverless-dynamodb-local to 0.2.30 due to a different bug.
– Jordan
Aug 30 at 16:39





how to do that?
– pritesh
Aug 31 at 7:50





Assuming you already ran sls dynamodb install. * sls dynamodb uninstall *npm uninstall 'your current version' *npm install -D serverless-dynamodb-local@0.2.30 *sls dynamodb install
– Jordan
Aug 31 at 20:27



sls dynamodb install


sls dynamodb uninstall


npm uninstall 'your current version'


npm install -D serverless-dynamodb-local@0.2.30


sls dynamodb install





yes, i did. Right now, i'm creating all the tables with separate script. cause sls is not creating tables by itself from serverless.yml file
– pritesh
Sep 3 at 19:17







Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

PHP code is not being executed, instead code shows on the page

Administrative divisions of China

Cardinality of the set of algorithms