Class: AwsMskIamSaslSigner::CLI

Inherits:
Thor
  • Object
show all
Extended by:
ThorExt::Start
Defined in:
lib/aws-msk-iam-sasl-signer/cli.rb

Instance Method Summary collapse

Methods included from ThorExt::Start

extended, start

Instance Method Details

#generateObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/aws-msk-iam-sasl-signer/cli.rb', line 18

def generate
  token_provider = MSKTokenProvider.new(region: options[:region])
  token = token_provider.generate_auth_token(
    aws_debug: options[:aws_debug]
  )

  puts "Token: #{token.token}"
  puts "Expiration Time: #{token.expiration_time_ms}"
  return unless options[:aws_debug]

  puts "Caller Identity: #{token.caller_identity.to_h.to_json}"
end

#generate_from_profileObject



34
35
36
37
38
39
40
# File 'lib/aws-msk-iam-sasl-signer/cli.rb', line 34

def generate_from_profile
  token_provider = MSKTokenProvider.new(region: options[:region])

  signed_url, expiration_time_ms = token_provider.generate_auth_token_from_profile(options[:aws_profile])
  puts "Token: #{signed_url}"
  puts "Expiration Time: #{expiration_time_ms}"
end

#generate_from_role_arnObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/aws-msk-iam-sasl-signer/cli.rb', line 46

def generate_from_role_arn
  token_provider = MSKTokenProvider.new(region: options[:region])
  signed_url, expiration_time_ms = token_provider.generate_auth_token_from_role_arn(
    options[:role_arn],
    options[:session_name]
  )

  puts "Token: #{signed_url}"
  puts "Expiration Time: #{expiration_time_ms}"
end

#versionObject



11
12
13
# File 'lib/aws-msk-iam-sasl-signer/cli.rb', line 11

def version
  say "signer/#{VERSION} #{RUBY_DESCRIPTION}"
end