From e2a45c53c3c6312fee0bc76259a929ac5d9ac578 Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Thu, 13 Oct 2022 13:37:51 -0400 Subject: [PATCH] Automatically resolve default KinesisEndpoint This commit fixes #5 by returning `aws.EndpointNotFoundError` from the endpoint resolver when no `KinesisEndpoint` is defined, which will resolve the default AWS endpoint. This is the same process used by the DynamoDB checkpointer to resolve the default endpoint. Signed-off-by: Caleb Stewart --- clientlibrary/worker/worker.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/clientlibrary/worker/worker.go b/clientlibrary/worker/worker.go index 7807edd..624598b 100644 --- a/clientlibrary/worker/worker.go +++ b/clientlibrary/worker/worker.go @@ -160,11 +160,15 @@ func (w *Worker) initialize() error { log.Infof("Creating Kinesis client") resolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) { - return aws.Endpoint{ - PartitionID: "aws", - URL: w.kclConfig.KinesisEndpoint, - SigningRegion: w.regionName, - }, nil + if service == kinesis.ServiceID && len(w.kclConfig.KinesisEndpoint) > 0 { + return aws.Endpoint{ + PartitionID: "aws", + URL: w.kclConfig.KinesisEndpoint, + SigningRegion: w.regionName, + }, nil + } + // returning EndpointNotFoundError will allow the service to fallback to it's default resolution + return aws.Endpoint{}, &aws.EndpointNotFoundError{} }) cfg, err := awsConfig.LoadDefaultConfig(