FS2 AWS Utilities
Projects including this library will also need to explicitly include the AWS SDK libraries they will rely on, to avoid inadvertently importing more libraries than are required.
This library is essentially Dwolla’s scala-aws-utils ported to fs2.
"com.dwolla" %% "fs2-aws" % "2.0.0"
Non-AWS-specific utilities are published separately for the JVM and Scala.js.
"com.dwolla" %% "fs2-utils" % "2.0.0"
"com.dwolla" %%% "fs2-utils" % "2.0.0"
All examples assume the following imports.
import cats.effect._ import com.amazonaws.services.cloudformation._ import com.amazonaws.services.cloudformation.model._
Paginate over an AWS resource
Given an AWS Async client and a base request builder, obtain an fs2
Stream of the resource.
val client: AmazonCloudFormationAsync = ??? val requestFactory = () ⇒ new DescribeStackEventsRequest() val x: Stream[IO, StackEvent] = requestFactory.fetchAll[IO](client.describeStackEventsAsync)(_.getStackEvents.asScala)
Note that settings can be changed inside the
() => Request function. The pagination logic takes the result of calling the function and sets the next page token on the request before handing it to the AWS Async client.
Retrieve an AWS resource
Given an AWS Async client and a request, obtain a cats-effect
Async that will contain the resource upon completion.
For paginated resources, this retrieves the first page. For non-paginated resources, this retrieves the entire resource.
val client: AmazonCloudFormationAsync = ??? val req = new DescribeStackEventsRequest() val x: IO[DescribeStackEventsResult] = req.executeVia[IO](client.describeStackEventsAsync)