Skip to content

Commit a040c9a

Browse files
committed
Fix: don't try to retrieve credentials before we need them
This was causing an issue in Grafana Cloud. Also updates CHANGELOG for release
1 parent 53f8657 commit a040c9a

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 0.38.5
6+
- Fix externalID handling by @njvrzm in [#246](https://github.com/grafana/grafana-aws-sdk/pull/246)
7+
- Add CloudWatch AWS/EKS metrics and dimensions by @jangaraj in [#242](https://github.com/grafana/grafana-aws-sdk/pull/242)
8+
- Bump github.com/grafana/grafana-plugin-sdk-go by @dependabot in [#241](https://github.com/grafana/grafana-aws-sdk/pull/241)
9+
510
## 0.38.4
611
- Add AvailableMemory metric for the DMS service by @andriikushch in [#244](https://github.com/grafana/grafana-aws-sdk/pull/244)
712
- Github actions: Add token write permission by @idastambuk in [#243](https://github.com/grafana/grafana-aws-sdk/pull/243)

pkg/awsauth/auth.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ func (rcp *awsConfigProvider) GetConfig(ctx context.Context, authSettings Settin
6666
}
6767
}
6868

69-
_, err = cfg.Credentials.Retrieve(ctx)
70-
if err != nil {
71-
return aws.Config{}, fmt.Errorf("error retrieving credentials: %w", err)
72-
}
73-
7469
rcp.cache[key] = cfg
7570
return cfg, nil
7671
}

pkg/awsauth/auth_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ func (tc testCase) Run(t *testing.T) {
4646
require.Error(t, err)
4747
} else {
4848
require.NoError(t, err)
49-
tc.assertConfig(t, cfg)
50-
creds, _ := cfg.Credentials.Retrieve(ctx)
51-
if tc.authSettings.GetAuthType() == AuthTypeKeys && tc.authSettings.SessionToken != "" {
52-
assert.Equal(t, tc.authSettings.SessionToken, creds.SessionToken)
49+
creds, err := cfg.Credentials.Retrieve(ctx)
50+
if tc.assumeRoleShouldFail {
51+
require.Error(t, err)
52+
} else {
53+
tc.assertConfig(t, cfg)
54+
if tc.authSettings.GetAuthType() == AuthTypeKeys && tc.authSettings.SessionToken != "" {
55+
assert.Equal(t, tc.authSettings.SessionToken, creds.SessionToken)
56+
}
57+
accessKey, secret := tc.getExpectedKeyAndSecret(t)
58+
assert.Equal(t, accessKey, creds.AccessKeyID)
59+
assert.Equal(t, secret, creds.SecretAccessKey)
5360
}
54-
accessKey, secret := tc.getExpectedKeyAndSecret(t)
55-
assert.Equal(t, accessKey, creds.AccessKeyID)
56-
assert.Equal(t, secret, creds.SecretAccessKey)
5761
}
5862
if isStsEndpoint(&tc.authSettings.Endpoint) {
5963
assert.Equal(t, tc.authSettings.Endpoint, *client.assumeRoleClient.stsConfig.BaseEndpoint)

0 commit comments

Comments
 (0)