AWS DynamoDB Metadata
This is not possible in DynamoDB like how you do it in S3 or SQS.
For DynamoDB, you simply need to add an attribute to the item when you put/update it, in this case I call the attribute metadata
:
Item={
'pk': 'jose.schneller@somewhere.com',
'sk': 'engineer',
'username': 'joses',
'first_name': 'Jose',
'last_name': 'Schneller',
'name': 'Jose Schneller',
'age': 27,
'address': {
'road': '12341 Fish Rd',
'city': 'Freeland',
'pcode': 98249,
'state': 'WA',
'country': 'USA'
},
'metadata':{
'sample-key': 'sample-value'
}
}
This means you get the items metadata each time you read the item.
How to connect AWS DynamoDb directly with dart
There is not an AWS SDK for this programming language. The only thing I can think of is to write code in your programming language that can invoke DynamoDB using Rest. There is an AWS documentation including an example:
DynamoDB Low-Level API
Unmarshalling DynamoDB MapString, AttributeValue to document-style JSON in AWS Java SDK 2.x
Per the comments above, there is currently no solution via the AWS SDK V2.
The following code works for my use-case:
private Object unwrapAttributeValue(AttributeValue av) {
if (av.isNULL() != null && av.isNULL())
return null;
if (av.getM() != null)
return unmarshall(av.getM());
if (av.getL() != null)
return av.getL().stream().map(this::unwrapAttributeValue)
.collect(Collectors.toList());
return Stream
.<Function<AttributeValue, Object>>of(AttributeValue::getS,
AttributeValue::getN, AttributeValue::getBOOL,
AttributeValue::getNS, AttributeValue::getSS,
AttributeValue::getB, AttributeValue::getBS)
.map(f -> f.apply(av)).filter(Objects::nonNull).findFirst()
.orElseThrow();
}
public Map<String, Object> unmarshall(Map<String, AttributeValue> in) {
Map<String, Object> out = new HashMap<>();
for (Entry<String, AttributeValue> e : in.entrySet()) {
Object uav = unwrapAttributeValue(e.getValue());
if (uav != null)
out.put(e.getKey(), uav);
}
return out;
}
The resulting Map<String, Object>
can then be fed to Jackson for further processing like normal json data.
AWS amplify/dynamo/appsync - how to sync data locally
How about using dynamodump
Download the data from AWS to your local machine:
python dynamodump.py -m backup -r REGION_NAME -s TABLE_NAME
Then import to Local DynamoDB:
dynamodump -m restore -r local -s SOURCE_TABLE_NAME -d LOCAL_TABLE_NAME --host localhost --port 8000
How to sent data triggered lambda function?
DynamoDB streams and Lambda can be used for the above use case.
1) Enable the DynamoDB streams on Dynamodb table to stream the data
2) Create a Lambda function to consume the stream and write to another DynamoDB table. The Lambda function can be created in many programming languages (API). You can use AWS SDK to create the lambda function.
Refer the below links for more details.
Full documentation
Enable Streams and Lambda - Cross region replication use case
Stream View Type:-
StreamViewType—specifies the information that will be written to the
stream whenever data in the table is modified:KEYS_ONLY—only the key attributes of the modified item.
NEW_IMAGE—the entire item, as it appears after it was modified.
OLD_IMAGE—the entire item, as it appeared before it was modified.
NEW_AND_OLD_IMAGES—both the new and the old images of the item.
Event Name:-
record.eventName
should have MODIFY when the data is updated in the DynamoDB table.
record.dynamodb
should have the values based on the Stream view type. If you have selected NEW_AND_OLD_IMAGES
, then it should have both old and new values.
eventName — (String) The type of data modification that was performed
on the DynamoDB table:INSERT - a new item was added to the table.
MODIFY - one or more of an existing item's attributes were modified.
REMOVE - the item was deleted from the table
Related Topics
Removing/Replacing Brackets from R String Using Gsub
How to Get The R Shiny Downloadhandler Filename to Work
Visualizing Distance Between Nodes According to Weights - with R
Existing Function to Combine Standard Deviations in R
Learning to Write Functions in R
Margins Between Plots in Grid.Arrange
Combining Date and Time into a Date Column for Plotting
Cannot Install Rgdal Package in R on Rhel6, Unable to Load Shared Object Rgdal.So
How to Fix Degree Symbol Not Showing Correctly in R on Linux/Fedora 31
Recursive Function Using Dplyr
How to Get All Possible Combinations of N Number of Data Set
R: How to Get Row and Column Names of The True Elements of a Matrix
How to Do Histograms of This Row-Column Table in R Ggplot
Function to Change Blanks to Na
Numerical Triple Integration in R