You can use environment variables to pass parameters and credentials to the custom script using _env. See Workflow Secret Management for information about how to use workflow secrets.
_env:
TD_API_KEY: ${secret:apikey}
TD_API_SERVER: ${secret:endpoint}
AWS_ACCESS_KEY_ID: ${secret:aws_access_key_id}
AWS_SECRET_ACCESS_KEY: ${secret:aws_secret_access_key}To add a workflow secret to your custom script:
- Declare the secret in your workflow definition (.dig file) custom script declaration. For example:
+task1:
py>: my_script.value_test
_env:
saved_value: ${secret:saved_value}
docker:
image: "digdag/digdag-python:3.9"Access the secret from your custom script using the
os.environ.getmethod.Add it within your script. For example:
import digdag
import os
import io
def value_test():
# GET SAVED VALUE
print(os.environ.get('saved_value'))