Description
Is this related to an existing feature request or issue?
Which Powertools for AWS Lambda (Python) utility does this relate to?
Parameters
Summary
There are many use cases where the Parameter store is used with PowerTools everywhere. It's an invaluable tool for getting SSM Parameters and the ability to cache them has been fantastic to save time going back to SSM repeatedly. There is one thing that I find to be missing and that is the ability to put SSM parameters as well as the ability to write secrets back to Secrets Manager as well.
Use case
Parameter Store
Adding the function to put_parameter
back to SSM with the ability to make sure it's also being cached when it is written back. This should also include the ability to have the overwrite
flag as optional. When parameters are being over-written to Parameter store you need to set the overwrite flag because it's set to false
by default.
Secrets Manager
Would also like to add the ability to write values to the Secrets Store as well. There are many uses, especially in Lambda where I need to cache/write something secret, (JWT Tokens for example) so that multiple Lambda's are not all going back to get a new token every time a new one is invoked. "Caching" that value in Secret Manager (or as a SecureString in Parameter Store) is a good use case for this.
Proposal
Tasks
- Define the API for creating/updating secrets/parameters
- Define whether we will cache
- Create a PoC to prove the experience.
Parameter Store
For getting values in SSM, Powertools is using get_parameter
. I am proposing that we add a new option for put_paramter
for the ability to write a value back to a parameter in SSM.
By default, you have to specify the overwrite=true
to write a value to a parameter if there is already an existing value. I am wondering if this should be set to true
by default or if we should be setting that on every time you need to overwrite a value. When it is written to Parameter store the put_parameter
will return a response that includes the new version of the parameter. So in theory there is already the ability to go back versions and it will hold up to 100 of the previous versions before it will start rolling over the oldest.
Secret Manager
Adding the ability to create, set, and update secrets in Secret Manager.
I think create()
makes sense for creating a new one.
set()
might be translated into boto3 as put_secret_value
. The newly created secret would become the latest version of the secret.
update()
sounds very similar to set()
but could be used for changing the version of the secret that would be retrieved.
update(secret_name="mySuperSecret", secret_value="toomanysecrets")
update(secret_name="mySuperSecret", secret_value="toomanysecrets", stage="development")
get()
would be nice to have with the optional way to get different versions of a secret.
generate_random_secret()
is also a nice feature for Secrets Manager. This might be a really nice way for people to generate random secrets that can be added to Powertools and saving the need for our fellow Powertools-ers to write custom code to generate random strings or secrets.
Out of scope
Secrets Manager
I think being able to cache that value would be great but I may have to think through if they are updating a secret with a different version.
I have been thinking about how this might eventually be used for versioning around being able to do "canary" or even cutovers to new secrets. But that is probably future work....
Potential challenges
Secrets Manager
When it comes to having the SecretsManager class also cache the new value, I think it would be great but I may have to think through if they are updating a secret with a different version. Do we cache the new version AND the old version if it exists? What would be the behavior around this?
Dependencies and Integrations
No response
Alternative solutions
No response
Acknowledgment
- This feature request meets Powertools for AWS Lambda (Python) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET
Metadata
Metadata
Assignees
Labels
Type
Projects
Status