# Missing required key 'Tablename' in params Error?!

**URL:** <https://forum.serverless.com/t/missing-required-key-tablename-in-params-error/4492>\
**Category:** Serverless Framework\
**Tags:** lambda\
**Created:** [May 14, 2018, 6:01am UTC](https://forum.serverless.com/t/missing-required-key-tablename-in-params-error/4492 "2018-05-14T06:01:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelinwu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/kelinwu/32/1943_2.png) [@kelinwu](https://forum.serverless.com/u/kelinwu)\
**Post date:** [May 14, 2018, 6:01am UTC](https://forum.serverless.com/t/missing-required-key-tablename-in-params-error/4492/1 "2018-05-14T06:01:35Z")

</div>

Hi Forks

I deployed a lambda function(functionName) to aws, the function saves data I fetched from a API to DynamoDB.

I can invoke the function: sls invoke local -f functionName and the data save to the db with no problem.

however, when I try to call the deployed function. I am getting this error:  
Error saving data to DynamoDB: {“message”:“Missing required key ‘TableName’ in params”,“code”:“MissingRequiredParameter”,“time”:“2018-05-14T05:49:57.600Z”}

please note: the TableName I stored in serverless.yml file:  
environment:  
DYNAMODB\_TABLE: myTable

Yml-provider:  
provider:  
name: aws  
runtime: nodejs6.10  
region: us-east-1  
stage: dev  
profile: serverless-admin  
environment:  
DYNAMODB\_TABLE: myTable  
iamRoleStatements:  
- Effect: Allow  
Action:  
- “lambda:InvokeFunction”  
Resource: “\*”  
- Effect: Allow  
Action:  
- dynamodb:Query  
- dynamodb:Scan  
- dynamodb:GetItem  
- dynamodb:PutItem  
- dynamodb:UpdateItem  
- dynamodb:DeleteItem  
Resource: “arn:aws:dynamodb:{opt:region, self:provider.region}:\*:table/{self:provider.environment.DYNAMODB\_TABLE}”

it should deployed to aws

what is missing from deploy? store myTable in serverless.yml isn’t enough when deploy to aws? but, it did run well when invoke the function at local as you see.

thanks

---

<div class="post-metadata">

**Author:** ![rupakg](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rupakg/32/900_2.png) [@rupakg](https://forum.serverless.com/u/rupakg)\
**Post date:** [May 14, 2018, 2:26pm UTC](https://forum.serverless.com/t/missing-required-key-tablename-in-params-error/4492/2 "2018-05-14T14:26:49Z")

</div>

Can you show me the yaml from the `Resources` section where you are creating the DynamoDB table? The environment var. for the table name should be used there.

---

<div class="post-metadata">

**Author:** ![kelinwu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/kelinwu/32/1943_2.png) [@kelinwu](https://forum.serverless.com/u/kelinwu)\
**Post date:** [May 14, 2018, 8:04pm UTC](https://forum.serverless.com/t/missing-required-key-tablename-in-params-error/4492/3 "2018-05-14T20:04:38Z")

</div>

I updated the post, yml provider has been added for ref. thx!

---

<div class="post-metadata">

**Author:** ![rupakg](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rupakg/32/900_2.png) [@rupakg](https://forum.serverless.com/u/rupakg)\
**Post date:** [May 14, 2018, 8:29pm UTC](https://forum.serverless.com/t/missing-required-key-tablename-in-params-error/4492/4 "2018-05-14T20:29:12Z")

</div>

The yaml section is not formatted correctly so it is very hard to read. Here is an example how it should be :

```auto
...

provider:
  ...
  environment:
    DYNAMODB_TABLE: myTable

...

resources:
  Resources:
    MyDynamoDBTable:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        AttributeDefinitions:
          -
            AttributeName: id
            AttributeType: S
        KeySchema:
          -
            AttributeName: id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        TableName: myTable

```

This configuration assumes that the Serverless Framework will create and manage the DynamoDB table for you. On `deploy` it will create the DynamoDB table, and on `remove` it will destroy it.

If you are connecting to an existing table you will just need to use the SDK and make dynamo calls from your code. No need to add the DynamoDB config in the `Resources` section. You will still need the `IAMRoleStatements` to give access to perform operations on the table.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![kelinwu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/kelinwu/32/1943_2.png) [@kelinwu](https://forum.serverless.com/u/kelinwu)\
**Post date:** [May 15, 2018, 1:11pm UTC](https://forum.serverless.com/t/missing-required-key-tablename-in-params-error/4492/5 "2018-05-15T13:11:37Z")

</div>

thanks for the reply.

in my case: I want to call the deployed function(my-serverless-deployed-function) that saves data to dynamodb.

when I “invoke local” the function, it works well,

however, when I deployed the function to the aws, then call it with the function name, It no longer saves data to db anymore, with no error popup.

**here is my code:**

const AWS = require(“aws-sdk”);

function deployScraper() {  
const lambda = new AWS.Lambda({  
region: “us-east-1”  
})

```
const params = {
    FunctionName: "my-serverless-deployed-function",
    InvocationType: "RequestResponse",
    LogType: "Tail"
}

return lambda.invoke(params, function(error, data) {
        console.log("lambda.invoked")
        console.log(data)
        return JSON.stringify(data);
})

```

}

**Here is the output of the call:**

lambda.invoked  
{ StatusCode: 200,  
LogResult: ‘U1RBUlQgUmVxdWVzdElkOiA3ZjAxMTA0Ni01ODNmLTExZTgtODZiNy02YmFjZjIwYWFmYjggVmVyc2lvbjogJExBVEVTVAoyMDE4LTA1LTE1VDEyOjU3OjE5Ljg3M1oJN2YwMTEwNDYtNTgzZi0xMWU4LTg2YjctNmJhY2YyMGFhZmI4CUVycm9yIHNhdmluZyBkYXRhIHRvIER5bmFtb0RCOiB7Im1lc3NhZ2UiOiJNaXNzaW5nIHJlcXVpcmVkIGtleSAnVGFibGVOYW1lJyBpbiBwYXJhbXMiLCJjb2RlIjoiTWlzc2luZ1JlcXVpcmVkUGFyYW1ldGVyIiwidGltZSI6IjIwMTgtMDUtMTVUMTI6NTc6MTkuODczWiJ9CjIwMTgtMDUtMTVUMTI6NTc6MTkuODc1Wgk3ZjAxMTA0Ni01ODNmLTExZTgtODZiNy02YmFjZjIwYWFmYjgJKG5vZGU6MSkgVW5oYW5kbGVkUHJvbWlzZVJlamVjdGlvbldhcm5pbmc6IFVuaGFuZGxlZCBwcm9taXNlIHJlamVjdGlvbiAocmVqZWN0aW9uIGlkOiAxKTogRXJyb3Igc2F3aW5nIGRhdGEgdG8gRHluYW1vREI6IHsibWVzc2FnZSI6Ik1pc3NpbmcgcmVxdWlyZWQga2V5ICdUYWJsZU5hbWUnIGluIHBhcmFtcyIsImNvZGUiOiJNaXNzaW5nUmVxdWlyZWRQYXJhbWV0ZXIiLCJ0aW1lIjoiMjAxOC0wNS0xNVQxMjo1NzoxOS44NzNaIn0KRU5EIFJlcXVlc3RJZDogN2YwMTEwNDYtNTgzZi0xMWU4LTg2YjctNmJhY2YyMGFhZmI4ClJFUE9SVCBSZXF1ZXN0SWQ6IDdmMDExMDQ2LTU4M2YtMTFlOC04NmI3LTZiYWNmMjBhYWZiOAlEdXJhdGlvbjogMTMzOC42NCBtcwlCaWxsZWQgRHVyYXRpb246IDE0MDAgbXMgCU1lbW9yeSBTaXplOiAxMDI0IE1CCU1heCBNZW1vcnkgVXNlZDogNzEgTUIJCg==’,  
ExecutedVersion: ‘$LATEST’,  
Payload: ‘{“statusCode”:200,“body”:"{\“message\”:\“completed\”}"}’ }

**here is yaml serverless.privder**

```
provider:
  name: aws
  runtime: nodejs6.10
  region: us-east-1
  stage: dev
  profile: serverless-admin
  environment:
    DYNAMODB_TABLE: myTable
  iamRoleStatements:
    - Effect: Allow
      Action:
        - "lambda:InvokeFunction"
      Resource: "*" 
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
      Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
```

---

<div class="post-metadata">

**Author:** ![kelinwu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/kelinwu/32/1943_2.png) [@kelinwu](https://forum.serverless.com/u/kelinwu)\
**Post date:** [May 16, 2018, 6:37pm UTC](https://forum.serverless.com/t/missing-required-key-tablename-in-params-error/4492/6 "2018-05-16T18:37:49Z")

</div>

Hello folks,

issue has been fixed myself!

the error code from AWS log isn’t reflect the actual error. I was confused about the error and check many times try to have the missing table name fixed, however, the above script are correct. aws report error, since I have some bugs in my node script. nothing to do with yaml and deplyed handler function.

Thanks!

---

<div class="post-metadata">

**Author:** ![rupakg](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rupakg/32/900_2.png) [@rupakg](https://forum.serverless.com/u/rupakg)\
**Post date:** [May 21, 2018, 4:10pm UTC](https://forum.serverless.com/t/missing-required-key-tablename-in-params-error/4492/7 "2018-05-21T16:10:35Z")

</div>

Good to hear it solved your issue.
