Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cmd/kaf/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,20 @@ func newTokenProvider() *tokenProvider {

// token either from tokenURL, static or AWS API
if cluster.SASL.Mechanism == "AWS_MSK_IAM" {
cfg, err := aws_config.LoadDefaultConfig(ctx)
var awsOpts []func(*aws_config.LoadOptions) error
if cluster.SASL.AWSProfile != "" {
awsOpts = append(awsOpts, aws_config.WithSharedConfigProfile(cluster.SASL.AWSProfile))
}
cfg, err := aws_config.LoadDefaultConfig(ctx, awsOpts...)
if err != nil {
errorExit("Could not load AWS config: " + err.Error())
}
token, _, err := aws_signer.GenerateAuthToken(ctx, cfg.Region)
var token string
if cluster.SASL.AWSProfile != "" {
token, _, err = aws_signer.GenerateAuthTokenFromProfile(ctx, cfg.Region, cluster.SASL.AWSProfile)
} else {
token, _, err = aws_signer.GenerateAuthToken(ctx, cfg.Region)
}
if err != nil {
errorExit("Could not generate auth token: " + err.Error())
}
Expand Down
1 change: 1 addition & 0 deletions examples/aws_msk_iam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ clusters:
- localhost:9092
SASL:
mechanism: AWS_MSK_IAM
# awsProfile: my-profile # optional: use a named AWS profile instead of env vars or the default profile
TLS: null
security-protocol: SASL_SSL
# set the region using the AWS_REGION envvar or saved profiles
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type SASL struct {
Scopes []string `yaml:"scopes"`
Token string `yaml:"token"`
Version int16 `yaml:"version"`
AWSProfile string `yaml:"awsProfile"`
}

type TLS struct {
Expand Down