Python - secret.latest()
Returns a reference to the latest
version of a secret, regardless of that version's ID.
from nitric.resources import secretfrom nitric.application import Nitric# Get latest secret versionlatest = secret("database.password").allow('access').latest()Nitric.run()
Notes
latest()
is most useful when you always want the most recent secret values from the secrets manager. Database credentials and API keys are good examples of secrets where the latest value is usually what you want.
For symmetric encryption, you'll need to retrieve the version of the secret used to encrypt a value when you try to decrypt it again. In those cases latest()
isn't a good choice, use version() instead.
Examples
Get a reference to the latest secret version
from nitric.resources import secretfrom nitric.application import Nitriclatest = secret("database.password").allow('access').latest()Nitric.run()
Access the latest value of a secret
from nitric.resources import secretfrom nitric.application import Nitriclatest = secret("database.password").allow('access').latest()value = await latest.access()Nitric.run()
See secret.version().access() for more details.
Last updated on Oct 16, 2024