Class: AwsMskIamSaslSigner::CredentialsResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-msk-iam-sasl-signer/credentials_resolver.rb

Instance Method Summary collapse

Instance Method Details

#from_credential_provider_chain(region) ⇒ Object



7
8
9
10
11
12
# File 'lib/aws-msk-iam-sasl-signer/credentials_resolver.rb', line 7

def from_credential_provider_chain(region)
  client = Aws::Kafka::Client.new(region: region)
  raise "No credentials found" unless client.config.credentials

  client.config.credentials
end

#from_profile(profile) ⇒ Object



14
15
16
# File 'lib/aws-msk-iam-sasl-signer/credentials_resolver.rb', line 14

def from_profile(profile)
  Aws::SharedCredentials.new(profile_name: profile)
end

#from_role_arn(role_arn:, session_name:) ⇒ Object



18
19
20
21
# File 'lib/aws-msk-iam-sasl-signer/credentials_resolver.rb', line 18

def from_role_arn(role_arn:, session_name:)
  sts = Aws::STS::Client.new
  sts.assume_role({ role_arn: role_arn, role_session_name: session_name })
end