lib/aws_su.rb in aws_su-0.1.2 vs lib/aws_su.rb in aws_su-0.1.3

- old
+ new

@@ -126,10 +126,11 @@ end # Assume a role using an MFA Token def assume_role_mfa(duration, mfa_code = nil) mfa_code = prompt_for_mfa_code if mfa_code.nil? + delete_sudo_file role_creds = sts_client.assume_role( role_arn: AWSConfig[@profile]['role_arn'], role_session_name: @session, duration_seconds: duration.to_i, serial_number: AWSConfig[@profile]['mfa_serial'], @@ -143,10 +144,15 @@ # # @param duration A string integer representing the role session duration def calculate_session_expiry(duration = DURATION) (Time.now + duration.to_i).strftime('%Y-%m-%d %H:%M:%S') end + # Delete the AWS sudo file + def delete_sudo_file + File.delete(AWS_SUDO_FILE) if File.exist?(AWS_SUDO_FILE) + end + # Get the values for AWS secrets etc and export them to the environment def export_aws_sudo_file return unless File.exists?(AWS_SUDO_FILE) File.readlines(AWS_SUDO_FILE).each do |line| @@ -242,10 +248,10 @@ return false end false end - # Update the Aws.config + # Update the Aws.config hash def update_aws_config(role_creds) Aws.config.update( credentials: Aws::Credentials.new( role_creds.credentials.access_key_id, role_creds.credentials.secret_access_key,