title: yaml SAM local with dynamo db
body: <p>I'm trying to create a set of lambda functions that depend on DynamoDB. I've written a valid SAM template like this:</p>
  
  <pre><code>---
  AWSTemplateFormatVersion: 2010-09-09
  
  Transform: AWS::Serverless-2016-10-31
  
  Resources:
    Get:
      Type: AWS::Serverless::Function
      Properties:
        Handler: ./lambdas/get/main
        Runtime: go1.x
        Events:
          PostEvent:
            Type: Api
            Properties:
              Path: /
              Method: get
    Portfolios:
      Type: AWS::DynamoDB::Table
      TableName: "entities"
      Properties: 
        AttributeDefinitions: 
          - 
            AttributeName: "Id"
            AttributeType: "S"
          - 
            AttributeName: "Name"
            AttributeType: "S"
        KeySchema: 
          - 
            AttributeName: "Id"
            KeyType: "HASH"
          - 
            AttributeName: "Name"
            KeyType: "RANGE"
        ProvisionedThroughput: 
          ReadCapacityUnits: 5
          WriteCapacityUnits: 5
        Tags:
          - Key: foo
            Value: bar         
  
  
  Outputs:
    Endpoint:
      Value:  !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
  </code></pre>
  
  <p>but when I try to execute any of the lambdas they timeout when trying to call <code>putItem</code>. What do I need to do to ensure that my lambdas can talk to my local dynamodb?</p>
  
  <pre><code>    sess := session.Must(session.NewSessionWithOptions(session.Options{
          SharedConfigState: session.SharedConfigEnable,
      }))
      endpoint := "localhost:3000"
      db := dynamodb.New(sess, &amp;aws.Config{
          Endpoint: &amp;endpoint,
      })
      entity := &amp;models.Entities{}
      json.Unmarshal([]byte(event.Body), portfolio)
  
      av, err := dynamodbattribute.MarshalMap(entity)
      if err != nil {
          fmt.Println("Got error marshalling:")
          fmt.Println(err.Error())
          os.Exit(1)
      }
  
      input := &amp;dynamodb.PutItemInput{
          Item:      av,
          TableName: aws.String("entities"),
      }
  
      _, err = db.PutItem(input) // Times out here
      if err != nil {
          fmt.Println("Got error calling PutItem:")
          fmt.Println(err.Error())
          return events.APIGatewayProxyResponse{StatusCode: 500}, nil
      }
  </code></pre>
  
  <p>How can I make sure that my table is even being created correctly?</p>