# Connecting DynamoDb inside Lambda

**URL:** <https://forum.serverless.com/t/connecting-dynamodb-inside-lambda/320>\
**Category:** Serverless Framework\
**Created:** [September 18, 2016, 3:51am UTC](https://forum.serverless.com/t/connecting-dynamodb-inside-lambda/320 "2016-09-18T03:51:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mnichols](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/mnichols/32/139_2.png) [@mnichols](https://forum.serverless.com/u/mnichols)\
**Post date:** [September 18, 2016, 3:51am UTC](https://forum.serverless.com/t/connecting-dynamodb-inside-lambda/320/1 "2016-09-18T03:51:16Z")

</div>

I’ve looked around for some examples of connecting to DynamoDb inside my simple Lambda function but had some difficulty putting it together.  
When I followed some samples here I was consistently getting told my `hello` lambda function resource wasnt found.

So I pulled down the most recent master (9/17/2016) and, thanks to running `serverless deploy --noDeploy`, I figured out the name of the lambda name the resource config expects, resulting in:

```
service: my-api 

provider:
  name: aws
  runtime: nodejs4.3
  iamRoleStatements:
    - Effect: "Allow"
      Resource: "*"
      Action:
        - "dynamodb:*"
functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: users
          method: GET

resources:
  Resources:
    mapping:
      Type: AWS::Lambda::EventSourceMapping
      Properties:
        BatchSize: 100
        EventSourceArn: <dynamodb-stream-arn>
        FunctionName:
          Fn::GetAtt:
            - "HelloLambdaFunction"
            - "Arn"
        StartingPosition: "TRIM_HORIZON"

```

This actually worked and I could talk to my DDB inside my lambda when invoked but does one typically reference the name of the Lambda function this way : {FunctionNameAsPascal}LambdaFunction ?

---

<div class="post-metadata">

**Author:** ![flomotlik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/flomotlik/32/3_2.png) [@flomotlik](https://forum.serverless.com/u/flomotlik)\
**Post date:** [September 19, 2016, 5:40am UTC](https://forum.serverless.com/t/connecting-dynamodb-inside-lambda/320/2 "2016-09-19T05:40:48Z")

</div>

@mnichols Yup, we switched that recently from just the function name for consistency. You can read more about it here: [https://github.com/serverless/serverless/blob/master/docs/02-providers/aws/04-resource-names-reference.md](https://github.com/serverless/serverless/blob/master/docs/02-providers/aws/04-resource-names-reference.md)

---

<div class="post-metadata">

**Author:** ![mnichols](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/mnichols/32/139_2.png) [@mnichols](https://forum.serverless.com/u/mnichols)\
**Post date:** [September 20, 2016, 12:26am UTC](https://forum.serverless.com/t/connecting-dynamodb-inside-lambda/320/3 "2016-09-20T00:26:48Z")

</div>

Thank you for the pointer @flomotlik!

---

<div class="post-metadata">

**Author:** ![bennybauer](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bennybauer/32/306_2.png) [@bennybauer](https://forum.serverless.com/u/bennybauer)\
**Post date:** [November 25, 2016, 6:26am UTC](https://forum.serverless.com/t/connecting-dynamodb-inside-lambda/320/4 "2016-11-25T06:26:02Z")

</div>

An updated link: [https://serverless.com/framework/docs/providers/aws/guide/resources#aws-cloudformation-resource-reference](https://serverless.com/framework/docs/providers/aws/guide/resources#aws-cloudformation-resource-reference)
