Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Keystore – option to read data encryption key from an env var (instead of file) #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ram-nadella
Copy link

@ram-nadella ram-nadella commented Feb 13, 2021

Issue # (if available)

#149

Description of changes

AWS Keystore uses KMS for the key encryption key and data encryption key is local to the code / runtime. This change adds the option to provide the data encryption using an environment variable with existing file option as a fallback. This would allow for use cases where you don't want to put the keys on the filesystem

NOTE: this is still a work in progress; pushed a commit early to show potential approach, the data needed to build the env key is not available in the read method. Thinking adding a config key might be the way to go here. Also need to add tests.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

AWS Keystore uses KMS for the key encryption key and data encryption key
is local to the code / runtime. This change adds the option to provide
the data encryption using environment varibles (in addition to files) to
allow for use cases where you don't want to put the keys on the
filesystem
@reidmorrison
Copy link
Owner

reidmorrison commented Aug 15, 2021

We have switched to using Secret Config instead of using a config file at all.
The data encryption keys are stored in the AWS Parameter Store and are encrypted using KMS.

The following code was added to config/application.rb to support local testing vs deployed code:

    unless Rails.env.development? || Rails.env.test?
      config.secret_config.use :ssm, key_alias: "customer-kms", path: "/#{ENV['STACK_NAME']}/web"
    end

@reidmorrison
Copy link
Owner

@ram-nadella have you had a chance to see if the Secret Config approach above better suites you needs in the AWS environment? We are happy we made the switch since it is much easier to manage now, and we now retrieve all application settings from Secret Config at startup. If using Docker Images, Secret Config is a must have for externalizing configuration.

@ram-nadella
Copy link
Author

@reidmorrison thanks for following up on this.

We're using SecretsManager on AWS (provides a few nice things like access audit logs, secret rotation etc.) Ideally, we'd init symmetric-encryption on load with a key from secrets manager, was thinking of ENV var as a more generalized way for others to reuse this method.

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.

2 participants