Connecting DynamoDb inside Lambda

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 ?

1 Like

@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

Thank you for the pointer @flomotlik!

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