-
Notifications
You must be signed in to change notification settings - Fork 428
feat(parameters): Configure max_age and decrypt parameters via environment variables #2088
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
feat(parameters): Configure max_age and decrypt parameters via environment variables #2088
Conversation
@@ -547,6 +547,44 @@ def test_ssm_provider_get_with_custom_client(mock_name, mock_value, mock_version | |||
stubber.deactivate() | |||
|
|||
|
|||
def test_ssm_provider_get_with_decrypt_environment_variable(monkeypatch, mock_name, mock_value, mock_version, config): |
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.
missing test for max_age
env var?
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.
Hei @heitorlessa, yes! It was missing and refactored the code adding a specific function to resolve the max_age and testing it. I tried to use the function resolve_env_var_choice
but looks like that mypy doesn't like overload with very similar types like float
and int
.
@rubenfonseca can you review this PR, please?! |
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.
Great job! It's a little bit tedious because the same logic is present in multiple places. I left some suggestions for improvement.
Thank you for this super review, Ruben! I really liked it! I addressed all feedback and let me know if I need to change something else. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #2088 +/- ##
========================================
Coverage 97.47% 97.48%
========================================
Files 147 147
Lines 6809 6835 +26
Branches 483 483
========================================
+ Hits 6637 6663 +26
Misses 136 136
Partials 36 36
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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.
Just a small thing...
| **POWERTOOLS_PARAMETERS_MAX_AGE** | Adjust how long values are kept in cache (in seconds) | [Parameters](./utilities/parameters/#adjusting-cache-ttl) | `5` | | ||
| **POWERTOOLS_PARAMETERS_SSM_DECRYPT** | Sets whether to decrypt or not values retrieved from AWS SSM Parameters Store | [Parameters](./utilities/parameters/#ssmprovider) | `false` | |
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.
I think the environment variable names need to be updated too
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.
No no Ruben, we don't need to. In the documentation is the name of the environment variable that will be configured in Lambda, what we changed was the constant in the constant.py file.
We put the constants to make easy the replication of the same value throughout the project's code.
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.
I need more coffee
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.
LGTM!
Issue number: #2041
Summary
Changes
In this PR we changed the utility parameter code to accept environment variables to configure the default TTL and the
decrypt
parameter.User experience
Before this PR the customer had to inform the
max_age
parameter every time they wanted a standard TTL different than 5 seconds (default value). If the user had retrieved dozens/hundreds of parameters, this made the developer's experience bad. This PR creates an environment variable calledPOWERTOOLS_PARAMETERS_MAX_AGE
that accepts an integer value to be used as the default TTL.This PR also introduces a new environment variable called
POWERTOOLS_PARAMETERS_SSM_DECRYPT
. This environment variable can be used to set a default value for thedecrypt
parameter in the SSM Provider. This is extremely useful in cases where the customer needs to recover dozens/hundreds of SecureString type parameters and you need to decrypt them. If a value for this environment variable is not informed, the default valueFalse
remains.This PR aims to make the developer experience simpler. Below is a code snippet of how a Lambda template can be configured to use these environment variables.
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.