Code Monkey home page Code Monkey logo

dbalkeyrotate's Introduction

DBAL driver for automatic retrieval of credentials through AWS secretsmanager.

This is a highly experimental POC library. Do not use in production!

This library will automatically fetch credentials from the AWS secrets manager. The secrets manager allows easy key rotating, and this library will fetch any new credentials without any changes your code or reboots of your instance, pod or container.

Because key retrieval is a time-consuming operation, the fetched credentials are stored inside a cache. The driver will first try the cached credentials and only when these credentials fail to connect, it will fetch credentials from the secrets manager. After a specific amount of attempt, the driver will fail if no correct credential can be retrieved.

If you have set a local username and password and no cached credentials are present, these local credentials will be tried first. If you do not need this behaviour, you can leave the username and password empty.

Usage

$connectionParams = [
    'dbname' => 'mysql',
    'user' => '',
    'password' => '',              
    'host' => 'mydb.1234.eu-west-1.rds.amazonaws.com',
    'driverClass' => KeyRotate\Driver::class,
    'driverOptions' => [
        'cache' => new PhpFileCache(sys_get_temp_dir()),
        'secretId' => /secret/database-2
        'retries' => 5,
        'awsOptions' => [],
    ]
];

The driver class needs a few options in order to work:

cache: The drivers needs an mandatory cache service in order to function. This is a class that implements Doctrine\Cache.

secretId: The actual secret that must be retrieved.

retries: The number of tries of database connection and key fetching that must be done before giving up.

awsOptions: An array of AWS options send to the AWS client. This chould consist of region, profile etc. Probably not needed when running on an ecs/ec2 instance where AWS credentials and information are automatically fetched by the AWS client.

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.