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

Commit 6699916

Browse files
authored
Merge pull request #59 from jhulten/stsEndpoint
WIP: Fetch STS endpoint from properties
2 parents 3654d3a + 4650bbd commit 6699916

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,20 @@ private[dynamodb] trait DynamoConnector {
7575
**/
7676
private def getCredentials(chosenRegion: String, roleArn: Option[String]) = {
7777
roleArn.map(arn => {
78-
val stsClient = AWSSecurityTokenServiceClientBuilder
79-
.standard()
80-
.withCredentials(new DefaultAWSCredentialsProviderChain)
81-
.withRegion(chosenRegion)
82-
.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+
// STS without an endpoint will sign from the region, but use the global endpoint
86+
AWSSecurityTokenServiceClientBuilder
87+
.standard()
88+
.withCredentials(new DefaultAWSCredentialsProviderChain)
89+
.withRegion(chosenRegion)
90+
.build()
91+
)
8392
val assumeRoleResult = stsClient.assumeRole(
8493
new AssumeRoleRequest()
8594
.withRoleSessionName("DynamoDBAssumed")

0 commit comments

Comments
 (0)