title: DynamoDB get item TypeScript hell
body: <p>Can anyone explain how to use <code>GetItemInput</code> type when calling <code>DocumentClient.get</code> ?</p>
  
  <p>If I pass in an object of any type <code>get</code> works but if I try and strongly type the params object I get this error:</p>
  
  <pre><code>ValidationException: The provided key element does not match the schema
  </code></pre>
  
  <p>Here is my lambda function code where I pass the params as type <code>any</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>export const get: Handler = async (event: APIGatewayProxyEvent): Promise&lt;APIGatewayProxyResult&gt; =&gt; {
  
    console.log(event.pathParameters)
    if (!event.pathParameters) {
      throw Error("no path params")
    }
  
    const params: any = {
      Key: {
        id: event.pathParameters.id
      },
      TableName: table
    }
  
    console.log(params)
    try {
      const result: any = await dynamoDb.get(params).promise()
      return {
        body: JSON.stringify(result.Item),
        statusCode: result.$response.httpResponse.statusCode
      }
  
    } catch (error) {
      console.log(error)
      return {
        body: JSON.stringify({
          message: `Failed to get project with id: ${event.pathParameters!.id}`
        }),
        statusCode: 500
      }
    }
  }
  </code></pre>
  
  <p>And here is my attempt to get it to work with type <code>GetItemInput</code></p>
  
  <pre class="lang-js prettyprint-override"><code>export const get: Handler = async (event: APIGatewayProxyEvent): Promise&lt;APIGatewayProxyResult&gt; =&gt; {
  
    console.log(event.pathParameters)
    if (!event.pathParameters) {
      throw Error("no path params")
    }
  
    const params: GetItemInput = {
      Key: {
        "id": { S: event.pathParameters.id }
      },
      TableName: table
    }
  
    console.log(params)
    try {
      const result: any = await dynamoDb.get(params).promise()
      return {
        body: JSON.stringify(result.Item),
        statusCode: result.$response.httpResponse.statusCode
      }
  
    } catch (error) {
      console.log(error)
      return {
        body: JSON.stringify({
          message: `Failed to get project with id: ${event.pathParameters!.id}`
        }),
        statusCode: 500
      }
    }
  }
  </code></pre>
  
  <p>If I leave the <code>Key</code> as before ala:</p>
  
  <pre class="lang-js prettyprint-override"><code>const params: GetItemInput = {
    Key: {
      id: event.pathParameters.id
    },
    TableName: table
  }
  </code></pre>
  
  <p>Unsurprisingly I get a type error. But can't fathom how I can form my <code>Key</code> such that I dont get the <code>ValidationException</code>. </p>
  
  <p>Note the <code>id</code> field is of type <code>String</code> in the <code>DynamoDB</code>.</p>