Sha256: 40abee013825dbf8927f95af3238ea436cfb22f6b7569f27c59c7bb54491346e
Contents?: true
Size: 1.4 KB
Versions: 43
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true require_relative "includes" require_relative "../../credentials/factories/default_chain_provider" class AwsAssumeRole::Cli::Actions::Test < AwsAssumeRole::Cli::Actions::AbstractAction include AwsAssumeRole::Ui CommandSchema = proc do required(:profile).maybe optional(:region) { filled? > format?(REGION_REGEX) } optional(:serial_number) { filled? > format?(MFA_REGEX) } required(:role_arn).maybe required(:role_session_name).maybe required(:duration_seconds).maybe rule(role_specification: %i[profile role_arn role_session_name duration_seconds]) do |p, r, s, d| (p.filled? | p.empty? & r.filled?) & (r.filled? > s.filled? & d.filled?) end end def act_on(config) logger.debug "Will try for credentials" credentials = try_for_credentials config logger.debug "Got credentials #{credentials}" client = Aws::STS::Client.new(credentials: credentials, region: resolved_region) identity = client.get_caller_identity out format(t("commands.test.output"), identity.account, identity.arn, identity.user_id) rescue KeyError, Aws::Errors::NoSuchProfileError error format(t("errors.NoSuchProfileError"), config.profile) raise rescue Aws::Errors::MissingCredentialsError error t("errors.MissingCredentialsError") raise end end
Version data entries
43 entries across 43 versions & 1 rubygems