title: run dynamodb trigger for specific event types
body: <p>Everytime there's a change in the dynamo table, it runs a trigger which then runs a lambda function. For now, the trigger runs whenever i add or delete a file both. Instead, I only want to run the trigger if the event type is INSERT. How can I achieve this?</p>
  <pre><code>resource &quot;aws_dynamodb_table&quot; &quot;filenames&quot; {
    name           = local.dynamodb_table_filenames
    billing_mode   = &quot;PROVISIONED&quot;
    read_capacity  = 1000
    write_capacity = 1000
    hash_key       = &quot;filename&quot;
    stream_enabled = true
    stream_view_type = &quot;NEW_IMAGE&quot;
  
    #range_key      = &quot;&quot;
  
    attribute {
      name = &quot;filename&quot;
      type = &quot;S&quot;
    }
  
    tags = var.tags
  }
  
  resource &quot;aws_lambda_event_source_mapping&quot; &quot;allow_dynamodb_table_to_trigger_lambda&quot; {
    event_source_arn  = aws_dynamodb_table.filenames.stream_arn
    function_name     = aws_lambda_function.trigger_stepfunction_lambda.arn
    starting_position = &quot;LATEST&quot;
  }
  
  </code></pre>