Skip to content

Resource option: replacementTrigger ​

The replacementTrigger resource option forces a replacement operation on a resource whenever a specified trigger value changes. This is useful when you need to replace resources on a schedule or in response to external events that aren't captured by the resource's properties.

For example, you might want to rotate cryptographic keys monthly by using a YYYY-MM string as the trigger, or synchronize infrastructure updates with application releases by using a version number. Unlike replaceOnChanges, which triggers replacements based on resource property changes, replacementTrigger allows you to control replacement timing based on arbitrary values.

typescript
const today = new Date()

const keyManager = new KeyManagerResource("key-manager", {}, {
  replacementTrigger: today.getMonth() + '-' + today.getFullYear()
});

INFO

During each deploy, the value is checked against the previous value of the trigger, and if they don't match, the resource will be marked for replacement. Note that, if either the previous value or the current value is null, a replacement operation will not be forced. This means that adding or removing a replacement trigger from a resource will not trigger a replacement - only changing a pre-existing trigger value.

Content from the official Pulumi documentation (github.com/pulumi/docs).