-
Notifications
You must be signed in to change notification settings - Fork 51
Add AWS KMS decryption support for environment variables #55
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
base: master
Are you sure you want to change the base?
Conversation
This commit adds support for decrypting KMS-encrypted environment variables with the format '\!kms base64EncodedValue'. The implementation follows these key aspects: - KMS encrypted values are identified by the '\!kms ' prefix - Quoted base64-encoded values are properly decoded - KMS decryption is performed using the AWS SDK - Existing SSM parameter functionality is preserved - Comprehensive test suite added for KMS decryption - README updated with KMS usage documentation The implementation is based on requirements detailed in the CHANGES file and follows the project patterns, including lazy initialization of AWS services and respect for the -no-fail flag. The CHANGES file will be removed in a future commit once the functionality is merged. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
This commit adds detailed comments to the KMS-related tests, making the test suite more readable and easier to review. Each test now has a header comment explaining: - What the test is checking - How it relates to existing SSM tests (when applicable) - Specific behaviors being tested with bullet points These comments help reviewers understand the test coverage for the new KMS decryption functionality without having to analyze each test in detail. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for decrypting AWS KMS–encrypted environment variables. Key changes include:
- Introducing a lazy-initializing KMS client and corresponding decryption function.
- Extending the environment expansion logic and tests to properly handle KMS-encrypted values.
- Updating documentation in the README to include the new KMS parameter format.
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
main_test.go | Added tests for KMS value extraction, decryption, and error handling |
main.go | Added lazyKMSClient, decryptKmsValue implementation, and KMS processing logic |
README.md | Updated parameter format instructions to include KMS-encrypted values |
Files not reviewed (1)
- CHANGES: Language not supported
Comments suppressed due to low confidence (1)
main.go:206
- [nitpick] Consider renaming the field 'envvar' to 'envVar' to maintain consistency with common camelCase naming conventions.
type kmsVar struct {
|
||
func (c *lazyKMSClient) Decrypt(input *kms.DecryptInput) (*kms.DecryptOutput, error) { | ||
// Initialize the KMS client (and AWS session) if it hasn't been already. | ||
if c.kms == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lazy initialization of the KMS client in lazyKMSClient is not thread-safe. Consider adding synchronization (e.g., a mutex) if expandEnviron might be called concurrently.
Copilot uses AI. Check for mistakes.
This is quite different from how SSM params work, using |
This commit adds support for decrypting KMS-encrypted environment variables with the format '!kms base64EncodedValue'. The implementation follows these key aspects:
The implementation is based on requirements detailed in the CHANGES file and follows the project patterns, including lazy initialization of AWS services and respect for the -no-fail flag. The CHANGES file will be removed in a future commit once the functionality is ready to be merged.
🤖 Generated with Claude Code