Created
May 11, 2020 11:33
-
-
Save warrenronsiek/2539df3ab2a186d6b7883d2dea4952d9 to your computer and use it in GitHub Desktop.
Create amazon client with specified role
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.amazonaws.services.s3.{AmazonS3, AmazonS3ClientBuilder} | |
| import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider | |
| import com.amazonaws.regions.Regions | |
| val credsWithRole: STSAssumeRoleSessionCredentialsProvider = new STSAssumeRoleSessionCredentialsProvider | |
| .Builder("role-arn","test-session") | |
| .withStsClient(AWSSecurityTokenServiceClientBuilder.standard().withRegion(Regions.US_EAST_1).build()).build() | |
| val client: AmazonS3 = AmazonS3ClientBuilder.standard().withCredentials(credsWithRole) | |
| .withRegion(Regions.US_EAST_1).build() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment