serverless-components / aws-dynamodb

⚡ Easily provision AWS DynamoDB tables using Serverless Components.
https://www.serverless.com
Apache License 2.0
59 stars 11 forks source link

TypeError: childComponentInstance.init is not a function #21

Open Arditc opened 3 years ago

Arditc commented 3 years ago

Hi, I'm trying to add a database (dynamodb) into my serverless file, however I get this error:

 error:
  TypeError: childComponentInstance.init is not a function
    at Template.load (/usr/local/lib/node_modules/serverless/node_modules/@serverless/core/src/Component.js:116:34)
    at async fn (/usr/local/lib/node_modules/serverless/node_modules/@serverless/template/utils.js:272:25)
    at async Promise.all (index 1)
    at async executeGraph (/usr/local/lib/node_modules/serverless/node_modules/@serverless/template/utils.js:294:3)
    at async Template.default (/usr/local/lib/node_modules/serverless/node_modules/@serverless/template/serverless.js:67:38)
    at async Object.runComponents (/usr/local/lib/node_modules/serverless/node_modules/@serverless/cli/src/index.js:220:17)

  47s › Template › TypeError: childComponentInstance.init is not a function

Do you have any ideas on how I can add a dynamodb table via serverless?

I've used @serverless/aws-dynamodb and that works fine, however I wanted to use the latest serverless component.

Here are some details regarding my serverless versions:

serverless --version

Framework Core: 1.74.1
Plugin: 3.6.15
SDK: 2.3.1
Components: 2.31.10

Serverless file:

App:
  component: "@sls-next/serverless-component@1.18.0"
  inputs:
    roleArn: xxxx
    domain: "xxxxx" # sub-domain defaults to www
    cloudfront:
      distributionId: xxxxx
      defaults:
        forward:
          cookies: "none"

database:
  component: aws-dynamodb          # (required) name of the component. In that case, it's aws-dynamodb.
  name: app-db                   # (required) name of your instance.

  inputs:
    name: app-db
    attributeDefinitions:
      - AttributeName: id
        AttributeType: S
      - AttributeName: attribute1
        AttributeType: N
    keySchema:
      - AttributeName: id
        KeyType: HASH
      - AttributeName: attribute1
        KeyType: RANGE
    localSecondaryIndexes:
      - IndexName: 'myLocalSecondaryIndex'
        KeySchema:
          - AttributeName: id
            KeyType: HASH
          - AttributeName: attribute2
            KeyType: RANGE
        Projection:
          ProjectionType: 'KEYS_ONLY'
    globalSecondaryIndexes:
      - IndexName: 'myGlobalSecondaryIndex'
        KeySchema:
          - AttributeName: attribute2
            KeyType: HASH
        Projection:
          ProjectionType: 'ALL'
    region: us-east-1

Many thanks :)

amanvir commented 3 years ago

Also running into the same issue, haven't had a chance to investigate, has anybody else taken a look?

techexe-code commented 3 years ago

also I am getting same error

lracicot commented 2 years ago

Same issue here.

Geoff-Ford commented 2 years ago

Did you get anywhere with this? I have the same issue still in 2022!

williamrjribeiro commented 2 years ago

@Geoff-Ford What solved this issue for me was using the name of the latest version of the component: "@serverless/aws-dynamodb"

If aws-dynamodb is used, I think it installs a very old version which is not compatible with components-v1 command. I hope it helps.