How to store timestamp message from aws iot button to DynamoDB - amazon-web-services

I am sending message from my AWS iot button and storing it to the DynamoDB. My partition key is "SerialNumber" and the sort key is "ClickType". The message is stored according to the key. But it is overwriting the previous data if there is already same ClickType. I do not want to overwrite my previous data and also want to see the time of the sending message. Can somebody provide me any suggestion or any link about how to do it?

On your AWS IoT rule for getting the message to lambda has the timestamp when the message was captured by Aws Iot rules engine. You could catch that on your rule and store on your Dynamodb table.
To do that, you have to use the timestamp() function from AWs IoT

Related

How to send email after a new DynamoDB entry without Lambda function

I would normally handle the task of sending an email after a new DynamoDB entry with Lambda and SES but I'm required to not use Lambda for it.
There's a 'Contact us' section in the website and the email needs to be sent every time a new entry is made. We use API Gateway to post the data to DyanmoDB
Is there a way to carry this out without Lambda?
It's not possible without writing code. Furthermore you may probably want to tailor each email to make it more personal to the user, thus Lambda is a must.
You could design something using EventBridge Pipes which can trigger when a new user is added and can have SNS as a destination which could trigger an email. But that email may not be customizable nor may it send to people not subscribed to the topic
DynamoDB triggers Lambda functions by feeding the records of a DynamoDB Stream to the Lambda function. That is by far the easiest way to process updates to a DynamoDB table, but you can also write other code that processes a DynamoDB outside of Lambda: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html
If you really want to do it without lambda you can use the following pattern and glue some AWS services together.
You can consume the dynamodb stream with eventbridge pipes and send it to a stepfunction and there you use the sdk integration to call SES. Instead of stepfunction you can directly use SNS for simpler setups.
You will not have to use lambda for this setup. Further you can transform your message either in the pipe or in the stepfunction.
Be aware that eventbirdge pipes has currently no AWS CDK L2 construct which might make it harder to configure if you use CDK.

How to get messageId in aws workmail/ Iterate through workmail messages

I want to list all the messages in aws workmail and analyze them.
The only function aws offers is
workmail = boto3.client('workmailmessageflow', region_name=os.environ["AWS_REGION"]
msg_id = event['messageId']
Here messageId can be retrieved from automation rule in aws workmail.
This messageId persists and can be called days later, so there is a long term association between IDs and messages, but the only way to get this ID is upon workmail automation rule that triggers lambda. Is there any other way to figure out the messageIds or iterate through the workmail mailbox?
The Amazon WorkMail Message Flow API can be used to access email messages that are in transit only. To programmatically access messages that are already delivered to a user’s mailbox, use one of the other protocols supported by Amazon WorkMail, such as IMAP or Exchange Web Services (EWS).
Source: Retrieving message content with AWS Lambda

AWS IoT DynamoDB Create Rule

I am trying to setup a AWS IoT rule to send the IoT incoming data into the DynamoDB, I think everything has been setup correctly such as the policies.
What I do not understand is what information is needed in the rule, to send the incoming data to the database?
You need to enter the mqtt topic name in your iot query
select * from topic_name;
Also here is the short guide about how you can get data from AWS iot to dynamo db for quick reference
Iot Rule to insert data into dynamo db

AWS - Securing Content From SNS To Lambda

I'm hoping to find out if there is any way to encrypt message content from SNS to Lambda? My use case is that I am Publishing JSON content using AWS SDK to a SNS Topic which contains a Subscription using the Lambda protocol to send the content to a Lambda function.
I haven't been able to find any real detail regarding how the Lambda protocol works but I believe it is not encrypting the message content.
I know that I can use a KMS key or whatever to encrypt the content prior to Publishing to the topic but does anyone know of a way to set up SNS or the Lambda subscription to get encryption happening automatically?
Thanks!
As asdfg mentioned, SNS payloads are not automatically encrypted (although they are signed)
You can encrypt the SNS message body yourself if you wish.

how to make a http post request on server side after data insert in aws?

I am trying to understand AWS data sync on xamarin. they have a nice SDK to use in xamarin.forms. I am using onesignal notifications instead of aws notifications.
my question is I want to fire a notification after a data insert or sync. Onesignal has an api working with http post.
So how do I make post to onesignal endpoint when
user data is syncronized with aws cognito
a new shared data is inserted into DynamoDB
Of course I can do that on clientside but this is not a good practice. I would like to do that on the server side.
For #1, you can use Cognito events, which execute a Lambda function, whenever the data is synchronized by the user. In this Lambda function you can fire the notification.
For #2, I do not see how that is related to Cognito Sync, as the data is stored in datasets not DynamoDB. If you are talking idependently about data being inserted into DynamoDB and getting notified about that, then again DynamoDB has nice integration with AWS Lambda to send notifications on table updates.