def update_metric_timestamp_ddb()

in CWMetricsToOpenSearch/handler.py [0:0]


def update_metric_timestamp_ddb(domain_name, region, ts):
    ddb = boto3.client('dynamodb')
    try:
        existing = get_last_timestamp_ddb(domain_name, region)
        if not existing or (existing and existing < ts):
            ddb.update_item(
                TableName=DDB_TABLE,
                Key={ 'domain': {'S': domain_name},
                      'region': {'S': region}},
                AttributeUpdates={'Timestamp': { 'Value': {'S': ts.isoformat()}}}
            )
    except Exception as e:
        print('Exception putting timestamp for "{}:{}"'.format(domain_name, region))
        print(e)