Skip to content

Add support for role chain assumption - #132

Merged
fernandezcuesta merged 5 commits into
crossplane-contrib:mainfrom
moserke:issue-131
Apr 24, 2026
Merged

Add support for role chain assumption#132
fernandezcuesta merged 5 commits into
crossplane-contrib:mainfrom
moserke:issue-131

Conversation

@moserke

@moserke moserke commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Description of your changes

Fixes #131

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

ran the custom image in a local crossplane cluster

@fernandezcuesta

Copy link
Copy Markdown
Collaborator

@moserke thanks for your contribution!
Could you please sign your commits? 🙏

@moserke
moserke force-pushed the issue-131 branch 3 times, most recently from 03cf621 to bfdd035 Compare April 15, 2026 14:15
@moserke

moserke commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

Sure thing, sorry about that. Signed now!

@fernandezcuesta

Copy link
Copy Markdown
Collaborator

Sure thing, sorry about that. Signed now!

DCO check still failing:

Commit sha: a163fbd, Author: Moser, Kevin, Committer: Moser, Kevin; The sign-off is missing.
Commit sha: bfdd035, Author: Moser, Kevin, Committer: Moser, Kevin; The sign-off is missing.

moserke added 2 commits April 15, 2026 12:33
Signed-off-by: Moser, Kevin <kevin.moser@horizon3.ai>
Signed-off-by: Moser, Kevin <kevin.moser@horizon3.ai>
@moserke

moserke commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

aha. If only I read the error message closer.... DCO is passing now

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds role chaining support for AWS MSK IAM authentication so provider-kafka can use ambient AWS credentials (e.g., IRSA/PodIdentity) and optionally assume a configured role before authenticating to MSK, addressing cross-account MSK access (Fixes #131).

Changes:

  • Extended Kafka SASL config to accept an optional roleArn.
  • Updated AWS MSK IAM auth to assume the configured role via STS before retrieving credentials.
  • Promoted required AWS SDK v2 modules to direct dependencies in go.mod.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
internal/clients/kafka/config.go Adds sasl.roleArn to the JSON config schema.
internal/clients/kafka/client.go Wraps AWS MSK IAM auth to optionally perform STS AssumeRole (role chaining).
go.mod Adds direct dependencies needed for STS assume-role credentials caching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/clients/kafka/client.go
Comment on lines +122 to +128
if roleArn != "" {
stsClient := sts.NewFromConfig(s)
provider := stscreds.NewAssumeRoleProvider(stsClient, roleArn, func(o *stscreds.AssumeRoleOptions) {
o.RoleSessionName = "crossplane-provider-kafka"
})
s.Credentials = aws.NewCredentialsCache(provider)
}

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

The new role-chaining branch (roleArn -> STS AssumeRole) is not covered by tests. Since this package already has unit tests, please add coverage for the new behavior (e.g., refactor authenticateAwsIam to allow injecting/mocking the STS client/credential provider and assert that credentials retrieval uses AssumeRole when roleArn is set).

Copilot uses AI. Check for mistakes.
Comment on lines 11 to 15
type SASL struct {
Mechanism string `json:"mechanism"`
RoleArn string `json:"roleArn"`
Username string `json:"username"`
Password string `json:"password"` //nolint:gosec

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

RoleArn extends the expected JSON schema for the provider secret, but the repository documentation/examples that point to internal/clients/kafka/config.go will become outdated unless they mention the new sasl.roleArn field and how it is used with aws-msk-iam. Please update the user-facing docs/examples accordingly so users can discover and correctly configure role chaining.

Copilot uses AI. Check for mistakes.
Comment thread go.mod Outdated
Comment on lines +14 to +17
github.com/aws/aws-sdk-go-v2 v1.41.4
github.com/aws/aws-sdk-go-v2/config v1.32.12
github.com/aws/aws-sdk-go-v2/credentials v1.19.12
github.com/aws/aws-sdk-go-v2/service/sts v1.41.9

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
github.com/aws/aws-sdk-go-v2 v1.41.4
github.com/aws/aws-sdk-go-v2/config v1.32.12
github.com/aws/aws-sdk-go-v2/credentials v1.19.12
github.com/aws/aws-sdk-go-v2/service/sts v1.41.9
github.com/aws/aws-sdk-go-v2 v1.41.5
github.com/aws/aws-sdk-go-v2/config v1.32.14
github.com/aws/aws-sdk-go-v2/credentials v1.19.14
github.com/aws/aws-sdk-go-v2/service/sts v1.41.10

and tidy

@fernandezcuesta

Copy link
Copy Markdown
Collaborator

@moserke could you please resolve the conflicts? After that I feel we're good to merge and release v1.2

moserke and others added 2 commits April 23, 2026 12:34
Signed-off-by: Moser, Kevin <kevin.moser@horizon3.ai>
@moserke

moserke commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

@fernandezcuesta resolved the conflicts and did a go mod tidy.

@fernandezcuesta

Copy link
Copy Markdown
Collaborator

Thanks a lot @moserke for your contribution, all good and merging!

@fernandezcuesta
fernandezcuesta merged commit 4f0cf1f into crossplane-contrib:main Apr 24, 2026
7 checks passed
@fernandezcuesta

fernandezcuesta commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Marketplace
GH Release

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Role Chaining

3 participants