Skip to content

TypeError: childComponentInstance.init is not a function #21

Description

@Arditc

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 :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions