Code Monkey home page Code Monkey logo

aws-secrets's Introduction

aws-secrets

Manage secrets on AWS instances with KMS encryption, IAM roles and S3 storage.

Synopsis

aws-secrets requires aws-cli version 1.8 or later.

Installation:

git clone -o github https://github.com/promptworks/aws-secrets
cd aws-secrets
make install
# (or just copy `bin/*` to somewhere in your PATH)

Set up AWS resources for an application named quizzo:

aws-secrets-init-resources quizzo

Make some secrets, send them to the cloud:

echo "SECRET=xyzzy" > quizzo-env
aws-secrets-send quizzo quizzo-env

Retrieve the secrets and print them to stdout:

aws-secrets-get quizzo

The last one can be run by:

  • users in the quizzo-manage-secrets group
  • programs on ec2 instances which have been started with the quizzo-secrets IAM profile

To start an EC2 instance with the quizzo-secrets IAM profile from the CLI:

aws ec2 run-instances ...--iam-instance-profile Name=quizzo-secrets

To start an ECS cluster with the quizzo IAM profile, select quizzo-secrets-instances from the Container Instance IAM Role selection on the Create Cluster screen.

Description

This repository contains a handful of scripts:

  • aws-secrets-init-resources
  • aws-secrets-send
  • aws-secrets-get
  • aws-secrets-run-in-env
  • aws-secrets-purge-resources

They can be used to set up and maintain a file containing environment variables which can then be used by an application running on an Amazon EC2 instance. They can also be used when running an application in a docker container on an EC2 instance.

aws-secrets-init-resources creates the following AWS resources:

  • A customer master key (CMK).
  • An alias for the key.
  • An S3 bucket.
  • A few roles to be used by an instance profile: one for S3 access, one for decryption with the CMK.
  • A group with access policies to get/put to S3 and encrypt/decrypt with the CMK.

aws-secrets-send takes an app name and a filename as input and uses the CMK to encrypt it, then sends it to an object in the S3 bucket.

aws-secrets-get take an app name as input, and uses it to construct the name of the S3 bucket and object. It then retrieves and decrypts the file and prints it to stdout.

If the file contains lines of the form:

X=yyyy

then exporting the output will put those variables into the current environment. i.e.

export `aws-secrets-get quizzo`

aws-secrets-run-in-env is a short script that does the above and then executes another program, with its arguments.

aws-secrets-purge-resources removes the resources associated with this app which were created by aws-secrets-init-resources.

Examples

To use this in a docker file, add a line like this:

CMD ["aws-secrets-run-in-env", "quizzo", "start-quizzo"]

where "quizzo" is the name of your app, and "start-quizzo" is the script that starts the app.

Notes

  • These scripts depend on having the AWS CLI installed. (See references below)

  • It may be necessary to explicitly set the region (e.g. using the AWS_DEFAULT_REGION environment variable).

References

aws-secrets's People

Contributors

bduggan avatar di avatar jgarber avatar

Watchers

 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.