Skip to content

Migrate from aws-sdk-go v1 to aws-sdk-go-v2 - #9

Merged
tommyzli merged 5 commits into
mainfrom
migrate-aws-sdk-go-v2
Jun 5, 2026
Merged

tommyzli merged 5 commits into
mainfrom
migrate-aws-sdk-go-v2

Conversation

@tommyzli

@tommyzli tommyzli commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Migrates all quota checks from the deprecated aws-sdk-go v1 to aws-sdk-go-v2 (EC2, ASG, Lambda, ELBv2, IAM, Service Quotas) — context-aware paginators, NewFromConfig clients, and regenerated mocks. Bumps Go to 1.24.
  • Sets config.WithRetryMaxAttempts(10) on the shared config. The Service Quotas API has a low request rate limit and the exporter calls ListServiceQuotas once per service, so the v2 standard retryer's default of 3 attempts surfaced TooManyRequestsException during normal scrapes. Raising the ceiling lets the SDK back off through throttling.

Test plan

  • go build ./cmd
  • go test ./... — all packages pass
  • Ran the built binary against us-west-2 with default checks: ~3,410 metrics, no throttling.
  • Ran each optional flag individually against us-west-2 and validated the expected metric family appears with no errors/throttling:
    • --enable-vpc-endpoints → *_vpc_endpoints_per_vpc
    • --enable-vpcs-per-region → vpcs_per_region
    • --enable-eips-per-region → eips_per_region
    • --enable-nlbs-per-region → nlbs_per_region
    • --enable-iam-roles-per-account → iam_roles_per_account
    • --enable-iam-policies-per-account → iam_policies_per_account

🤖 Generated with Claude Code

tommyzli and others added 2 commits June 5, 2026 14:46
Replace the deprecated aws-sdk-go v1 SDK with aws-sdk-go-v2 across all
quota checks (EC2, ASG, Lambda, ELBv2, IAM, Service Quotas), including
context-aware paginators, NewFromConfig clients, and regenerated mocks.

Set WithRetryMaxAttempts(10) on the shared config: the Service Quotas
API has a low request rate limit and the exporter calls ListServiceQuotas
once per service, so the v2 standard retryer's default of 3 attempts
surfaced TooManyRequestsException under normal scrapes. Raising the
attempt ceiling lets the SDK back off through throttling.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@behebot

behebot commented Jun 5, 2026

Copy link
Copy Markdown

should you update https://github.com/ClickHouse/aws-service-quotas-exporter/blob/main/build/Dockerfile#L1 ?

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the quota/usage checks from aws-sdk-go v1 to aws-sdk-go-v2, updating clients, paginators, and mocks, and bumps the project to Go 1.24 to support the updated SDK/tooling.

Changes:

  • Replace v1 AWS service clients/interfaces with v2 NewFromConfig clients and context-aware paginators across EC2/VPC/VPC endpoints/ASG/Lambda/ELBv2/IAM/Service Quotas.
  • Regenerate/update mocks and unit tests to use v2 API shapes (types.*) and request signatures (context.Context + options).
  • Update build/runtime dependencies: Go 1.24 in go.mod and Docker builder image, plus v2 SDK modules in go.mod/go.sum.

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
servicequotas/vpc_limits.go Migrate VPC/EIP usage checks to EC2 v2 client + paginator usage.
servicequotas/vpc_limits_test.go Update VPC/EIP tests to v2 shapes and mock behaviors.
servicequotas/vpc_endpoint_limits.go Migrate VPC endpoint counting/checks to EC2 v2 paginator + v2 endpoint type enums.
servicequotas/vpc_endpoint_limits_test.go Update VPC endpoint tests to v2 shapes/enums.
servicequotas/service_quotas.go Migrate Service Quotas client creation to v2 config; implement v2 paginator usage; update region/partition handling.
servicequotas/service_quotas_test.go Update service quotas tests/mocks to v2 interfaces and types.
servicequotas/nlb_limits.go Migrate ELBv2 NLB usage check to v2 client + paginator.
servicequotas/nlb_limits_test.go Update NLB tests to v2 ELBv2 types.
servicequotas/mock_iam_client.go Update IAM mock to v2 method signatures and output types.
servicequotas/mock_elbv2_client.go Update ELBv2 mock to v2 method signatures and output types.
servicequotas/mock_ec2_client.go Update EC2 mock to v2 method signatures and output types; capture filters in v2 form.
servicequotas/mock_autoscaling_client.go Update ASG mock to v2 method signature and output types.
servicequotas/lambda_limits.go Migrate Lambda account settings usage check to v2 client signature and output shapes.
servicequotas/lambda_limits_test.go Update Lambda tests to v2 shapes/types.
servicequotas/iam_limits.go Migrate IAM usage checks to v2 paginators + v2 policy scope enum.
servicequotas/iam_limits_test.go Update IAM tests to v2 shapes/enums and mock expectations.
servicequotas/ec2_limits.go Migrate EC2-backed usage checks to v2 paginators and v2 request/shape types.
servicequotas/ec2_limits_test.go Update EC2 usage-check tests to v2 types and filter shapes.
servicequotas/asg_limits.go Migrate ASG usage check to v2 paginator + v2 instance lifecycle state type.
servicequotas/asg_limits_test.go Update ASG tests to v2 shapes/enums.
go.mod Bump Go version and replace v1 SDK dependency with v2 module set.
go.sum Refresh dependency checksums to match v2 SDK and updated indirect deps.
build/Dockerfile Update build image to Go 1.24 Alpine image.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread servicequotas/ec2_limits.go
Comment thread servicequotas/service_quotas.go
Comment thread servicequotas/lambda_limits.go Outdated
Comment thread build/Dockerfile
tommyzli and others added 2 commits June 5, 2026 15:29
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Map us-iso-* to aws-iso and us-isob-* to aws-iso-b, including their
global Service Quotas regions, so ISO-partition regions resolve to the
correct partition instead of falling through to the default aws partition.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tommyzli
tommyzli merged commit dd37de1 into main Jun 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants