question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(aws-kinesis): fails to deploy on-demand stream

See original GitHub issue

What is the problem?

Error from CloudFormation when using Kinesis Data Streams in on-demand mode with shardCount specified.

ShardCount is not expected when StreamMode=ON_DEMAND

Reproduction Steps

Create a new stream with a streamMode set.

new Stream(this, 'KinesisStream', {
    streamName: 'my-ingest-stream',
    shardCount: 1, // optional
    streamMode: StreamMode.ON_DEMAND,
});

What did you expect to happen?

Deploy a stream in on-demand mode, possibly informed by the shardCount for an initial scaling hint.

What actually happened?

Error from CloudFormation

ShardCount is not expected when StreamMode=ON_DEMAND

CDK CLI Version

1.137.0 (build bfbdf64)

Framework Version

1.137.0

Node.js Version

14.17.3

OS

MacOS

Language

Typescript

Language Version

4.5.2

Other information

CloudFormation’s documentation does not inform the user that setting the StreamMode to ON_DEMNAD is an error. Can we raise a bug with the right team to get the documentation improved?

Removing the shardCount field from the CDK user code does not fix the error because internally, CDK always sets the shardCount to 1 if it is left undefined by the user.

The solution in CDK is to remove shardCount from the underlying CfnStream if the user did not provide the field. CloudFormation will default to 1 anyway if needed, so CDK’s default is not doing anything useful here.

We should also add a validator to ensure that shardCount and StreamMode: 'ON_DEMAND' are not set at the same time when generating the template.

An end-to-end test through CloudFormation would have caught this bug before release. I’m not aware that there is any automated testing of this type at present.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
pierre-vrcommented, Jan 5, 2022

⚠️ Edit: Caution this might only work for creating a new stream from scratch (see comment below)

In the meantime, a quick fix is to manually set the shardCount prop to undefined on the Cfn resource:

const stream = new Stream(this, 'KinesisStream', {
    streamName: 'my-ingest-stream',
    streamMode: StreamMode.ON_DEMAND,
});

;(stream.node.defaultChild as CfnStream).shardCount = undefined

I have tested it and I am able to confirm that “ShardCount” is no longer present in the Cfn template.

1reaction
Harshit22commented, Jan 13, 2022

Thanks @igilham for detailed workaround ! Upgrading to CDK version 1.138.2 fixed the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Kinesis Data Streams Consumers
Some Kinesis Data Streams Records are Skipped When Using the Kinesis Client Library. The most common cause of skipped records is an unhandled...
Read more >
Amazon Kinesis Data Streams FAQs | Amazon Web Services
Amazon Kinesis Data Streams is a fully managed streaming data service. ... You do not have to worry about provisioning, deployment, ongoing-maintenance of ......
Read more >
6 common pitfalls of AWS Lambda with Kinesis trigger
When we deploy a new Lambda function with a Kinesis as a trigger, it will start by reading all the existing records from...
Read more >
Now your Kinesis streams are totally serverless! - YouTube
During AWS re:Invent there were a lot of announcements. But the new On-demand mode for Kinesis Data Streams is one of my favorites....
Read more >
Streaming to AWS Kinesis Data Streams using Kinesis Agent
During the tutorial, we will spin up an Amazon Linux 2 instance and will install Kinesis Agent. We will configure the Kinesis Agent...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found