Unable to reference a variable in environment variable

part of my serverless.yml

custom:
  tables:
    userSignup: userSignup-table

functions:
  signup:
    handler: handler.signup
    name: ${self:custom.prefix}-signup
    environment:
      tables:
        userSignup: ${self:custom.tables.userSignup}

getting this error while deploying

  Serverless Error ---------------------------------------

  An error occurred while provisioning your stack: SignupLambdaFunction - Value of property Variables must be an object with String (or simple type) properties.

  Your Environment Information -----------------------------
     OS:                     win32
     Node Version:           6.10.0
     Serverless Version:     1.16.0

anyone knows whats wrong in here?

Can’t nest the userSignup key under the tables key.
environment contents must only be 1 layer deep of “key: value” pairs.

example:

functions:
  signup:
    handler: handler.signup
    name: ${self:custom.prefix}-signup
    environment:
      userSignupTable: ${self:custom.tables.userSignup}

Hope it helps.

3 Likes