mirror of
https://github.com/apple/pkl.git
synced 2026-01-13 23:23:37 +01:00
Support fetching secrets from cloud providers #61
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Clebbie on GitHub (Feb 13, 2024).
As a Developer I would like to store my application's secrets in my configuration.
I think we could add this feature with the read() interface. Supporting the cloud platforms could go a long way in making pkl the standard config language it wants to be.
i.e.
read(azvault:some.vault.url)
@bioball commented on GitHub (Feb 14, 2024):
This is possible. To do this, you will need to drive Pkl execution through one of our language bindings. And, in the host language, you'll want to define a resource reader to implement reading from Vault, etc.
See:
@Clebbie commented on GitHub (Feb 16, 2024):
Got it working in my go project. Ty for the documentation.
@khanakia commented on GitHub (Jul 27, 2025):
@Clebbie Can you share an example in Golang please how did you achieve this.
@HT154 commented on GitHub (Jul 27, 2025):
It's no longer necessary to drive evaluation via the language bindings to do this. The External Readers feature allows extending any Pkl usage (eg. the plain CLI) to allow reading or importing custom URI schemes. You can read more about external readers here: https://pkl-lang.org/main/current/language-reference/index.html. You can see a very basic example of implementing an external reader in golang here: https://pkl-lang.org/go/current/external-readers.html.
@khanakia commented on GitHub (Jul 27, 2025):
I checked this, but i think External Readers are to extend the pkl functionality
What I need is to be able to load Secrets from an External Secret Manager like AWS Secret Manager, and instead of defining secrets in the app.pkl file and commit with Docker Image file
I am using Docker Containers, so I need the best way to load secrets.
@Clebbie commented on GitHub (Jul 27, 2025):
Unfortunately I don’t have access to the code I wrote. I’m looking around to see if I don’t have another example somewhere… no promises though
On Sun, Jul 27, 2025 at 11:42 AM, Aman Bansal @.***(mailto:On Sun, Jul 27, 2025 at 11:42 AM, Aman Bansal < wrote:
@HT154 commented on GitHub (Jul 27, 2025):
I think I need a little more info to provide good guidance then.
Can you say more about how your app loads your config? Is your app.pkl included in your container image? Is it loaded directly by your application using pkl-go? Are you trying to configure which secrets to read in your app.pkl but defer actually reading them from the external secret manager until when your app loads the configuration?
@khanakia commented on GitHub (Jul 27, 2025):
So what i want is to store secrets to some remote service e.g AWS Secret Manager, and then do the following
app.pkl
Loading the file
@HT154 commented on GitHub (Jul 27, 2025):
If you're looking to override the values loaded via Pkl in your application, that's somewhat out of scope for what this issue is originally asking about. It's up to you to decide how to interact with your secrets provider and override values in the configuration structs. You would need to consult the docs for AWS Secret Manager's golang SDK.
That said, the approach Clebbie referred to in this issue is indeed extending Pkl to read directly from a secrets provider. Usage would look like this:
There are two ways to support this kind of extension:
In both cases you would need to implement the reader code in golang and configure your app's Pkl evaluator to use it. Since you're using pkl-go's evaluator API the Custom Reader approach is likely a better choice. Usage would look something like this:
(I freehanded this so no promises it works as-is)
@khanakia commented on GitHub (Jul 27, 2025):
Yes, i meant that reading directly from the secrets provider may be. I wrote it differently.
Thanks, will check