neurodyne / zio-aws-s3

ZIO integration with AWS S3 SDK

Version Matrix

Maven

zio-aws-s3

Welcome to ZIO AWS S3 !

This project aims to ease ZIO integration with AWS S3, providing a clean, simple and efficient API.

Features

Integration

"io.github.neurodyne" %% "zio-aws-s3" % version
ivy"io.github.neurodyne::zio-aws-s3:$version"

Getting Started

// build.sbt
libraryDependencies ++= Seq(
  "dev.zio" %% "zio" % "1.0.0-RC20",
  "io.github.neurodyne" %% "zio-aws-s3" % "0.4.13"
)

// build.sc
def ivyDeps = Agg(
  ivy"dev.zio::zio:1.0.0-RC20",
  ivy"io.github.neurodyne::zio-aws-s3:0.4.13"
)
import zio._
import zio_aws_s3.{ AwsAgent, AwsApp }
import software.amazon.awssdk.regions.Region

import scala.jdk.CollectionConverters._

object Main extends App {
  val BUCKET = "<your-bucket>"

  val awsEnv = AwsApp.ExtDeps.live >>> AwsApp.AwsLink.live

  val app = for {
    s3 <- AwsAgent.createClient(Region.US_WEST_2)

    response <- AwsApp.listBuckets.provideLayer(awsEnv).provide(s3)

    buckets <- Task(response.buckets.asScala.toList.map(_.name))

    _ = buckets.foreach(println)
  } yield ()

  def run(args: List[String]): ZIO[ZEnv, Nothing, Int] = {
    app.fold(_ => 1, _ => 0)
  }
}

API Reference

  1. See [API Reference]

Running Tests

All the tests are integration tests. That is, they make real API requests to S3. As such, you'll need to make sure you have variables set to a bucket and object that you can access and manipulate.

Here are all the things you will need to change to run the tests locally:

  1. Export AWS_BUCKET as an environment variable in the window you will be running the tests.
  2. Change the region in Setup.scala to your region.
  3. Change the prefix and key in AwsSpec.scala to a prefix/key in your bucket.

Then:

> sbt
> testOnly *BuckSpec

Commercial integration and support services are available

Please open an issue with your commercial integration request

Resources

  1. AWS SDK Java v2 [Documentation]
  2. AWS SDK Java v2 [Repo]