Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
switch to DefaultAWSCredentialsProviderChain which also includes Prof…
Browse files Browse the repository at this point in the history
…ileCredentialsProvider, but also allows e.g. for AWS Instance Profile Roles and thus is more flexible and does not force developers to include credentials on their PredictionIO machines
  • Loading branch information
Chris Wewerka committed Nov 12, 2018
1 parent 4342fcd commit 43ca47e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@

package org.apache.predictionio.data.storage.s3

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
import org.apache.predictionio.data.storage.BaseStorageClient
import org.apache.predictionio.data.storage.StorageClientConfig

import com.amazonaws.auth.profile.ProfileCredentialsProvider
import com.amazonaws.client.builder.AwsClientBuilder
import com.amazonaws.services.s3.AmazonS3
import com.amazonaws.services.s3.AmazonS3ClientBuilder

import grizzled.slf4j.Logging

class StorageClient(val config: StorageClientConfig) extends BaseStorageClient
with Logging {
override val prefix = "S3"
val client: AmazonS3 = {
val builder = AmazonS3ClientBuilder.standard().withCredentials(new ProfileCredentialsProvider())
val builder = AmazonS3ClientBuilder
.standard()
.withCredentials(DefaultAWSCredentialsProviderChain.getInstance())
(config.properties.get("ENDPOINT"), config.properties.get("REGION")) match {
case (Some(endpoint), Some(region)) =>
builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region))
Expand Down

0 comments on commit 43ca47e

Please sign in to comment.