Repository navigation
Support AWS default credential chain for S3 - #433
Conversation
francescayeye
left a comment
There was a problem hiding this comment.
see my comment, thanks
|
@BOPOHA Do you intend to address the comment from @francescayeye ? |
|
@stefanbenten thanks for following up. I revisited this PR against the current codebase and updated the implementation locally. Since the original proposal, transfer.sh has migrated to AWS SDK for Go v2, which provides a comprehensive default credential chain. Based on the original review feedback, I agree that a separate The updated approach is:
This enables EC2 instance profiles, ECS task roles, EKS IRSA, standard AWS environment variables, and shared AWS configuration while remaining backward-compatible. I have also updated #431 with the current motivation and acceptance criteria. I’m preparing to replace the old implementation in this PR with the revised version. |
|
Thanks for the feedback. I implemented the requested explicit credential mode:
Validation completed successfully with go test, go vet, Helm lint, and rendered manifests for both credential modes. |
| } | ||
| } | ||
|
|
||
| func resolveS3Credentials(credentialsType, accessKey, secretKey string) (string, string, error) { |
There was a problem hiding this comment.
can you move this function to server/storage/s3.go and make it part of the storage package?
thanks :)
| } else if secretKey := c.String("aws-secret-key"); secretKey == "" { | ||
| return errors.New("secret-key not set") | ||
| } else if bucket := c.String("bucket"); bucket == "" { | ||
| accessKey, secretKey, err := resolveS3Credentials(c.String("s3-credentials-type"), c.String("aws-access-key"), c.String("aws-secret-key")) |
There was a problem hiding this comment.
also please keep the if ..., err } else if { structure of this part of cmd.go.
for extending the scope of acessKey and secretKey you can initialize them as empty variables before the first if branch.
thank you very much again
| func getAwsConfig(ctx context.Context, accessKey, secretKey string) (aws.Config, error) { | ||
| return config.LoadDefaultConfig(ctx, | ||
| config.WithCredentialsProvider(credentials.StaticCredentialsProvider{ | ||
| if (accessKey == "") != (secretKey == "") { |
There was a problem hiding this comment.
it should be fine as not breaking change behaviour, but i think there's a little hidden logic here where we hide explicit information here that the credentials type implied into the s3 storage is the legacy one. i'd pass down c.String("s3-credentials-type") to storage.NewS3Storage along with c.String("aws-access-key") and c.String("aws-secret-key"), and then deal with the logic that's in resolveS3Credentials (that will be moved to storage package anyway) directly here in getAwsConfig checking on the credentials type to be passed as new parameter and the eventual error will be bubbled up to the storage.NewS3Strorage returned error
francescayeye
left a comment
There was a problem hiding this comment.
i apologize for splitting the view in multiple sub-reviews
| t.Fatalf("retrieve credentials: %v", err) | ||
| } | ||
| if credentials.AccessKeyID != "configured-access-key" || credentials.SecretAccessKey != "configured-secret-key" || credentials.SessionToken != "" { | ||
| t.Fatalf("got credentials %q/%q, want configured static credentials", credentials.AccessKeyID, credentials.SecretAccessKey) |
There was a problem hiding this comment.
can you please reword as ""got credentials %q/%q, want configured static credentials and empty session token"? ;)
| t.Fatalf("retrieve credentials: %v", err) | ||
| } | ||
| if credentials.AccessKeyID != "environment-access-key" || credentials.SecretAccessKey != "environment-secret-key" || credentials.SessionToken != "environment-session-token" { | ||
| t.Fatalf("got credentials %q/%q, want credentials from the default chain", credentials.AccessKeyID, credentials.SecretAccessKey) |
There was a problem hiding this comment.
the same here regarding session token
francescayeye
left a comment
There was a problem hiding this comment.
i apologize for splitting the view in multiple sub-reviews
|
no problem
@francescayeye please review it and feel free to suggest any improvements |
No description provided.