Skip to content

Commit b759b8c

Browse files
authored
Update to Go 1.24 and refresh AGENTS.md documentation (#195)
- Move to Go 1.24 and update dependencies - Update AGENTS.md to reflect AWS SDK v2 migration patterns and implementation details 🤖 Generated with [Claude Code](https://claude.ai/code) Assisted-by: Claude <[email protected]> Signed-off-by: Rafa Porres Molina <[email protected]>
1 parent 892b339 commit b759b8c

File tree

4 files changed

+115
-105
lines changed

4 files changed

+115
-105
lines changed

AGENTS.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ AWS Resource Exporter is a Prometheus exporter for AWS resources, built in Go. I
4343
- Service-specific configs extend BaseConfig (RDSConfig, VPCConfig, etc.)
4444

4545
**AWS Client Layer (`pkg/awsclient/`)**
46-
- Centralized AWS SDK session management
47-
- Service-specific client wrappers
48-
- Mock interfaces for testing
46+
- Centralized AWS SDK v2 config-based client management
47+
- Service-specific client wrappers with paginator patterns
48+
- Mock interfaces for testing using golang/mock
4949

5050
**Service Collectors (`pkg/`)**
5151
- Each AWS service has its own collector: `rds.go`, `vpc.go`, `ec2.go`, `route53.go`, `elasticache.go`, `iam.go`, `msk.go`
@@ -66,7 +66,7 @@ AWS Resource Exporter is a Prometheus exporter for AWS resources, built in Go. I
6666

6767
**AWS Credentials**
6868
- Environment variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`
69-
- Standard AWS SDK credential chain support
69+
- Standard AWS SDK v2 credential chain support with aws.Config
7070

7171
**Metrics Collection**
7272
- Each service runs on configurable intervals
@@ -75,8 +75,9 @@ AWS Resource Exporter is a Prometheus exporter for AWS resources, built in Go. I
7575

7676
**Testing Strategy**
7777
- Unit tests for each service collector
78-
- Mock AWS clients using golang/mock
78+
- Mock AWS clients using golang/mock with AWS SDK v2 interfaces
7979
- Test files mirror source file structure (`pkg/*_test.go`)
80+
- Mock generation: `go generate ./pkg/awsclient/`
8081

8182
## Exported Metrics
8283

@@ -133,3 +134,21 @@ AWS Resource Exporter is a Prometheus exporter for AWS resources, built in Go. I
133134
### AWS Client Metrics
134135
- `aws_resources_exporter_awsclient_api_requests_total` - Total AWS API requests made
135136
- `aws_resources_exporter_awsclient_api_errors_total` - Total AWS API errors encountered
137+
138+
## Key Implementation Notes
139+
140+
### AWS SDK v2 Migration
141+
- Project migrated from AWS SDK for Go v1 to v2
142+
- Uses config-based initialization instead of session-based
143+
- Paginator patterns replace callback-based pagination
144+
- Error handling uses smithy errors instead of awserr
145+
- Type system changes: some fields changed from *int64 to *int32
146+
- Method signatures updated (removed WithContext suffixes)
147+
- Import paths use aws-sdk-go-v2 namespace
148+
149+
### Important Patterns
150+
- All AWS API calls use context.Context for cancellation
151+
- Pagination handled via AWS SDK v2 paginators (NewListRolesPaginator, etc.)
152+
- Error metrics incremented at usage sites to avoid double counting
153+
- IAM metrics use GetAccountSummary API for efficiency instead of listing all roles
154+
- RDS AllocatedStorage metric handles int32 overflow by casting to int64 before multiplication

go.mod

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,48 @@
11
module github.com/app-sre/aws-resource-exporter
22

3-
go 1.22
3+
go 1.24
44

55
require (
66
github.com/alecthomas/kingpin/v2 v2.4.0
7-
github.com/aws/aws-sdk-go v1.55.8
8-
github.com/aws/aws-sdk-go-v2 v1.30.3
9-
github.com/aws/aws-sdk-go-v2/config v1.27.24
10-
github.com/aws/aws-sdk-go-v2/service/ec2 v1.173.0
11-
github.com/aws/aws-sdk-go-v2/service/elasticache v1.40.0
12-
github.com/aws/aws-sdk-go-v2/service/iam v1.34.0
13-
github.com/aws/aws-sdk-go-v2/service/kafka v1.35.1
14-
github.com/aws/aws-sdk-go-v2/service/rds v1.82.0
15-
github.com/aws/aws-sdk-go-v2/service/route53 v1.42.0
16-
github.com/aws/aws-sdk-go-v2/service/servicequotas v1.23.0
17-
github.com/aws/aws-sdk-go-v2/service/sts v1.30.1
7+
github.com/aws/aws-sdk-go-v2 v1.39.1
8+
github.com/aws/aws-sdk-go-v2/config v1.31.10
9+
github.com/aws/aws-sdk-go-v2/service/ec2 v1.254.0
10+
github.com/aws/aws-sdk-go-v2/service/elasticache v1.50.4
11+
github.com/aws/aws-sdk-go-v2/service/iam v1.47.6
12+
github.com/aws/aws-sdk-go-v2/service/kafka v1.43.5
13+
github.com/aws/aws-sdk-go-v2/service/rds v1.107.1
14+
github.com/aws/aws-sdk-go-v2/service/route53 v1.58.3
15+
github.com/aws/aws-sdk-go-v2/service/servicequotas v1.32.4
16+
github.com/aws/aws-sdk-go-v2/service/sts v1.38.5
17+
github.com/aws/smithy-go v1.23.0
1818
github.com/golang/mock v1.6.0
19-
github.com/prometheus/client_golang v1.20.5
20-
github.com/prometheus/client_model v0.6.1
21-
github.com/prometheus/common v0.60.0
22-
github.com/stretchr/testify v1.9.0
19+
github.com/prometheus/client_golang v1.23.2
20+
github.com/prometheus/client_model v0.6.2
21+
github.com/prometheus/common v0.66.1
22+
github.com/stretchr/testify v1.11.1
2323
gopkg.in/yaml.v3 v3.0.1
2424
)
2525

2626
require (
2727
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
28-
github.com/aws/aws-sdk-go-v2/credentials v1.17.24 // indirect
29-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.9 // indirect
30-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect
31-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 // indirect
32-
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
33-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 // indirect
34-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 // indirect
35-
github.com/aws/aws-sdk-go-v2/service/sso v1.22.1 // indirect
36-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.2 // indirect
37-
github.com/aws/smithy-go v1.20.3 // indirect
28+
github.com/aws/aws-sdk-go-v2/credentials v1.18.14 // indirect
29+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.8 // indirect
30+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.8 // indirect
31+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.8 // indirect
32+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
33+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.1 // indirect
34+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.8 // indirect
35+
github.com/aws/aws-sdk-go-v2/service/sso v1.29.4 // indirect
36+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.0 // indirect
3837
github.com/beorn7/perks v1.0.1 // indirect
3938
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4039
github.com/davecgh/go-spew v1.1.1 // indirect
41-
github.com/jmespath/go-jmespath v0.4.0 // indirect
42-
github.com/klauspost/compress v1.17.11 // indirect
4340
github.com/kr/text v0.2.0 // indirect
4441
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
4542
github.com/pmezard/go-difflib v1.0.0 // indirect
46-
github.com/prometheus/procfs v0.15.1 // indirect
43+
github.com/prometheus/procfs v0.16.1 // indirect
4744
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
48-
golang.org/x/sys v0.26.0 // indirect
49-
google.golang.org/protobuf v1.35.1 // indirect
45+
go.yaml.in/yaml/v2 v2.4.2 // indirect
46+
golang.org/x/sys v0.35.0 // indirect
47+
google.golang.org/protobuf v1.36.8 // indirect
5048
)

0 commit comments

Comments
 (0)