Skip to content

Add a parameter resolver for EJSON wrapper#264

Merged
stevehodgkiss merged 9 commits intomasterfrom
ejson_wrapper
Aug 9, 2019
Merged

Add a parameter resolver for EJSON wrapper#264
stevehodgkiss merged 9 commits intomasterfrom
ejson_wrapper

Conversation

@stevehodgkiss
Copy link
Copy Markdown
Contributor

@stevehodgkiss stevehodgkiss commented Dec 21, 2018

An EJSON file that uses KMS can be generated with EJSON Wrapper:

ejson_wrapper generate --region ap-southeast-2 --kms-key-id [key_id] --file secrets/staging.ejson

Secrets are then added as usual with EJSON. Add the plaintext then:

ejson encrypt secrets.ejson

Set ejson_file in the stack definition to staging.ejson. Then secrets can be referenced in parameter files:

my_param:
  ejson: "my_secret"

TODO:

  • Update Readme.

Copy link
Copy Markdown
Contributor

@patrobinson patrobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and it works, minor question


def secret_path_relative_to_base
@secret_path_relative_to_base ||= File.join('secrets', ejson_file)
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two methods have no effect and are not called anywhere? When I specify ejson_file I have to use the full path (secrets/foo.ejson)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the resolver to look in secrets/ for the ejson_file

@patrobinson
Copy link
Copy Markdown
Contributor

@stevehodgkiss I've added documentation, do you want to review that for me?

Comment thread README.md Outdated

[ejson](https://github.com/Shopify/ejson) is a tool for managing asymmetrically encrypted values in JSON format. This allows you to keep secrets securely in git/Github and give anyone the ability the capability to add new secrets without requiring access to the private key.

First create the `production.ejson` file and store the secret value in it, then call `ejson encrypt secrets.ejson`. Then add the `ejson_file` argument to your stack in stack_master.yml:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we provide details about how to create this file? For example:

ejson_wrapper generate --region ap-southeast-2 --kms-key-id [key_id] --file secrets/production.ejson

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add another command to stack master to create ejson files with ejson wrapper/a kms key rather than relying on the user to know about ejson wrapper and do this manually. Thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that's a nice addition


def resolve(secret_key)
validate_ejson_file_specified
secrets = decrypt_ejson_file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevehodgkiss should we memoize secrets?

@stevehodgkiss stevehodgkiss removed the wip label Aug 5, 2019
@stevehodgkiss stevehodgkiss merged commit 4b225c8 into master Aug 9, 2019
@stevehodgkiss stevehodgkiss deleted the ejson_wrapper branch August 9, 2019 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants