Skip to content

Commit

Permalink
Update AWS/S3 config
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jul 25, 2024
1 parent 7eea020 commit babab4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
26 changes: 11 additions & 15 deletions archives/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)"`
Expand All @@ -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,
Expand All @@ -64,6 +59,7 @@ func NewDefaultConfig() *Config {
Once: false,

InstanceName: hostname,
LogLevel: "info",
}

return &config
Expand Down
6 changes: 2 additions & 4 deletions archives/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand Down

0 comments on commit babab4d

Please sign in to comment.