Amazon-Web-Services – AWS API Gateway stores JSON to DynamoDB

I have a problem when trying to use the API gateway as a proxy for DynamoDB.

Basically, if I know the structure of the data to be stored , It will be effective, but regardless of the payload structure, I cannot make it dynamic.

There are many websites explaining how to use the API gateway as a proxy for DynamoDB.
I found no explanation How to store JSON objects.

Basically I send this JSON to my API endpoint:

{
"entryId":"abc ",
"data":{
"key1":"123",
"key2":123
}
}

If I use the following template for mapping, the data will be correctly placed in my database

{ 
"TableName": "Events",
"Item ": {
"entryId": {
"S": "abc"
},
"data": {
"M": {
"key1": {
"S": "123"
},
"key2": {
"N": "123"
}
}
}
}
}

However, I don’t know the structure of “data”, so I want the mapping to be dynamic, or even better, I think Avoid any mapping.

I managed to make it dynamic, but all my entries are now of type String:

"data": {"M" : {
#foreach($key in $input.path('$.data').keySet())
"$key": {"S": "$input.path('$.data').get($key)"}#if($foreach.hasNext),#end
#end }
}

Can the type be obtained dynamically?
I'm not sure how the API gateway mapping works.

Thank you for your help.

Loeb

When inserting Dynamodb, you won’t avoid some kind of mapping. I recommend using Lambda functions instead of service proxies to provide more control when mapping data to the Dynamodb schema And flexibility.

I have a problem when trying to use the API gateway as a proxy for DynamoDB.

Basically, if I know to store The structure of the data, it will be very effective, but regardless of the payload structure, I cannot make it dynamic.

There are many websites explaining how to use the API gateway as a proxy for DynamoDB.
I found no explanation on how to store JSON objects.

Basically I send this JSON to my API endpoint:

{
"entryId ":"abc",
"data":{
"key1":"123",
"key2":123
}
}

If I use the following template for mapping, the data will be correctly placed in my database

{ 
"TableName": "Events",
"Item": {
"entryId": {
"S": "abc"
},
"data": {
"M": {
"key1": {
"S": "123"
},
"key2": {
"N": "123"
}
}
}
}
}

However, I don’t know the structure of the "data", so I want the mapping to be dynamic. To better, I want to avoid any mapping.

I managed to make it dynamic, but all my entries are now of type String:

"data ": {"M": {
#foreach($key in $input.path('$.data').keySet())
"$key": {"S": "$ input.path('$.data').get($key)"}#if($foreach.hasNext),#end
#end }
}

Is it possible Dynamic acquisition type?
I'm not sure how the API gateway mapping works.

Thank you for your help.

Loeb

When inserting Dynamodb, you will not avoid some kind of mapping. I recommend using Lambda functions instead of service proxies to provide more control and flexibility when mapping data to the Dynamodb architecture.

< /p>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1872 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.