Repository navigation
feat(iot): add Action to put record to Kinesis Data stream - #18321
Conversation
skinny85
left a comment
There was a problem hiding this comment.
Very high quality contribution as always, @yamatatsu! A few minor comments.
| sql: iot.IotSql.fromStringAsVer20160323("SELECT * FROM 'device/+/data'"), | ||
| actions: [ | ||
| new actions.KinesisPutRecordAction(stream, { | ||
| partitionKey: '${timestamp()}', // optional property |
There was a problem hiding this comment.
Let's mention what's the default.
| * The partition key is usually composed of an expression (for example, ${topic()} or ${timestamp()}). | ||
| * For more information @see https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html#API_PutRecord_RequestParameters | ||
| * | ||
| * @default - None |
There was a problem hiding this comment.
Can you elaborate what does "None" mean here?
There was a problem hiding this comment.
Sorry, I tried to elaborate, but I could not😞.
Proberbly, IoT Core rule is fill default value (e.g. MQTT payload JSON string or hash of it) because PartitionKey is required in this API Reference.
But there is no description about it in IoT Core rule documentation and CloudFormation Documentation
There was a problem hiding this comment.
Did you try deploying an IoT app without this property filled?
Maybe this is simply a mistake in the CloudFormation resource, and this should actually be required?
There was a problem hiding this comment.
Did you try deploying an IoT app without this property filled?
Yes I tried and the deploying secceeded.
Again, I deployed, and I tested following for confirmation to be spreaded records to shards:
- Prepare
- Deploy Kinesis Stream with 10 shards
- Test1
- Prepare: Deploy IoT Core Kinesis Rule action with
${timestamp()}partitionKey - Send 10 same payloads
- Prepare: Deploy IoT Core Kinesis Rule action with
- Test2
- Prepare: Deploy IoT Core Kinesis Rule action with no partitionKey
- Send 10 same payloads
- Test3
- Prepare: Deploy IoT Core Kinesis Rule action with no partitionKey
- Send 10 payloads different each time
Results:
- Test1: Records was spreaded to each shards
- Test2: All records was put in same record
- Test3: All records was put in same record
The IoT Core may be filling in a static partitionKey if it is not specified.
But this is just a guess...
There was a problem hiding this comment.
OK. I think that's a good guess. Let's put that in the docs - it's certainly better than just "None", which gives you no clue what that actually means 🙂.
Thanks for the detailed testing!
There was a problem hiding this comment.
Thank you!
OK. If we beleave this guess, I think it is better that fill default value. Because in Kinesis Stream, it is pretty not helpful to not spread records by shards.
I found that ${newuuid} is suggested in Web Console.

This is the documentation of ${newuuid}.
I try to add default value ${newuuid}. But if you have any opinions, please feel free to tell me😉 .
There was a problem hiding this comment.
I don't hate it, but I'm a little concerned that the L2 won't have all of the capabilities of the underlying service (in this case, leaving the partition key as empty).
Does the Console allow you to leave it as empty, or do you have to provide a value?
There was a problem hiding this comment.
the L2 won't have all of the capabilities of the underlying service
It is so reasonable I think! So I will never mind to revert my commit that add default value.
Does the Console allow you to leave it as empty, or do you have to provide a value?
The Console requre PartitionKey, but CloudFormation does not. For keeping compatibility for CloudFormation, let's not add a default value, instead add a detailed description in JSDoc and Readme?
There was a problem hiding this comment.
Let's do this.
Make this field required, like it is in the console. But, allow specifying an empty string there (''). If an empty string is passed, then we will actually pass undefined to the underlying CloudFormation resource for that field. Of course, we will need to cover that in our documentation.
This way, we will be close to the Console experience, while covering the entire service capabilities.
What do you think about this @yamatatsu?
There was a problem hiding this comment.
It's good I think! 👍🏻
OK, I will do it!
| errorAction: new actions.CloudWatchLogsAction( | ||
| new logs.LogGroup(this, 'Logs', { removalPolicy: cdk.RemovalPolicy.DESTROY }), | ||
| ), |
There was a problem hiding this comment.
Do we need this in this test?
There was a problem hiding this comment.
Oh it is not needed, but for confirmation that it is work on aws 😅 .
I'll remove it!
…nesis-put-record-action.ts Co-authored-by: Adam Ruka <[email protected]>
Pull request has been modified.
…on` (#18356) By #18321 (comment) BREAKING CHANGE: the class `FirehoseStreamAction` has been renamed to `FirehosePutRecordAction` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
skinny85
left a comment
There was a problem hiding this comment.
Looks great @yamatatsu, thanks for your patience in seeing this one through to the end!
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…on` (aws#18356) By aws#18321 (comment) BREAKING CHANGE: the class `FirehoseStreamAction` has been renamed to `FirehosePutRecordAction` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Fixes aws#17703 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…on` (aws#18356) By aws#18321 (comment) BREAKING CHANGE: the class `FirehoseStreamAction` has been renamed to `FirehosePutRecordAction` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Fixes aws#17703 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Fixes #17703
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license