Skip to content

Commit ca2c4c7

Browse files
Vishal TakDerik Wang
andcommitted
Merge branch 'add-user-agent-asm' into 'main'
Add user agent to AWS Secrets Manager integration See merge request https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/6060 Merged-by: Vishal Tak <vtak@gitlab.com> Approved-by: Timo Furrer <tfurrer@gitlab.com> Approved-by: Axel von Bertoldi <avonbertoldi@gitlab.com> Reviewed-by: Axel von Bertoldi <avonbertoldi@gitlab.com> Reviewed-by: Timo Furrer <tfurrer@gitlab.com> Co-authored-by: Derik Wang <derikwan@amazon.com>
2 parents ebe3556 + a2c9739 commit ca2c4c7

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

helpers/aws/service/aws_service.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
1111
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
1212
"github.com/aws/aws-sdk-go-v2/service/sts"
13+
14+
"gitlab.com/gitlab-org/gitlab-runner/common"
1315
)
1416

1517
type SecretsManagerAPI interface {
@@ -44,14 +46,22 @@ func NewAWSSecretsManager(ctx context.Context, region string, webIdentityProvide
4446
var cfg aws.Config
4547
var err error
4648

49+
// AppID is used by the AWS SDK to construct the User-Agent header sent with requests.
50+
// The SDK automatically includes the Go version, OS, and architecture in the base user agent,
51+
// and this AppID value appends the GitLab Runner version
52+
// (e.g., "aws-sdk-go-v2/1.41.0 os/macos lang/go#1.25.5 md/GOOS#darwin md/GOARCH#arm64 app/GitLab-Runner-18.8.0").
53+
appID := fmt.Sprintf("GitLab-Runner/%s", common.AppVersion.Version)
54+
4755
if webIdentityProvider != nil {
4856
cfg = aws.Config{
4957
Region: region,
5058
Credentials: webIdentityProvider,
59+
AppID: appID,
5160
}
5261
} else {
5362
cfg, err = config.LoadDefaultConfig(ctx,
5463
config.WithRegion(region),
64+
config.WithAppID(appID),
5565
)
5666
}
5767

helpers/aws/service/aws_service_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func TestNewAWSSecretsManager(t *testing.T) {
9898
assert.NoError(t, err)
9999
assert.NotNil(t, manager)
100100
assert.NotNil(t, manager.client)
101+
assert.NotEmpty(t, manager.client.(*secretsmanager.Client).Options().AppID)
101102
}
102103

103104
func TestNewWebIdentityRoleProvider(t *testing.T) {

0 commit comments

Comments
 (0)