Search documentation

Type to search the documentation.

Docs/Examples/Pass configuration with Secrets

Python example

Pass configuration with Secrets

Inject an inline Secret and check that its key is available remotely.

Before you run#

Use an installed, authenticated Yak CLI with access to the invite-only preview. Read Secrets for the full setup and current behavior.

Source code#

Download secrets.py

Canonical examplesecrets.py
secrets.py
import asyncio
import os

import yak


secret = yak.Secret.from_dict({"YAK_DEMO_TOKEN": "preview-demo-value"})
app = yak.App(name="secret-example", secrets=[secret])


@app.task()
def secret_is_available() -> bool:
    return bool(os.environ.get("YAK_DEMO_TOKEN"))


@app.entrypoint()
async def main() -> None:
    configured = await secret_is_available.remote.aio()
    print(f"secret configured: {configured}")


if __name__ == "__main__":
    asyncio.run(main())

Run the example#

Save the source as secrets.py, then run:

Commandsecrets.py
secrets.py ready
$ yak run secrets.py