Posts

Showing posts with the label AWS DynamoDB

Update dynamodb items programatically

Today, I wanted to update all dynamodb items and couldn't find a handy example in AWS documentation.  Below is a handy script that I created to update all the dynamodb table rows with current time stamp using python from __future__ import print_function # Python 2/3 compatibility import boto3 import json import decimal from boto3.dynamodb.conditions import Key, Attr import datetime, time row = 0 table_name = 'table' dynamodb = boto3.resource('dynamodb') table = dynamodb.Table(table_name) # Helper class to convert a DynamoDB item to JSON. class DecimalEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, decimal.Decimal): if o % 1 > 0: return float(o) else: return int(o) return super(DecimalEncoder, self).default(o) def updateItem(item): global row response = table.update_item( Key=item, UpdateExpression='SET #s = :updated', Expre...

Leveraging AWS Elasticsearch

Image
Recently I had an use case where I had to expose AWS DynamoDB search as an API.  I could have gone with the common approach of using AWS API Gateway integrating with AWS Lambda which runs the search against the  AWS DynamoDB  as   however this approach wouldn't be scalable under load.  Alternative to the above solution would be to use AWS  Elasticsearch Service .  ElasticSearch  is an open source product from Elastic that’s is designed to help us search in a way that is highly available and abstracted from datastore.  AWS  Elasticsearch  Service  is AWS hosted ElasticSearch that takes care of set-up and management of the back end server and provides us with an endpoint that we can get developing with.  AWS Elasticsearch Service makes it easy to deploy, secure, operate, and scale Elasticsearch for log analytics, full text search, application monitoring, and more.  AWS  Elasticsearch Servic...