Giter VIP home page Giter VIP logo

pstore's Introduction

pstore

Build Status

pstore is a tiny utility to make usage of AWS Parameter Store an absolute breeze. Simply prefix your application launch with pstore exec <yourapp> and you're up and running - in dev or prod.

AWS ECS now has support for specifying secrets from Parameter Store directly in ECS task definitions, making pstore obsolete for some use cases.

Usage

pstore expects the AWS_REGION environment variable to be set to the region that your parameters are stored in.

exec

AWS_REGION=us-east-1 PSTORE_DBSTRING=MyDatabaseString pstore exec -- 'echo val is $DBSTRING'
val is SomeSuperSecretDbString

pstore is usable out of the box. By default it looks for environment variables with a PSTORE_ prefix. For example, PSTORE_DBSTRING=MyDatabaseString asks AWS to decrypt the parameter named MyDatabaseString and stores the decrypted value in a new environment variable named DBSTRING. If there are no envvars with the PSTORE_ prefix, it's essentially a noop - so the same command can be used in local dev and in prod.

If pstore fails to decrypt any envvars it will exit instead of launching your application.

shell

Sometimes you don't want to exec the child process directly. You want to use the decrypted values as part of a larger script. In that case you can do:

#!/bin/bash
# do some stuff ...
eval $(PSTORE_DBSTRING=MyDatabaseString pstore shell)
echo $DBSTRING # will echo out your secret string!

powershell

Same as the above, albeit for our Windows friends.

$Env:PSTORE_DBSTRING = "MyDatabaseString"
$Cmd = (pstore powershell mycompany-prod) | Out-String
Invoke-Expression $Cmd
Do-SomethingWith -DbString $DBSTRING

show

Quickly interrogate parameters for a given path or path prefix:

$ pstore show "/company/princess/lambdas"
/company/princess/lambdas/execution/env/MyDatabaseString : SomeSuperSecretDbString
/company/princess/lambdas/execution/env/NODE_ENV         : production
/company/princess/lambdas/execution/env/LOGLEVEL         : excessive

Advanced

pstore also works with tagged parameters, which can be helpful when you have a lot of parameters and don't want to enumerate them all individually. You can specify PSTORETAG_tagkey=tagval and pstore will retrieve all parameters with tagkey=tagval. pstore will expect to find an additional tag on these parameters, pstore:name=ENVVAR. pstore then sets ENVVAR=value in the environment.

The PSTORE_ and PSTORETAG_ prefixes are configurable if you want to use something else. If you want to use MYSECRETS_ as a prefix, simply invoke pstore exec --prefix MYSECRETS_ <yourapp>.

Finally, for debugging there is the pstore exec --verbose <yourapp> flag. Before launching, pstore will output what its doing to stdout, e.g.

$ pstore exec --verbose <yourapp>
✔ Decrypted MYREALSECRET︎
✗ Failed to decrypt PstoreVal (MYLAMESECRET)
ERROR: Failed to decrypt some secret values

Docker

pstore is well-suited to acting as an entrypoint for a Dockerised application. Adding it to your project is as simple as:

FROM alpine
RUN apk add --update curl
RUN curl -sL -o /usr/bin/pstore https://github.com/glassechidna/pstore/releases/download/1.5.0/pstore_linux_amd64
RUN chmod +x /usr/bin/pstore
ENTRYPOINT ["pstore", "exec", "--verbose", "--"]
CMD env

Note that https requests made require ca-certificates. Alpine does not ship them by default anymore. In the above example this package is installed because curl also needs them, but if you install without curl or your Dockerfile removes curl, you need to explicitly have RUN apk add ca-certificates. Without these you will get a runtime error x509: failed to load system roots and no roots provided.

pstore's People

Contributors

aidansteele avatar leqeta-hypr avatar srizzling avatar vertti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pstore's Issues

Parameter access with EKS service account mapped IAM role

Hi Aidan,

We use pstore to get ssm parameter values from Parameter store on few of our pods deployed on EKS. Until recently we used instance IAM profile to provide permissions pods need to get the parameter values. But now we have started using k8s service account mapped IAM roles to provide the permissions pods need. I removed SSM parameter access permissions from instance profile and mapped an IAM role with sufficient permissions to the pod service account. I noticed the pods that use pstore tool are failing with error 'Instance profile doesn't have permission to fetch the ssm param'. Does pstore use instance profile by default? Please let me know if this is supported by pstore.

Thanks,
Namesh

Better error messages

  • No request id shown if there was a connectivity error
  • Failed connections should mention things like "if there's a proxy, be sure to set https_proxy and no_proxy for metadata" etc

Add Windows support

syscall.Exec returns EWINDOWS on Windows. Do it another way. Will need to ask Windows gurus about special considerations re: signals, message pumps, etc.

Experience running in ECS containers?

Can I ask if you've tried running pstore within an ECS container? I'm really not sure why mine's not working, was wondering if it was a known problem.

I'm running a container on an Amazon ECS-optimized instance. My container has a task role to give it access to my SSM keys. Within the container, curl 169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI gives the correct role.

Additionally, I can fetch the keys successfully using the aws-cli tool:

aws ssm get-parameters --region=eu-west-1 --names imogen.license --with-decryption

However, pstore seems to be unable to fetch the same key:

$ AWS_REGION=eu-west-1 PSTORE_LICENSE=imogen.license pstore exec --verbose -- /bin/bash -c 'echo val is $LICENSE'
✗ Failed to decrypt imogen.license=LICENSE (request ID: 5181b60f-be6c-11e7-af11-63590df9a94d)
ERROR: Failed to decrypt some secret values

It doesn't seem to make a difference if the parameter is encrypted or not. Can I do anything to narrow the problem down?

Decryption via PSTOREPATH_

Hey man... loving this work. Awesome implementation of parameter store interaction and perfect for setting up sensitive runtime config. Noticed the path option isn't decrypting and added a possible fix although haven't tested yet... sorry. Hope this helps and thanks for the fantastic work!!

Add version parameter

I'd love to see the addition of a --version or -v flag to the command line which outputs, preferably, the current version of the binary and possibly the commit tag associated with the release.

It will make version management of the binaries in complex development environments and container builds a lot easier, as well as give users a possibility to provide information when running into issues they'd like to report back on.

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.