Migrate from aws-sdk-go v1 to v2 (#30308)

#29482

[Migrate to the AWS SDK for Go
v2](https://docs.aws.amazon.com/sdk-for-go/v2/developer-guide/migrate-gosdk.html)
documents how to migrate codebases.

QA on features that use AWS SDK Go:
- Bootstrap package:
  - upload:  
  - download: 
  - cleanup: 
- Software (upload, download, installation, etc.) 
  - Cloudfront: Luckly, this feature was already using aws-sdk-go-v2.
- Carves 
- Logging:
	- Firehose 
	- Kinesis 
- Lambda  (tested result logs to a lambda function on our AWS Dogfood
account)
- Email:
	- Amazon SES TODO ⚠️ (this is what Dogfood uses and a few customers)
- We cannot easily test locally, we can use dogfood or load testing
(AWS) environments.

---

- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.
- [ ] Manual QA for all new/changed functionality
This commit is contained in:
Lucas Manuel Rodriguez
2025-06-30 17:45:39 -03:00
committed by GitHub
parent 05108066ba
commit 404f0d3ac0
42 changed files with 770 additions and 607 deletions
+2 -13
View File
@@ -107,7 +107,7 @@ func applyDevFlags(cfg *config.FleetConfig) {
cfg.S3.CarvesBucket = "carves-dev"
cfg.S3.CarvesRegion = "minio"
cfg.S3.CarvesPrefix = "dev-prefix"
cfg.S3.CarvesEndpointURL = "localhost:9000"
cfg.S3.CarvesEndpointURL = "http://localhost:9000"
cfg.S3.CarvesAccessKeyID = "minio"
cfg.S3.CarvesSecretAccessKey = "minio123!"
cfg.S3.CarvesDisableSSL = true
@@ -118,23 +118,12 @@ func applyDevFlags(cfg *config.FleetConfig) {
cfg.S3.SoftwareInstallersBucket = "software-installers-dev"
cfg.S3.SoftwareInstallersRegion = "minio"
cfg.S3.SoftwareInstallersPrefix = "dev-prefix"
cfg.S3.SoftwareInstallersEndpointURL = "localhost:9000"
cfg.S3.SoftwareInstallersEndpointURL = "http://localhost:9000"
cfg.S3.SoftwareInstallersAccessKeyID = "minio"
cfg.S3.SoftwareInstallersSecretAccessKey = "minio123!"
cfg.S3.SoftwareInstallersDisableSSL = true
cfg.S3.SoftwareInstallersForceS3PathStyle = true
}
cfg.Packaging.S3 = config.S3Config{
Bucket: "installers-dev",
Region: "minio",
Prefix: "dev-prefix",
EndpointURL: "localhost:9000",
AccessKeyID: "minio",
SecretAccessKey: "minio123!",
DisableSSL: true,
ForceS3PathStyle: true,
}
}
func initLogger(cfg config.FleetConfig) kitlog.Logger {
+17 -40
View File
@@ -138,7 +138,7 @@ the way that the Fleet server works.
logger := initLogger(config)
if dev {
createTestBucketForInstallers(&config, logger)
createTestBuckets(&config, logger)
}
// Init tracing
@@ -254,41 +254,6 @@ the way that the Fleet server works.
}
}
if config.Packaging.GlobalEnrollSecret != "" {
secrets, err := ds.GetEnrollSecrets(cmd.Context(), nil)
if err != nil {
initFatal(err, "loading enroll secrets")
}
var globalEnrollSecret string
for _, secret := range secrets {
if secret.TeamID == nil {
globalEnrollSecret = secret.Secret
break
}
}
if globalEnrollSecret != "" {
if globalEnrollSecret != config.Packaging.GlobalEnrollSecret {
fmt.Printf("################################################################################\n" +
"# WARNING:\n" +
"# You have provided a global enroll secret config, but there's\n" +
"# already one set up for your application.\n" +
"#\n" +
"# This is generally an error and the provided value will be\n" +
"# ignored, if you really need to configure an enroll secret please\n" +
"# remove the global enroll secret from the database manually.\n" +
"################################################################################\n")
os.Exit(1)
}
} else {
if err := ds.ApplyEnrollSecrets(cmd.Context(), nil,
[]*fleet.EnrollSecret{{Secret: config.Packaging.GlobalEnrollSecret}}); err != nil {
level.Debug(logger).Log("err", err, "msg", "failed to apply enroll secrets")
}
}
}
// Strip the Redis URI scheme if it's present. Scheme docs are at: https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
// This allows us to use Render's Redis service in render.yaml, including the free tier.
// In the future, we could support the full Redis URI if needed (including username, password, database, etc.)
@@ -1654,17 +1619,29 @@ func (n nopPusher) Push(context.Context, []string) (map[string]*push.Response, e
return nil, nil
}
func createTestBucketForInstallers(config *configpkg.FleetConfig, logger log.Logger) {
store, err := s3.NewSoftwareInstallerStore(config.S3)
func createTestBuckets(config *configpkg.FleetConfig, logger log.Logger) {
softwareInstallerStore, err := s3.NewSoftwareInstallerStore(config.S3)
if err != nil {
initFatal(err, "initializing S3 software installer store")
}
if err := store.CreateTestBucket(config.S3.SoftwareInstallersBucket); err != nil {
if err := softwareInstallerStore.CreateTestBucket(context.Background(), config.S3.SoftwareInstallersBucket); err != nil {
// Don't panic, allow devs to run Fleet without minio/S3 dependency.
level.Info(logger).Log(
"err", err,
"msg", "failed to create test bucket",
"msg", "failed to create test software installer bucket",
"name", config.S3.SoftwareInstallersBucket,
)
}
carveStore, err := s3.NewCarveStore(config.S3, nil)
if err != nil {
initFatal(err, "initializing S3 carve store")
}
if err := carveStore.CreateTestBucket(context.Background(), config.S3.CarvesBucket); err != nil {
// Don't panic, allow devs to run Fleet without minio/S3 dependency.
level.Info(logger).Log(
"err", err,
"msg", "failed to create test carve bucket",
"name", config.S3.CarvesBucket,
)
}
}