From babab4d5a6ef432fafb6e7c4e2434b51f886a389 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Thu, 25 Jul 2024 11:53:51 -0500 Subject: [PATCH] Update AWS/S3 config --- archives/config.go | 26 +++++++++++--------------- archives/s3.go | 6 ++---- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/archives/config.go b/archives/config.go index 596b56e..e76ded4 100644 --- a/archives/config.go +++ b/archives/config.go @@ -8,14 +8,12 @@ type Config struct { LogLevel string `help:"the log level, one of error, warn, info, debug"` SentryDSN string `help:"the sentry configuration to log errors to, if any"` - S3Endpoint string `help:"the S3 endpoint we will write archives to"` - S3Region string `help:"the S3 region we will write archives to"` - S3Bucket string `help:"the S3 bucket we will write archives to"` - S3DisableSSL bool `help:"whether we disable SSL when accessing S3. Should always be set to False unless you're hosting an S3 compatible service within a secure internal network"` - S3ForcePathStyle bool `help:"whether we force S3 path style. Should generally need to default to False unless you're hosting an S3 compatible service"` + AWSAccessKeyID string `help:"access key ID to use for AWS services"` + AWSSecretAccessKey string `help:"secret access key to use for AWS services"` + AWSRegion string `help:"region to use for AWS services, e.g. us-east-1"` - AWSAccessKeyID string `help:"the access key id to use when authenticating S3"` - AWSSecretAccessKey string `help:"the secret access key id to use when authenticating S3"` + S3Endpoint string `help:"the S3 endpoint we will write archives to"` + S3Bucket string `help:"the S3 bucket we will write archives to"` TempDir string `help:"directory where temporary archive files are written"` KeepFiles bool `help:"whether we should keep local archive files after upload (default false)"` @@ -39,17 +37,14 @@ func NewDefaultConfig() *Config { hostname, _ := os.Hostname() config := Config{ - DB: "postgres://localhost/archiver_test?sslmode=disable", - LogLevel: "info", - - S3Endpoint: "https://s3.amazonaws.com", - S3Region: "us-east-1", - S3Bucket: "dl-archiver-test", - S3DisableSSL: false, - S3ForcePathStyle: false, + DB: "postgres://localhost/archiver_test?sslmode=disable", AWSAccessKeyID: "", AWSSecretAccessKey: "", + AWSRegion: "us-east-1", + + S3Endpoint: "https://s3.amazonaws.com", + S3Bucket: "dl-archiver-test", TempDir: "/tmp", KeepFiles: false, @@ -64,6 +59,7 @@ func NewDefaultConfig() *Config { Once: false, InstanceName: hostname, + LogLevel: "info", } return &config diff --git a/archives/s3.go b/archives/s3.go index 17bd698..b7aa94d 100644 --- a/archives/s3.go +++ b/archives/s3.go @@ -31,10 +31,8 @@ const chunkSizeBytes = 1e9 // 1GB // NewS3Client creates a new s3 client from the passed in config, testing it as necessary func NewS3Client(config *Config) (s3iface.S3API, error) { s3config := &aws.Config{ - Endpoint: aws.String(config.S3Endpoint), - Region: aws.String(config.S3Region), - DisableSSL: aws.Bool(config.S3DisableSSL), - S3ForcePathStyle: aws.Bool(config.S3ForcePathStyle), + Region: aws.String(config.AWSRegion), + Endpoint: aws.String(config.S3Endpoint), } if config.AWSAccessKeyID != "" { s3config.Credentials = credentials.NewStaticCredentials(config.AWSAccessKeyID, config.AWSSecretAccessKey, "")