Page tree
Skip to end of metadata
Go to start of metadata

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:

  1. 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.7"

  2. Access the secret from your custom script using the `os.environ.get` method.

  3. 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'))

  • No labels