Giter VIP home page Giter VIP logo

config-generator's Introduction

Config Generator

Build Status License: MIT

Description

The Config Generator service is an API which generates a configuration file based on a template and secrets. The goal is to be able to commit a configuration template without secret and store those secrets on AWS Parameter Store service. The Config Generator will retrieve those secrets to fill the template and generate the complete configuration file.

config_generator_archi

Service execution and tests are Dockerised, therefore only Docker and Docker-compose are required to run and test this service.

Authorization & environment variables

The Config generator service needs environment variables like AWS keys and region. Those variables are passed to the Docker container through different manners and become environment variables in this container.

Local API use

The 3 following variables are passed to the container thanks to the .env file:

  • AWS keys (access key & secret key)
  • AWS region

Travis CI

Travis is used as a CI. The 3 following variables are passed to the container thanks to the Travis settings panel:

  • AWS keys (access key & secret key)
  • AWS region

You can create specific AWS keys for your CI to easily revoke them if needed.

Remote API

When you deploy the Config generator service, it is better to avoid putting your AWS keys on the server. Prefer to attached an AWS role to your server instance. The following variable is passed to the container thanks to the .env file:

  • AWS region

Template format

The configuration template must follow the Python Jinja2 format (http://jinja.pocoo.org/docs/2.10/). Below a configuration template example.

REDSHIFT = {
"user": "{{ redshift_user }}",
"pwd" : "{{ redshift_pwd }}",
"host" : "{{ redshift_host }}",
"port" : "{{ redshift_port }}",
"name" : "{{ redshift_name }}"
}

DEPLOYMENT_VAR = {
"client": "client-name",
"environment": "dev"
}

In AWS Parameter Store, the secrets are stored under hierarchical paths. For instances redshift/user, redshift/pwdโ€ฆ As the Jinja2 format can not handle '/' in the variable name, you have to replace the '/' by '_' and the '-' by '__' (double underscores).

Example:

If you store a secret under the following path in the AWS Parameter Store: /foo-bar/redshift/pwd, you have to put the following key in the template: foo__bar_redshift_pwd (remark that the first '/' must be omitted).

Remark: The DEPLOYMENT_VAR variables can easily be committed as they are not secret. However all the variable under the REDSHIFT section MUST NOT be committed but stored in AWS Parameter Store.

How to run

Run the following command

./scripts/run.sh --help

How to stop

./scripts/down.sh

How to test

The container will be run in attached mode to be able to directly see the results.

./scripts/test.sh --help

How to linter

./scripts/linter.sh

CURL query examples

* curl -X POST -H "Content-Type: text/plain" --data-binary '{"key":"{{all_test_config__generator_test__key}}"}' 'localhost:8000/generate-conf'
* curl -X POST -H "Content-Type: text/plain" --data-binary @resources/conf_template_examples/json_conf_template.j2  'localhost:8000/generate-conf?key_prefix=perso/dev'
* <resources/conf_template_examples/python_conf_template.j2 curl -X POST -H "Content-Type: text/plain" --data-binary @- 'localhost:8000/generate-conf?key_prefix=perso/dev'

How to deploy

The following points are required on the machine before deploying:

  • attach a role to the machine so that it can access the Parameter Store.
  • attach a security group to the machine to whitelist IPs. Otherwise, the API will be opened to the world and all your Parameter Store secrets reachable by anyone. Authorize only HTTPS connection.

Currently, the following deploy script works only for an instance with the following Amazon AMI : ami-66506c1c

./scripts/deploy.sh --help

config-generator's People

Contributors

christophecluizel avatar

Watchers

James Cloos 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.