OS: darwin
Node Version: 8.11.2
Serverless Version: 1.26.0
Problem is I can’t access env variables with process.env.tableQuestions
Function returns error message:
Invalid table/index name. Table/index names must be between 3 and 255 characters long, and may contain only the characters a-z, A-Z, 0-9, ‘_’, ‘-’, and ‘.’
Here is part of serverless.yml file:
custom:
stage: {opt:stage, self:provider.stage}
tableThroughputs:
prod: 5
default: 1
tableThroughput: {self:custom.tableThroughputs.{self:custom.stage}, self:custom.tableThroughputs.default}
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
dynamodb:
start:
port: 8000
inMemory: true
migrate: true
seed: true
noStart: true
seed:
test:
sources:
- table: {env:tableQuestions}
rawsources: [./offline/seeds/questions.json]
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: eu-central-1
environment:
tableQuestions:
Ref: QuestionsTable
tableReplays:
Ref: ReplaysTable
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- "Fn::GetAtt": [ QuestionsTable, Arn ]
- "Fn::GetAtt": [ ReplaysTable, Arn ]
And this is my dynamoDb Resource configuration:
Resources:
QuestionsTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: questionId
AttributeType: S
KeySchema:
- AttributeName: questionId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: ${self:custom.tableThroughput}
WriteCapacityUnits: ${self:custom.tableThroughput}
TableName: ${self:custom.stage}-questions
ReplaysTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
KeySchema:
- AttributeName: userId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: ${self:custom.tableThroughput}
WriteCapacityUnits: ${self:custom.tableThroughput}
TableName: ${self:custom.stage}-replays