configraun


License

License

Categories

Categories

config Application Layer Libs Configuration
GroupId

GroupId

com.gu
ArtifactId

ArtifactId

configraun_2.12
Last Version

Last Version

0.3
Release Date

Release Date

Type

Type

jar
Description

Description

configraun
configraun
Project URL

Project URL

https://github.com/guardian/configraun
Project Organization

Project Organization

com.gu
Source Code Management

Source Code Management

https://github.com/guardian/configraun

Download configraun_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.gu/configraun_2.12/ -->
<dependency>
    <groupId>com.gu</groupId>
    <artifactId>configraun_2.12</artifactId>
    <version>0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.gu/configraun_2.12/
implementation 'com.gu:configraun_2.12:0.3'
// https://jarcasting.com/artifacts/com.gu/configraun_2.12/
implementation ("com.gu:configraun_2.12:0.3")
'com.gu:configraun_2.12:jar:0.3'
<dependency org="com.gu" name="configraun_2.12" rev="0.3">
  <artifact name="configraun_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gu', module='configraun_2.12', version='0.3')
)
libraryDependencies += "com.gu" % "configraun_2.12" % "0.3"
[com.gu/configraun_2.12 "0.3"]

Dependencies

compile (4)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.4
org.typelevel : cats-core_2.12 jar 1.0.1
com.amazonaws : aws-java-sdk-ssm jar 1.11.261
com.amazonaws : aws-java-sdk-ec2 jar 1.11.261

test (2)

Group / Artifact Type Version
org.scalacheck : scalacheck_2.12 jar 1.13.4
org.scalatestplus.play : scalatestplus-play_2.12 jar 3.1.2

Project Modules

There are no modules declared in this project.

Configraun

Configraun is a thin wrapper around AWS's Systems Manager Parameter Store. Parameter store allows you to manage your configuration data in one place including plain data and secure data encrypted through AWS KMS.

Using Parameter Store to store your applications configuration has a number of benefits:

  1. You can control who and what resources access specific config through IAM credentials at a granular level.
  2. You can make use of AWS KMS to encrypt information and protect the security of your keys.
  3. Any changes to configuration in Parameter Store are versioned providing an audit trail of what has changed and by whom. In fact all calls to Parameter Store may be audited via Cloudtrail.
  4. Parameter store gives you some type safety around the type of the configuration item returned to you. I.e String | Secure String | String List.
  5. Config items can be tagged.

Setup

Add the following line to your SBT build definition, and set the version number to be the latest from the releases page:

libraryDependencies += "com.gu" %% "configraun" % "x.y"

You will then need to create a new instance of the client and set the key:

  implicit val client: AWSSimpleSystemsManagement = AWSSimpleSystemsManagementFactory(region, profile)

  val stack: String = "STACK"
  val stage: Stage = Stage.PROD
  val app: String = "APP"

  val config = Configraun.loadConfig(stack, app, stage)

Or, for an EC2 instance with appropriate IAM policies (see below):

  implicit val client: AWSSimpleSystemsManagement = AWSSimpleSystemsManagementFactory(region, profile)

  val config = Configraun.loadConfig()

Usage

Each of the get methods returns an Either[ConfigraunError, T], designed to be traversed within a for comprehension.

config.getAsString("/mydomain/mykey")

or

config.getAsList("/mydomain/mykey")

Key Format

Configraun expects that any parameters are keyed with a parameter hierarchy format. The hierarchy can have a maximum of 5 levels and must begin with /$stack/$app/$stage.

/$stack/$app/$stage/key

or

/$stack/$app/$stage/domain/key

e.g.

/content-api/porter/PROD/aws/region

Key Value Creation

Keys can be created from the command line using the following:

aws --region $region --profile $profile ssm put-parameter --name '/mystack/myapp/PROD/mydomain/mykey' --value 'myvalue' --type String

IAM Policies

Instances will need to have Describe Tags permission in a policy in their instance role, or via some other form of credentials provider:

    "Effect": "Allow",
    "Action": "ec2:DescribeTags",
    "Resource": "*"
com.gu

The Guardian

The source code of the world's leading liberal voice

Versions

Version
0.3
0.2
0.1