Skip to content

Commit

Permalink
Allow to pass aws.Config (#16)
Browse files Browse the repository at this point in the history
* Allow to pass aws.Config

* Use credentials instead of config
  • Loading branch information
Loïc PORTE authored Aug 28, 2020
1 parent f57cd30 commit 4b025a7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion s3update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/mitchellh/ioprogress"
Expand All @@ -31,6 +32,8 @@ type Updater struct {
S3ReleaseKey string
// S3VersionKey represents the key on S3 to download the current version
S3VersionKey string
// AWSCredentials represents the config to use to connect to s3
AWSCredentials *credentials.Credentials
}

// validate ensures every required fields is correctly set. Otherwise and error is returned.
Expand Down Expand Up @@ -89,7 +92,11 @@ func runAutoUpdate(u Updater) error {
return fmt.Errorf("invalid local version")
}

svc := s3.New(session.New(), &aws.Config{Region: aws.String(u.S3Region)})
svc := s3.New(session.New(), &aws.Config{
Region: aws.String(u.S3Region),
Credentials: u.AWSCredentials,
})

resp, err := svc.GetObject(&s3.GetObjectInput{Bucket: aws.String(u.S3Bucket), Key: aws.String(u.S3VersionKey)})
if err != nil {
return err
Expand Down

0 comments on commit 4b025a7

Please sign in to comment.