How to trigger stack runs when a module version is updated

Last updated: September 16, 2025

You can automatically trigger stack runs when a new version of a module is released by using a trigger policy. This is useful for ensuring that stacks consuming your modules are automatically updated when new versions become available.

Setting up the trigger policy

Create a trigger policy with the following code:

package spacelift

trigger[stack.id] { stack := input.stacks[_] }

This policy should be applied to the module in the registry, not to individual stacks.

Important requirements

  • Policy type: The policy must be set as a "trigger" type policy

  • Policy attachment: Apply the policy to the module itself, not to the consuming stacks

  • Module version: Only stacks using the latest version of the module will be triggered

  • Consumer relationship: Stacks must be listed as consumers of the module (this happens automatically when a stack uses the module)

How it works

When a new module version is released, the trigger policy will automatically run all stacks that are consumers of the newest available module version. The policy uses the consumer list from the module's data input to determine which stacks to trigger.

For more details on trigger policy data input, refer to the trigger policy documentation.

Triggering stacks on older module versions

If you need to trigger stacks that are using older versions of a module, you can use the Spacelift API with a script to:

  1. Iterate through each module and its versions

  2. Identify consumers for each version

  3. Manually trigger those stacks via API calls

This approach is useful for updating all stacks to the latest version during migration or testing scenarios.