-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed an error when placing objects in a different bucket than the region running the Lambda function #18
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
func (r *Router) getS3BucketRegion(ctx context.Context, bucket string) (string, error) { | ||
if region, ok := r.s3bucketRegion[bucket]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
putToS3
might be called from multiple goroutines in parallel, so we have to guard concurrent map access. Please consider using sync.Mutex
or another lock mechanism.
log.Println("[info] completed put to", dest.String()) | ||
} | ||
return err | ||
} | ||
|
||
func (r *Router) defaultS3Client() *s3.Client { | ||
return r.s3[r.awsConf.Region] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also map access to read, which should be guarded by a mutex.
Co-authored-by: FUJIWARA Shunichiro <[email protected]>
missed on 189c119
Fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
If the region running Lambda function is not same to destination S3 bucket, AWS API returns errors like berow:
To avoid this, added codes to init AWS API Client for each destination.
before (v0.1.1)
after