fleet
fleet copied to clipboard
AWS IAM auth code in common_mysql increases complexity
Fleet version: (current main branch)
💥 Actual behavior
The common_mysql package contains AWS IAM authentication code (aws_iam_auth.go), which:
- Increases cognitive complexity: Developers working with
common_mysqlmay need to understand AWS IAM auth even when not using it - Weakens modularity: Other packages cannot use
common_mysqlwithout inheriting AWS SDK dependencies - Does not have single responsibility:
common_mysqlcurrently provides generic MySQL utilities, plus AWS-specific authentication - Increases build times: Any package importing
common_mysqlpulls in AWS SDK dependencies transitively
🛠️ To fix
Refactor AWS IAM authentication out of common_mysql using dependency injection:
- Create new
server/datastore/mysql/rdsauth/package containing the AWS IAM connector - Add
ConnectorFactoryinjection point tocommon_mysql.DBOptions - Update
common_mysql.NewDBto use injected factory when present - Move IAM auth setup to
mysql.New()which injects the factory - Remove
aws_iam_auth.gofromcommon_mysql
🧑💻 Steps to reproduce
These steps:
- [x] Have been confirmed to consistently lead to reproduction in multiple Fleet instances.
- Check direct imports of
common_mysql:go list -f '{{.Imports}}' ./server/datastore/mysql/common_mysql - Observe AWS-related imports:
github.com/aws/aws-sdk-go-v2/aws,github.com/fleetdm/fleet/v4/server/aws_common - Any bounded context using
common_mysqlinherits these dependencies
QA
Smoke test the RDS IAM authentication feature from #1817 (PR #32488):
- Deploy Fleet with RDS MySQL using IAM authentication (no password, region configured)
- Verify Fleet connects and operates normally