Giter VIP home page Giter VIP logo

scala-aws-params-reader's Introduction

Scala AWS Params Reader

Build Status Maven Central

What?

A library that lets you read data from AWS' EC2 Systems Manager Parameter Store in a Scala-friendly way. It supports reading data in AWS' three formats - String, StringList, and SecureString - implicitly into Scala types.

Huh?

Example

  
package io.policarp.scala

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClientBuilder
import io.policarp.scala.aws.params.reader.ParamReader
import io.policarp.scala.aws.params.reader.ListWriter._

object Test extends App {

  val client = AWSSimpleSystemsManagementClientBuilder.standard().withCredentials(new DefaultAWSCredentialsProviderChain()).build()
  val params = ParamReader(client)
  
  println(params.read[Long]("length"))
  // Right(42)
  
  println(params.readList[Long]("length"))
  // Left(InvalidParam(length)) because 'length' is actually a single parameter
  
  println(params.readList[String]("names"))
  // Right(List(Grayson,Jemma)))
  
  println(params.readList[String]("emails", listSeparator = Semicolon))
  // Right(List([email protected],[email protected])))  
  
  println(params.readSecure[String]("mysecret"))
  // Right(hunter2), where data is decrypted using Amazon's Key Management Service if your credentials allow for it
  
  println(params.readSecure[String]("yoursecret"))
  // Left(InvalidParam(yoursecret)) because 'yoursecret' does not exist OR your credentials don't allow for reading
}

Other Types?

Simply provide an implementation of the trait ValueWriter. It's basically:

  • String => ParamResult[A],
  • where ParamResult is an alias to Either[InvalidParam[A], A], and
  • InvalidParam is simply a case class wrapping the name of the invalid parameter.

scala-aws-params-reader's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.