Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(connector): MSK connection by AWS IAM #16625

Merged
merged 10 commits into from May 9, 2024
Merged

feat(connector): MSK connection by AWS IAM #16625

merged 10 commits into from May 9, 2024

Conversation

yuhao-su
Copy link
Contributor

@yuhao-su yuhao-su commented May 7, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Use AWS IAM to build the connection for MSK.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

To use AWS IAM to connect to MSK, properties.sasl.mechanism should be set to AWS_MSK_IAM .

Also the following field:
region (optional) the region MSK region located.
access_key (required) AWS access key ID for accessing the MSK.
secret_key (required) should be provided. AWS seceret key for accessing the MSK.
arn (optional)
external_id (optional)
session_token (optional
)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@yuhao-su yuhao-su requested a review from a team as a code owner May 7, 2024 22:55
Copy link

gitguardian bot commented May 7, 2024

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9425213 Triggered Generic Password ff2a92c e2e_test/source/cdc/cdc.validate.postgres.slt View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 5070 files.

Valid Invalid Ignored Fixed
2168 1 2901 0
Click to see the invalid file list
  • src/connector/src/source/kafka/client_context.rs

Cargo.toml Outdated
@@ -118,7 +118,7 @@ axum = "=0.7.4" # TODO: 0.7.5+ does not work with current toolchain
etcd-client = { package = "madsim-etcd-client", version = "0.4" }
futures-async-stream = "0.2.9"
hytra = "0.1"
rdkafka = { package = "madsim-rdkafka", version = "0.3.4", features = [
rdkafka = { package = "madsim-rdkafka", version = "0.4.0", features = [
Copy link
Contributor Author

@yuhao-su yuhao-su May 7, 2024

Choose a reason for hiding this comment

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

This is to refactor rdkafka. madsim-rs/madsim#207

Copy link
Contributor

Choose a reason for hiding this comment

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

bumped to v0.4.1 to add some missing APIs madsim-rs/madsim#208

@neverchanje
Copy link
Contributor

neverchanje commented May 8, 2024

Didn't dive into details.
Seems the only user-facing change AWS_MSK_IAM is a new value option for the config sasl_mechanism.
Please remember to update the comment above it and update with_options_source/sink.yaml.

    /// SASL mechanism if SASL is enabled. Currently support PLAIN, SCRAM and GSSAPI.
    #[serde(rename = "properties.sasl.mechanism")]
    sasl_mechanism: Option<String>,

@yuhao-su
Copy link
Contributor Author

yuhao-su commented May 8, 2024

Seems the only user-facing change AWS_MSK_IAM is a new value option for the config sasl_mechanism

Also users can provide ak/sk and assume role arn. Just like kinesis and pulsar source.

yuhao-su and others added 2 commits May 7, 2024 21:20
Signed-off-by: Runji Wang <[email protected]>
@fuyufjh
Copy link
Contributor

fuyufjh commented May 8, 2024

Please update the "Documentation" section in PR description

Copy link
Contributor

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

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

Generally LGTM

src/connector/Cargo.toml Outdated Show resolved Hide resolved
// AWS_MSK_IAM
if self.is_aws_msk_iam() {
config.set("security.protocol", "SASL_SSL");
config.set("sasl.mechanism", "OAUTHBEARER");
Copy link
Contributor

Choose a reason for hiding this comment

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

The OAUTHBEARER was mentioned as an alternative way in https://github.com/aws/aws-msk-iam-auth?tab=readme-ov-file#configuring-a-kafka-client-to-use-aws-iam-with-sasl-oauthbearer-mechanism. Not quite understand this part, may I ask the difference between sasl.mechanism = AWS_MSK_IAM and OAUTHBEARER? Is the first one actually implemented with the second one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AWS_MSK_IAM is not a rdkafka value while OAUTHBEARER is. When using AWS_MSK_IAM, rdkafka mechanism will be set to OAUTHBEARER. I use AWS_MSK_IAM because we want't user to explicitly tell RW that an AWS service was used instead of implicitly by providing ak/sk.

src/connector/src/source/kafka/private_link.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@tabVersion tabVersion left a comment

Choose a reason for hiding this comment

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

rest LGTM

Comment on lines +217 to +219
- name: region
field_type: String
required: false
Copy link
Contributor

Choose a reason for hiding this comment

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

how about adding a aws prefix for these props? I am not sure if GCP or Azure has the same stuff 😅

Copy link
Contributor Author

@yuhao-su yuhao-su May 8, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe open another pr to add prefix for AwsAuthProp while keeping the backward compatibility

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM

src/connector/src/source/kafka/enumerator/client.rs Outdated Show resolved Hide resolved
@yuhao-su yuhao-su added the user-facing-changes Contains changes that are visible to users label May 8, 2024
@yuhao-su yuhao-su added this pull request to the merge queue May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants