Open yaronlevi opened 1 year ago
+1!
You can create a wrapper python script (e.g. infisical_secrets_injector.py
) in your project that takes the debug command generated by the launch.json
file, and prepends the infisical run
command so that the environment variables are in place before even the debugger itself starts up
infisical_secrets_injector.py
import subprocess, sys
sys.exit(subprocess.run(
args=["infisical", "run", "--", "python3" ] + sys.argv[1:],
).returncode)
You can then add this script to the pythonArgs
section of your launch.json
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug my app",
"type": "python",
"request": "launch",
"program": "the_python_app_you_want_to_debug.py",
"pythonArgs": ["infisical_secrets_injector.py"],
"args": ["actual", "args", "for", "your", "app"],
"console": "integratedTerminal",
"justMyCode": true,
}
]
}
(Kudos to Merramore's comment on this Stack Overflow post for coming up with this idea)
@daninge98 Thank you for the detailed information! I'll check this later.
Here's my setup if it helps anyone - using FastAPI
import subprocess, sys
sys.exit(subprocess.run(
args=["infisical", "run", "--", "python3" ] + sys.argv[1:],
).returncode)
{
"name": "Python: FastAPI + Infisical",
"type": "python",
"request": "launch",
"module": "uvicorn",
"pythonArgs": ["${workspaceFolder}/.vscode/infisical.py"],
"args": ["main:app","--reload"],
"console": "integratedTerminal",
"justMyCode": true
}
Hi,
Currently, there is no way to work locally with Python (the Infisical CLI inject way), in Vscode with the launch.json. So the desired result is that I should be able to click the green PLAY button in Vscode, and the envs will be injected by Infisical CLI.
Iv'e created this issue per the request of @maidul98
Detailed information can be found in this slack thread:
https://infisical-users.slack.com/archives/C04BSBMQAQ7/p1691421014342469
Thanks!