title: AWS SAM CLI cannot access Dynamo DB when function is invoked locally
body: <p>I am building an AWS lambda with <a href="https://github.com/awslabs/aws-sam-cli" rel="noreferrer">aws-sam-cli</a>. In the function, I want to access a certain DynamoDB table.
  My issue is that the function comes back with this error when I invoke it locally with the <code>sam local invoke</code> command: <code>ResourceNotFoundException: Requested resource not found</code></p>
  <pre class="lang-js prettyprint-override"><code>const axios = require('axios')
  const AWS = require('aws-sdk')
  AWS.config.update({region: &lt;MY REGION&gt;})
  const dynamo = new AWS.DynamoDB.DocumentClient()
  
  exports.handler = async (event) =&gt; {
    const scanParams = {
      TableName: 'example-table'
    }
    const scanResult = await dynamo.scan(scanParams).promise().catch((error) =&gt; {
      console.log(`Scan error: ${error}`)
      // =&gt; Scan error: ResourceNotFoundException: Requested resource not found
    })
  
    console.log(scanResult)
  }
  </code></pre>
  <p>However, if I actually <code>sam deploy</code> it to AWS and test it in the actual Lambda console, it logs the table info correctly.</p>
  <pre><code>{
    Items: &lt;TABLE ITEMS&gt;,
    Count: 1,
    ScannedCount: 1
  }
  </code></pre>
  <p>Is this expected behavior? Or is there some additional configuration I need to do for it to work locally? My <code>template.yaml</code> looks like this:</p>
  <pre class="lang-yaml prettyprint-override"><code>AWSTemplateFormatVersion: '2010-09-09'
  Transform: AWS::Serverless-2016-10-31
  Description: 'Example SAM stack'
  Resources:
    ExampleFunction:
      Type: AWS::Serverless::Function
      Properties:
        Handler: index.handler
        Runtime: nodejs12.x
        Policies:
        - DynamoDBCrudPolicy:
            TableName: 'example-table'
  </code></pre>