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.
replacementTrigger resource option has no direct effect on component resources. It is defined on the base resource-options type in every Pulumi SDK, so no SDK rejects it at compile time — passing it to a component resource has no direct effect at runtime. replacementTrigger is settable on a component, but the engine never replaces components, so it has no effect there. It also is not inherited by the component's children — set it on each child custom resource that you want to be replaced by the trigger, or use a transforms function on the component to inject it into matching children.const today = new Date()
const keyManager = new KeyManagerResource("key-manager", {}, {
replacementTrigger: today.getMonth() + '-' + today.getFullYear()
});
import datetime
today = datetime.now()
trigger = f"{today.month}-{today.year}"
key_manager = KeyManagerResource("key-manager", {},
opts=pulumi.ResourceOptions(replacement_trigger=trigger))
today := time.Now()
trigger := fmt.Sprintf("%d-%d", int(today.Month()), today.Year())
keyManager, err := NewKeyManagerResource(ctx, "key-manager", &KeyManagerResourceArgs{},
pulumi.ReplacementTrigger(pulumi.Any(trigger)))
var today = LocalDate.now();
var trigger = String.format("%d-%d", today.getMonthValue(), today.getYear());
var keyManager = new KeyManagerResource("key-manager",
KeyManagerResourceArgs.Empty,
CustomResourceOptions.builder()
.replacementTrigger(Output.of(trigger))
.build());
var today = DateTime.Now;
var trigger = $"{today.Month}-{today.Year}";
var keyManager = new KeyManagerResource("key-manager", new KeyManagerResourceArgs(),
new CustomResourceOptions
{
ReplacementTrigger = Output.Create(trigger)
});
configuration: rotationPeriod: type: string default: “01-2026”
resources: keyManager: type: example:components:KeyManager options: replacementTrigger: ${rotationPeriod}
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.Thank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.