Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Dynamodb instrumentation access_key_id error on some credential classes #2684

Merged
merged 10 commits into from
Jun 6, 2024
5 changes: 4 additions & 1 deletion lib/new_relic/agent/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ module Aws
HEX_MASK = '7fffffffff80'

def self.create_arn(service, resource, config)
access_key_id = config&.credentials&.credentials&.access_key_id if config&.credentials&.credentials&.respond_to?(:access_key_id)
tannalynn marked this conversation as resolved.
Show resolved Hide resolved
return unless access_key_id

region = config.region
account_id = NewRelic::Agent::Aws.convert_access_key_to_account_id(config.credentials.access_key_id)
account_id = NewRelic::Agent::Aws.convert_access_key_to_account_id(access_key_id)

"arn:aws:#{service}:#{region}:#{account_id}:#{resource}"
rescue => e
Expand Down
1 change: 1 addition & 0 deletions test/new_relic/agent/aws_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def test_create_arn
config = mock
config.stubs(:region).returns('us-test-region-1')
mock_credentials = mock
mock_credentials.stubs(:credentials).returns(mock_credentials)
mock_credentials.stubs(:access_key_id).returns('AKIAIOSFODNN7EXAMPLE') # this is a fake access key id from aws docs
config.stubs(:credentials).returns(mock_credentials)

Expand Down
Loading