Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit f4ca46b

Browse files
committed
refactor to getOrElse of client, instead of endpoint
1 parent 47aef4d commit f4ca46b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/main/scala/com/audienceproject/spark/dynamodb/connector/DynamoConnector.scala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,19 @@ private[dynamodb] trait DynamoConnector {
7575
**/
7676
private def getCredentials(chosenRegion: String, roleArn: Option[String]) = {
7777
roleArn.map(arn => {
78-
val stsEndpoint = Option(System.getProperty("aws.sts.endpoint")).getOrElse("https://sts.amazonaws.com")
79-
val stsClient = AWSSecurityTokenServiceClientBuilder
80-
.standard()
81-
.withCredentials(new DefaultAWSCredentialsProviderChain)
82-
.withRegion(chosenRegion)
83-
.withEndpointConfiguration(new EndpointConfiguration(stsEndpoint, chosenRegion))
84-
.build()
78+
val stsClient = Option(System.getProperty("aws.sts.endpoint")).map(endpoint => {
79+
AWSSecurityTokenServiceClientBuilder
80+
.standard()
81+
.withCredentials(new DefaultAWSCredentialsProviderChain)
82+
.withEndpointConfiguration(new EndpointConfiguration(endpoint, chosenRegion))
83+
.build()
84+
}).getOrElse(
85+
AWSSecurityTokenServiceClientBuilder
86+
.standard()
87+
.withCredentials(new DefaultAWSCredentialsProviderChain)
88+
.withRegion(chosenRegion)
89+
.build()
90+
)
8591
val assumeRoleResult = stsClient.assumeRole(
8692
new AssumeRoleRequest()
8793
.withRoleSessionName("DynamoDBAssumed")

0 commit comments

Comments
 (0)