Skip to content

AWS API Calls from CNI not using correct UserAgent #3555

@cdirubbio

Description

@cdirubbio

What happened: CloudTrail events not showing userAgent containing "amazon-vpc-cni-k8s". This is unintended.

    "userAgent": "aws-sdk-go-v2/1.39.2 ua/2.1 os/linux lang/go#1.25.4 md/GOOS#linux md/GOARCH#amd64 api/ec2#1.254.1 m/E,z",

I'm going to work on debugging and make the PR myself for the fix.

The issue was introduced in commit 8dd2a5a57 when transitioning from aws-sdkv1 to aws-sdkv2

Attach logs

What you expected to happen: this to work

// injectUserAgent will inject app specific user-agent into awsSDK
func injectUserAgent(loadOptions *config.LoadOptions) error {
	version := utils.GetEnv(envVpcCniVersion, "")
	userAgent := fmt.Sprintf("amazon-vpc-cni-k8s/version/%s", version)

	loadOptions.APIOptions = append(loadOptions.APIOptions, func(stack *smithymiddleware.Stack) error {
		return stack.Build.Add(&addUserAgentMiddleware{
			userAgent: userAgent,
		}, smithymiddleware.After)
	})

	return nil
}

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version):
  • CNI Version
  • OS (e.g: cat /etc/os-release):
  • Kernel (e.g. uname -a):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions