From 6f4c71d859a0781be0ec8f3b29a8d4576f3d9d44 Mon Sep 17 00:00:00 2001 From: Matt Muller <53055821+mullermp@users.noreply.github.com> Date: Wed, 3 Jul 2024 15:53:25 -0400 Subject: [PATCH] Do not warn using process credentials in shared config (#3062) --- gems/aws-sdk-core/CHANGELOG.md | 2 ++ .../lib/aws-sdk-core/credential_provider_chain.rb | 8 ++++---- gems/aws-sdk-core/lib/aws-sdk-core/shared_config.rb | 2 +- .../spec/aws/credential_resolution_chain_spec.rb | 6 ++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gems/aws-sdk-core/CHANGELOG.md b/gems/aws-sdk-core/CHANGELOG.md index ca3f022fd66..7bac7e9e3cb 100644 --- a/gems/aws-sdk-core/CHANGELOG.md +++ b/gems/aws-sdk-core/CHANGELOG.md @@ -1,6 +1,8 @@ Unreleased Changes ------------------ +* Issue - Fix `Aws::ProcessCredentials` warning in cases where shared config is used. + 3.201.0 (2024-07-02) ------------------ diff --git a/gems/aws-sdk-core/lib/aws-sdk-core/credential_provider_chain.rb b/gems/aws-sdk-core/lib/aws-sdk-core/credential_provider_chain.rb index 7574659c937..189ede119d6 100644 --- a/gems/aws-sdk-core/lib/aws-sdk-core/credential_provider_chain.rb +++ b/gems/aws-sdk-core/lib/aws-sdk-core/credential_provider_chain.rb @@ -84,7 +84,7 @@ def static_profile_credentials(options) def static_profile_process_credentials(options) if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile process_provider = Aws.shared_config.credential_process(profile: options[:config].profile) - ProcessCredentials.new(process_provider) if process_provider + ProcessCredentials.new([process_provider]) if process_provider end rescue Errors::NoSuchProfileError nil @@ -117,9 +117,9 @@ def shared_credentials(options) def process_credentials(options) profile_name = determine_profile_name(options) - if Aws.shared_config.config_enabled? && - (process_provider = Aws.shared_config.credential_process(profile: profile_name)) - ProcessCredentials.new(process_provider) + if Aws.shared_config.config_enabled? + process_provider = Aws.shared_config.credential_process(profile: profile_name) + ProcessCredentials.new([process_provider]) if process_provider end rescue Errors::NoSuchProfileError nil diff --git a/gems/aws-sdk-core/lib/aws-sdk-core/shared_config.rb b/gems/aws-sdk-core/lib/aws-sdk-core/shared_config.rb index ac66623cc1a..2dca19bb944 100644 --- a/gems/aws-sdk-core/lib/aws-sdk-core/shared_config.rb +++ b/gems/aws-sdk-core/lib/aws-sdk-core/shared_config.rb @@ -339,7 +339,7 @@ def assume_role_process_credentials_from_config(profile) if @parsed_config credential_process ||= @parsed_config.fetch(profile, {})['credential_process'] end - ProcessCredentials.new(credential_process) if credential_process + ProcessCredentials.new([credential_process]) if credential_process end def credentials_from_shared(profile, _opts) diff --git a/gems/aws-sdk-core/spec/aws/credential_resolution_chain_spec.rb b/gems/aws-sdk-core/spec/aws/credential_resolution_chain_spec.rb index d20cf0a3eff..cd0ac9f2c62 100644 --- a/gems/aws-sdk-core/spec/aws/credential_resolution_chain_spec.rb +++ b/gems/aws-sdk-core/spec/aws/credential_resolution_chain_spec.rb @@ -4,10 +4,6 @@ module Aws describe 'Credential Resolution Chain' do - before(:each) do - allow_any_instance_of(ProcessCredentials).to receive(:warn) - end - let(:mock_credential_file) do File.expand_path( File.join( @@ -35,6 +31,8 @@ module Aws before(:each) do allow(InstanceProfileCredentials).to receive(:new).and_return(mock_instance_creds) + + expect_any_instance_of(ProcessCredentials).not_to receive(:warn) end describe 'default behavior' do