Skip to content

Commit c702346

Browse files
funny-falcontejasmanohar
authored andcommitted
Allow to pass region as parameter in connection string (#7)
* Allow to pass region as parameter in connection string * add documentation for 'region' parameter in connection string.
1 parent 38ce6dc commit c702346

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

driver.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"sync"
1010
"time"
1111

12+
"github.com/aws/aws-sdk-go/aws"
1213
"github.com/aws/aws-sdk-go/aws/session"
1314
"github.com/aws/aws-sdk-go/service/athena"
1415
)
@@ -54,6 +55,9 @@ func init() {
5455
// which the driver will poll for results. It should be a time/Duration.String().
5556
// A completely arbitrary default of "5s" was chosen.
5657
//
58+
// - `region` (optional)
59+
// Override AWS region. Useful if it is not set with environment variable.
60+
//
5761
// Credentials must be accessible via the SDK's Default Credential Provider Chain.
5862
// For more advanced AWS credentials/session/config management, please supply
5963
// a custom AWS session directly via `athena.Open()`.
@@ -123,7 +127,11 @@ func configFromConnectionString(connStr string) (*Config, error) {
123127

124128
var cfg Config
125129

126-
cfg.Session, err = session.NewSession()
130+
var acfg []*aws.Config
131+
if region := args.Get("region"); region != "" {
132+
acfg = append(acfg, &aws.Config{Region: aws.String(region)})
133+
}
134+
cfg.Session, err = session.NewSession(acfg...)
127135
if err != nil {
128136
return nil, err
129137
}

0 commit comments

Comments
 (0)