title: Querying DynamoDB without PrimaryKey with Lambda
body: <p>I want to query my DynamoDB with a lambda function running python.</p>
  <p>DynamoDB Table (Name: Testing-Table):</p>
  <ul>
  <li><strong>user_id</strong> (String) <strong>PrimaryKey</strong></li>
  <li>status (String)</li>
  <li>destination (String)</li>
  </ul>
  <p>I want to query the table as it is in my code. I want the lambda function to return me all the <strong>user_id</strong>'s that has their <strong>status</strong> attribute with <strong>active</strong>.</p>
  <pre><code>table = dynamodb.Table('Testing-Table')
  def lambda_handler(event, context):
  
  response = table.query (
      KeyConditionExpression=Key('status').eq('active')
  )
  
  for i in response['Items']:
      print(i['user_id'],&quot;:&quot;,i['status'])
  
  #return 'listing results'
  </code></pre>
  <p>I've also added a new index:
  <img src="https://i.stack.imgur.com/cNRmp.png" alt="Indexes" /></p>
  <p>I tried creating a table with <strong>status</strong> as primary key, and my code worked... but primarykey's must be unique, so when I try to create a new item in my table, I cant set <strong>status</strong> as active again.</p>
  <p>If necessary, I will add more information to the question. I would thank for a little help.</p>
  <p>--<strong>Edit</strong>--
  My code works <em>only</em> if <strong>status</strong> is the PrimaryKey of my table.</p>
  <p><em>My question is</em>: Can I query my DynamoDB table using <strong>status</strong> PartitionKey instead of the PrimaryKey <strong>used_id</strong>? And most important...How is it done?</p>