From d4169908292e574a22701fe01b1ac5831c6b6c76 Mon Sep 17 00:00:00 2001 From: Mark Armendariz Date: Thu, 14 Jun 2018 13:58:57 -0500 Subject: [PATCH] Allow AWS-SDK to handle gathering credentials. This change enables ec2 instance assumed roles, environment variables, and shared configs as is standard for the aws-sdk. --- cmd/tusd/cli/composer.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/tusd/cli/composer.go b/cmd/tusd/cli/composer.go index b35cc1e..0113275 100644 --- a/cmd/tusd/cli/composer.go +++ b/cmd/tusd/cli/composer.go @@ -11,7 +11,6 @@ import ( "github.com/tus/tusd/gcsstore" "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" ) @@ -33,10 +32,9 @@ func CreateComposer() { s3Config = s3Config.WithEndpoint(Flags.S3Endpoint).WithS3ForcePathStyle(true) } - // Derive credentials from AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID and - // AWS_REGION environment variables. - s3Config = s3Config.WithCredentials(credentials.NewEnvCredentials()) - store := s3store.New(Flags.S3Bucket, s3.New(session.New(), s3Config)) + // Derive credentials from default credential chain (env, shared, ec2 instance role) + // as per https://github.com/aws/aws-sdk-go#configuring-credentials + store := s3store.New(Flags.S3Bucket, s3.New(session.Must(session.NewSession()), s3Config)) store.UseIn(Composer) locker := memorylocker.New()