Custom Script Modules

Script modules hold helper functions that several steps and projects share.

Search guides... Ctrl K

A script module is a PowerShell or Python module stored in the workspace. Include it in a project, and every script step in that project can call its functions. Use modules for helpers that several scripts share, such as authentication wrappers, database helpers and notification functions.

// Step templates

When the user fills out a form

A step template is a reusable step with input fields. Pick it from the step list, fill in the inputs, and it becomes a step in the process.

// Script modules

When the user writes a script

A script module is a function library. Use one when people write their own scripts and want to call shared functions instead of copying them.

Using a module in a step

In the project's script modules, tick Include in project for each module the project needs. PowerShell modules are imported automatically before every PowerShell step, so you call their functions directly. In a Python step, import the module by its name.

Calling module functions

Variables come from $Jaws.Parameters in PowerShell and jaws.parameters in Python.

# PowerShell step: Get-SqlConnection and Send-SlackNotification come from an included module
$conn = Get-SqlConnection -ConnectionString $Jaws.Parameters["Db.Conn"].Value
Invoke-Migration -Connection $conn
Send-SlackNotification -Channel "#deploys" -Message "Migration finished"

# Python step: notifications is an included Python module
import notifications
notifications.send_slack("#deploys", "Migration finished")

What belongs in a module

Generic functions used by several steps or projects: logging helpers, notification senders, authentication wrappers and database connection helpers. If you have written the same function in more than one inline script, move it to a module.

Keep project-specific code in the project's own scripts. A shared module should make sense to someone who doesn't know the project it came from.