pulumi/pulumi · error

--once is not valid for drift schedules; use --cron

Error message

--once is not valid for drift schedules; use --cron

What it means

Drift schedules are triggered by cron expressions, not one-off timestamps. When editing a drift schedule, passing --once is rejected with a hint to use --cron instead. This keeps drift schedules periodic by construction.

Source

Thrown at pkg/cmd/pulumi/stack/stack_schedule_edit.go:235

	return flags.cronChanged ||
		flags.onceChanged ||
		flags.operationChanged ||
		flags.autoRemediateChanged ||
		flags.deleteAfterDestroyChanged
}

func validateScheduleEditFlags(kind string, flags stackScheduleEditFlags) error {
	switch kind {
	case scheduleKindRaw:
		if flags.autoRemediateChanged {
			return errors.New("--auto-remediate is only valid for drift schedules")
		}
		if flags.deleteAfterDestroyChanged {
			return errors.New("--delete-after-destroy is only valid for ttl schedules")
		}
	case scheduleKindDrift:
		if flags.onceChanged {
			return errors.New("--once is not valid for drift schedules; use --cron")
		}
		if flags.operationChanged {
			return errors.New("--operation is not valid for drift schedules")
		}
		if flags.deleteAfterDestroyChanged {
			return errors.New("--delete-after-destroy is only valid for ttl schedules")
		}
	case scheduleKindTTL:
		if flags.cronChanged {
			return errors.New("--cron is not valid for ttl schedules; use --once")
		}
		if flags.operationChanged {
			return errors.New("--operation is not valid for ttl schedules")
		}
		if flags.autoRemediateChanged {
			return errors.New("--auto-remediate is only valid for drift schedules")
		}
	}

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Replace --once with --cron to set a recurring cadence for the drift schedule.
  2. If a single one-off run is needed, edit or create a raw schedule that supports --once.
  3. Check the schedule kind with `pulumi stack schedule ls` before choosing flags.

Example fix

// before
pulumi stack schedule edit my-drift-schedule --once 2026-09-01T10:00:00Z
// after
pulumi stack schedule edit my-drift-schedule --cron "0 10 * * *"
Defensive patterns

Strategy: validation

Validate before calling

if kind === 'drift' && (process.argv.includes('--once')) {
  throw new Error('use --cron for drift schedules');
}

Type guard

function isDriftSchedule(s) { return s.kind === 'drift'; }

Prevention

When it happens

Trigger: Running `pulumi stack schedule edit <drift-schedule> --once <timestamp>` (flags.onceChanged true while kind == scheduleKindDrift).

Common situations: Users confuse drift schedules with one-off (raw/ttl once) schedules and try to convert a recurring drift check into a single run, or copy a TTL edit command onto a drift schedule.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/0b01c6bb40ca6faf. Report an issue: GitHub.