Create a database table using Google Cloud Platform

google

#1

Hi,
I am working on my second project using serverless framework. I did the first one using AWS and now I wanted to give it a try to Google Cloud Platform. Everything was going fine until I needed to create a database table to store some data.

I AWS I would have added this to my serverless.yml file:

resources:
  Resources:
    userEventsDynamoDbTable:
      Type: 'AWS::DynamoDB::Table'
      DeletionPolicy: Retain
      Properties:
        AttributeDefinitions:
          - AttributeName: username
            AttributeType: S
        KeySchema:
          - AttributeName: username
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        TableName: 'users'

But I have no idea what is the equivalent in GCP. After looking for a while in the google documentation, I found this: https://cloud.google.com/deployment-manager/docs/configuration/supported-resource-types but no examples of specifically create a table.

I have tried with the following, as I thought I might need an instance before having a table:

resources:
  resources:
    - type: bigtableadmin.v2.instance
      name: my-serverless-service-instance

but then I get this error when deploying:

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Compiling function "slackDispatcher"...
Serverless: Uploading artifacts...
Serverless: Artifacts successfully uploaded...
Serverless: Updating deployment...
Serverless: Checking deployment update progress...
 
  Error --------------------------------------------------
 
  Unexpected token M in JSON at position 0
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Forums:        forum.serverless.com
     Chat:          gitter.im/serverless/serverless
 
  Your Environment Information -----------------------------
     OS:                     linux
     Node Version:           6.11.3
     Serverless Version:     1.23.0

Does anyone know how to simply create a table in GCP the same way you would create a DynamoDB table in AWS?

Thanks


#2

I am running into the exact same problem while setting up a pub/sub topic. Did you figure this one out?