Skip to content

feat(kinesis) Cross-account Kinesis source support via STS assume-role in JsonKinesisSource - #19383

Open
suryadanny wants to merge 1 commit into
apache:masterfrom
suryadanny:ENG-45358-cross-account-kinesis
Open

feat(kinesis) Cross-account Kinesis source support via STS assume-role in JsonKinesisSource#19383
suryadanny wants to merge 1 commit into
apache:masterfrom
suryadanny:ENG-45358-cross-account-kinesis

Conversation

@suryadanny

Copy link
Copy Markdown

Tracking issue: #19382

Change Logs

Kinesis has no resource-based policy, so reading a stream in a different AWS account than the application requires IAM role assumption (sts:AssumeRole). This adds an optional config hoodie.streamer.source.kinesis.role.arn:

  • KinesisSourceConfig — new KINESIS_ROLE_ARN key (no default). Naming aligns with HoodieAWSConfig.hoodie.aws.role.arn.
  • KinesisOffsetGen.createKinesisClient — when the ARN is set (and no static keys), attach an auto-refreshing StsAssumeRoleCredentialsProvider (AWS SDK v2). The base STS client uses the default credential chain (must be granted sts:AssumeRole on the ARN). Static access/secret keys still take precedence; empty/absent ARN preserves the existing same-account behavior. No external ID is used.
  • Provider is cached per region|roleArn so a long-lived streaming executor reuses one StsClient per distinct role instead of leaking one per mapPartitions task (AWS SDK v2 does not close a user-supplied credentials provider when the KinesisClient closes).
  • KinesisReadConfig — carry the ARN so executors rebuild the client with it (client is built inside mapPartitions, not on the driver).
  • JsonKinesisSource — thread the ARN through on both driver and executor paths.
  • hudi-utilities/pom.xml — add software.amazon.awssdk:sts (StsAssumeRoleCredentialsProvider is not otherwise on the classpath; kinesis doesn't pull it transitively).

New unit tests (no Spark harness): the config-key contract, ARN round-trip + null preservation, ARN surviving Java serialization to executors, and the credential-provider branch selection (assume-role vs default-chain vs static-keys-take-precedence).

Impact

Opt-in; no behavior change when the config is unset. Enables reading cross-account Kinesis streams.

Risk level (write none, low medium or high below)

low — additive, gated behind a new no-default config; existing same-account path unchanged.

Documentation Update

Config is self-documenting via withDocumentation; will surface in the generated configuration docs. No separate doc page needed.

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact described above
  • Necessary unit tests added

🤖 Generated with Claude Code

Kinesis has no resource-based policy, so reading a stream in a different AWS
account requires IAM role assumption (sts:AssumeRole). Add an optional role-ARN
config (hoodie.streamer.source.kinesis.role.arn) that, when set, builds the
KinesisClient with an STS assume-role credentials provider (AWS SDK v2). The
base STS client uses the default credential chain; static access/secret keys
still take precedence. Empty/absent preserves the existing same-account
behavior. No external ID is used.

The assume-role provider is cached per region|roleArn so a long-lived streaming
executor reuses one StsClient per distinct role instead of leaking one per
mapPartitions task (AWS SDK v2 does not close a user-supplied credentials
provider when the KinesisClient closes).

Adds software.amazon.awssdk:sts to hudi-utilities and unit coverage for the
config-key contract, ARN serialization to executors, and the credential-
provider branch selection.
@github-actions github-actions Bot added the size:M PR with lines of changes in (100, 300] label Jul 27, 2026
@suryadanny suryadanny changed the title Cross-account Kinesis source support via STS assume-role in JsonKinesisSource feat(kinesis) Cross-account Kinesis source support via STS assume-role in JsonKinesisSource Jul 27, 2026

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for working on this! This PR adds opt-in cross-account Kinesis support by threading a new hoodie.streamer.source.kinesis.role.arn config through to an STS StsAssumeRoleCredentialsProvider, cached per region|roleArn to avoid leaking an StsClient per micro-batch. The plumbing (config → serializable KinesisReadConfig → executor client build), precedence logic, and caching all look sound after tracing the driver and executor paths. One edge case around credential precedence is worth double-checking in the inline comment. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. One small naming nit on the private helper method; otherwise the code is clean and well-documented.

@hudi-bot

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

public static final ConfigProperty<String> KINESIS_ROLE_ARN = ConfigProperty
.key(PREFIX + "role.arn")
.noDefaultValue()
.sinceVersion("1.2.0")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.sinceVersion("1.2.0")
.sinceVersion("1.3.0")

Comment thread hudi-utilities/pom.xml
Comment on lines +541 to +545
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sts</artifactId>
<version>${aws.sdk.version}</version>
</dependency>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be shaded in hudi-utilities-bundle?

@codecov-commenter

codecov-commenter commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.81%. Comparing base (4a5d5b0) to head (e5e2b37).
⚠️ Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
...di/utilities/sources/helpers/KinesisOffsetGen.java 0.00% 13 Missing ⚠️
...che/hudi/utilities/config/KinesisSourceConfig.java 0.00% 6 Missing ⚠️
...ache/hudi/utilities/sources/JsonKinesisSource.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19383      +/-   ##
============================================
- Coverage     70.49%   67.81%   -2.68%     
+ Complexity    32775    31636    -1139     
============================================
  Files          2700     2700              
  Lines        152896   152915      +19     
  Branches      19009    19010       +1     
============================================
- Hits         107778   103702    -4076     
- Misses        36596    40955    +4359     
+ Partials       8522     8258     -264     
Components Coverage Δ
hudi-common 81.11% <ø> (-0.30%) ⬇️
hudi-client 80.25% <ø> (-1.33%) ⬇️
hudi-flink 78.62% <ø> (ø)
hudi-spark-datasource 55.37% <ø> (-3.01%) ⬇️
hudi-utilities 48.95% <0.00%> (-21.42%) ⬇️
hudi-cli 15.32% <ø> (ø)
hudi-hadoop 62.29% <ø> (-1.20%) ⬇️
hudi-sync 70.62% <ø> (ø)
hudi-io 79.09% <ø> (-0.48%) ⬇️
hudi-timeline-service 83.83% <ø> (+0.09%) ⬆️
hudi-cloud 64.00% <ø> (ø)
hudi-kafka-connect 53.20% <ø> (ø)
Flag Coverage Δ
flink-integration-tests 47.72% <ø> (+0.18%) ⬆️
hadoop-mr-java-client 43.33% <ø> (-0.01%) ⬇️
spark-client-hadoop-common 48.71% <ø> (-0.01%) ⬇️
spark-java-tests 44.67% <0.00%> (-4.57%) ⬇️
spark-scala-tests 44.35% <0.00%> (-0.31%) ⬇️
utilities 0.00% <0.00%> (-36.43%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ache/hudi/utilities/sources/JsonKinesisSource.java 22.66% <0.00%> (-0.31%) ⬇️
...che/hudi/utilities/config/KinesisSourceConfig.java 93.80% <0.00%> (-5.27%) ⬇️
...di/utilities/sources/helpers/KinesisOffsetGen.java 44.33% <0.00%> (-2.67%) ⬇️

... and 235 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M PR with lines of changes in (100, 300]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants