Ciris Ciris

http4s-aws

The ciris-http4s-aws module provides a way to read decrypted values from the AWS Systems Manager (SSM) Parameter Store using the http4s-aws library.

Getting Started

To get started with sbt, add the following line to your build.sbt file.

libraryDependencies += "is.cir" %% "ciris-http4s-aws" % "3.15.2"

If you are using Scala.js or Scala Native, make sure to replace %% with %%% above.

Usage

Following is an example of how parameter values can be retrieved. Note parameter values are wrapped in Secret by default since they are usually sensitive.

import cats.effect.IO
import cats.effect.IOApp
import ciris._
import ciris.http4s.aws.AwsSsmParameters
import com.magine.aws.Region
import com.magine.http4s.aws.CredentialsProvider
import org.http4s.ember.client.EmberClientBuilder

object Main extends IOApp.Simple {
  case class Config(username: String, password: Secret[String])

  object Config {
    def fromParameters(parameters: AwsSsmParameters[IO]): IO[Config] =
      (
        env("USERNAME"),
        parameters("password")
      ).parMapN(apply).load[IO]
  }

  override def run: IO[Unit] =
    EmberClientBuilder.default[IO].build.use { client =>
      CredentialsProvider.default(client).use { provider =>
        val parameters = AwsSsmParameters(client, provider, Region.EU_WEST_1)
        Config.fromParameters(parameters).flatMap(IO.println)
      }
    }
}