Reputation: 6799
I have an app that takes in a gateway url and makes POST request directly to the URL with some data. I would like to know if there is a specific url that is used to make POST request to DynamoDB.
I contacted AWS support and they linked me to this article but I am still confused about how to do it.
More details on the app and making POST request through it.
Upvotes: 0
Views: 2637
Reputation: 55720
You will most likely not be able to have the Ruuvi gateway post data directly to your DynamoDB table.
While it is absolutely possible to have any client that can make HTTP requests, interface with DynamoDB, one requirement to making successful requests is for the requests to contain a valid AWS SigV4 signature. This signature is specific to each request and must be generated based on the contents of the request, including headers, and must also be time correlated with the request.
To read more about how to generate SigV4 signatures yourself, here is some information from the AWS docs: https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
There is also a walk through that you can follow to understand exactly what is entailed: https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
So, unless the Ruuvi gateway has the ability to generate SigV4 signatures on your behalf, you will need some intermediate tech to receive the data and post to Dynamo.
For example, you could set up an AWS API Gateway backed by a Lambda function to receive the data, do any transformation you want, and then post to DynamoDB. Alternatively, you could spin up a tiny EC2 instance, deploy an Nginx reverse proxy and feed the requests to some stock of your choice (Node,Python,PHP,Java,.NET) and process..
Something you will have to consider is how you authenticate these requests from the Ruuvi gateway so you don't get junk into your system. Api gateway has some nice features, like throttling rules and even support for an authorization process but again, not sure how the Ruuvi gateway would integrate with anything that requires auth keys etc. Maybe they have a way to at least pass some sort of secret in a header and as long as you expose your ingestion endpoint as an SSL endpoint, you'll get some protection. YMMV
Upvotes: 2
Reputation: 2777
The article you posted has the information you need I believe
Request Format The DynamoDB low-level API accepts HTTP(S) POST requests as input. The AWS SDKs construct these requests for you.
Suppose that you have a table named Pets, with a key schema consisting of AnimalType (partition key) and Name (sort key). Both of these attributes are of type string. To retrieve an item from Pets, the AWS SDK constructs the following request.
POST / HTTP/1.1
Host: dynamodb.<region>.<domain>;
Accept-Encoding: identity
Content-Length: <PayloadSizeBytes>
User-Agent: <UserAgentString>
Content-Type: application/x-amz-json-1.0
Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=<Headers>, Signature=<Signature>
X-Amz-Date: <Date>
X-Amz-Target: DynamoDB_20120810.GetItem
{
"TableName": "Pets",
"Key": {
"AnimalType": {"S": "Dog"},
"Name": {"S": "Fido"}
}
}
Upvotes: 0