From e4477572e8aa8105c46e5ff642d710f7310f345d Mon Sep 17 00:00:00 2001 From: Tyler Britten <1933680+tybritten@users.noreply.github.com> Date: Tue, 2 Aug 2022 11:46:16 -0400 Subject: [PATCH] Allow AWS Cred Chain --- archives/config.go | 4 ++-- archives/s3.go | 9 ++++++--- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/archives/config.go b/archives/config.go index c1f4a1c..ad001d2 100644 --- a/archives/config.go +++ b/archives/config.go @@ -47,8 +47,8 @@ func NewDefaultConfig() *Config { S3DisableSSL: false, S3ForcePathStyle: false, - AWSAccessKeyID: "missing_aws_access_key_id", - AWSSecretAccessKey: "missing_aws_secret_access_key", + AWSAccessKeyID: "", + AWSSecretAccessKey: "", TempDir: "/tmp", KeepFiles: false, diff --git a/archives/s3.go b/archives/s3.go index 02c8d48..cc55d65 100644 --- a/archives/s3.go +++ b/archives/s3.go @@ -24,13 +24,16 @@ var s3BucketURL = "https://%s.s3.amazonaws.com%s" // NewS3Client creates a new s3 client from the passed in config, testing it as necessary func NewS3Client(config *Config) (s3iface.S3API, error) { - s3Session, err := session.NewSession(&aws.Config{ - Credentials: credentials.NewStaticCredentials(config.AWSAccessKeyID, config.AWSSecretAccessKey, ""), + s3config := &aws.Config{ Endpoint: aws.String(config.S3Endpoint), Region: aws.String(config.S3Region), DisableSSL: aws.Bool(config.S3DisableSSL), S3ForcePathStyle: aws.Bool(config.S3ForcePathStyle), - }) + } + if config.AWSAccessKeyID != "" { + s3config.Credentials = credentials.NewStaticCredentials(config.AWSAccessKeyID, config.AWSSecretAccessKey, "") + } + s3Session, err := session.NewSession(s3config) if err != nil { return nil, err } diff --git a/go.mod b/go.mod index bd08b0f..2f46371 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/jmoiron/sqlx v1.3.5 github.com/lib/pq v1.10.6 github.com/nyaruka/ezconf v0.2.1 - github.com/nyaruka/gocommon v1.22.4 + github.com/nyaruka/gocommon v1.24.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.8.0 diff --git a/go.sum b/go.sum index f04c336..efe7470 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,8 @@ github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8= github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= github.com/nyaruka/ezconf v0.2.1 h1:TDXWoqjqYya1uhou1mAJZg7rgFYL98EB0Tb3+BWtUh0= github.com/nyaruka/ezconf v0.2.1/go.mod h1:ey182kYkw2MIi4XiWe1FR/mzI33WCmTWuceDYYxgnQw= -github.com/nyaruka/gocommon v1.22.4 h1:NCAItnrQbXlipDeOszoYbjXEFa1J1M+alS8VSk/uero= -github.com/nyaruka/gocommon v1.22.4/go.mod h1:g6/d9drZXDUrtRSPe2Kf8lTUS+baHt/0G0dwHq3qeIU= +github.com/nyaruka/gocommon v1.24.0 h1:zfluRa4h+Ms3hmed2vPov+PR/vWxtrTgBUEONRuuiIQ= +github.com/nyaruka/gocommon v1.24.0/go.mod h1:g6/d9drZXDUrtRSPe2Kf8lTUS+baHt/0G0dwHq3qeIU= github.com/nyaruka/librato v1.0.0 h1:Vznj9WCeC1yZXbBYyYp40KnbmXLbEkjKmHesV/v2SR0= github.com/nyaruka/librato v1.0.0/go.mod h1:pkRNLFhFurOz0QqBz6/DuTFhHHxAubWxs4Jx+J7yUgg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=