Skip to content

Commit

Permalink
Remove alpakka s3 dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
dantb committed Apr 8, 2024
1 parent 914877c commit 7aa18fc
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 94 deletions.
7 changes: 0 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ lazy val akkaTestKit = "com.typesafe.akka" %% "akka
lazy val akkaTestKitTyped = "com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion
lazy val alpakkaFile = "com.lightbend.akka" %% "akka-stream-alpakka-file" % alpakkaVersion
lazy val alpakkaSse = "com.lightbend.akka" %% "akka-stream-alpakka-sse" % alpakkaVersion
lazy val alpakkaS3 = "com.lightbend.akka" %% "akka-stream-alpakka-s3" % alpakkaVersion
lazy val apacheCompress = "org.apache.commons" % "commons-compress" % apacheCompressVersion
lazy val apacheIO = "commons-io" % "commons-io" % apacheIOVersion
lazy val awsSdk = "software.amazon.awssdk" % "s3" % awsSdkVersion
Expand Down Expand Up @@ -576,12 +575,6 @@ lazy val storagePlugin = project
name := "delta-storage-plugin",
moduleName := "delta-storage-plugin",
libraryDependencies ++= Seq(
alpakkaS3 excludeAll (
ExclusionRule(organization = "com.typesafe.akka", name = "akka-stream_2.13"),
ExclusionRule(organization = "com.typesafe.akka", name = "akka-http_2.13"),
ExclusionRule(organization = "com.typesafe.akka", name = "akka-http-xml_2.13"),
ExclusionRule(organization = "org.slf4j", name = "slf4j-api")
),
kamonAkkaHttp % Provided,
akkaSlf4j % Test,
akkaTestKitTyped % Test,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model

import akka.http.scaladsl.model.Uri
import akka.stream.alpakka.s3
import akka.stream.alpakka.s3.{ApiVersion, MemoryBufferType}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.Digest
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.StoragesConfig.StorageTypeConfig
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.JsonLdContext.keywords
import ch.epfl.bluebrain.nexus.delta.sdk.implicits._
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.model.Permission
Expand All @@ -13,9 +10,7 @@ import io.circe.generic.extras.Configuration
import io.circe.generic.extras.semiauto.{deriveConfiguredCodec, deriveConfiguredEncoder}
import io.circe.syntax._
import io.circe.{Codec, Decoder, Encoder}
import software.amazon.awssdk.auth.credentials.{AnonymousCredentialsProvider, AwsBasicCredentials, StaticCredentialsProvider}
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.regions.providers.AwsRegionProvider

import java.io.File
import java.nio.file.Path
Expand Down Expand Up @@ -146,38 +141,6 @@ object StorageValue {

override val tpe: StorageType = StorageType.S3Storage
override val capacity: Option[Long] = None

def address(bucket: String): Uri =
endpoint match {
case Some(host) if host.scheme.trim.isEmpty => Uri(s"https://$bucket.$host")
case Some(e) => e.withHost(s"$bucket.${e.authority.host}")
case None => region.fold(s"https://$bucket.s3.amazonaws.com")(r => s"https://$bucket.s3.$r.amazonaws.com")
}

/**
* @return
* these settings converted to an instance of [[akka.stream.alpakka.s3.S3Settings]]
*/
def alpakkaSettings(config: StorageTypeConfig): s3.S3Settings = {

val keys = for {
cfg <- config.amazon
} yield cfg.defaultAccessKey.value -> cfg.defaultSecretKey.value

val credsProvider = keys match {
case Some((accessKey, secretKey)) =>
StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, secretKey))
case _ =>
StaticCredentialsProvider.create(AnonymousCredentialsProvider.create().resolveCredentials())
}

val regionProvider: AwsRegionProvider = new AwsRegionProvider {
val getRegion: Region = region.getOrElse(Region.US_EAST_1)
}

s3.S3Settings(MemoryBufferType, credsProvider, regionProvider, ApiVersion.ListBucketVersion2)
.withEndpointUrl(address(bucket).toString())
}
}

object S3StorageValue {
Expand Down

This file was deleted.

0 comments on commit 7aa18fc

Please sign in to comment.