Saltar al contenido

Lambda durable function versions

1

I'm currently migrating a project from a step function to a durable function and hit an annoying snag. Since durable functions require pinned versions, deploying changes to my stack (implemented in CDK) will hang while trying to delete the old version as long as there's an execution running using that old version. This is very impractical for a platform where executions can last up to a year!

So far, the only reasonable workaround I've come across is to just keep old versions but that doesn't seem practical in the long term. Is there really no other option?

preguntada hace 3 meses58 visualizaciones
2 Respuestas
0

Short Answer

There’s no clean workaround here — keeping old versions is the correct and expected approach.

AWS will not delete a Lambda version while it’s still referenced by a running execution. With workflows that can run for months (or a year), deployment-time cleanup is fundamentally incompatible.

What You Should Do

  • Set Lambda versions to RemovalPolicy.RETAIN in CDK
  • Treat versions as immutable artifacts
  • Implement a separate cleanup process that deletes versions only when they’re no longer in use

Why This Is Actually Good Practice

  • Old executions remain stable and reproducible
  • New deployments don’t interfere with in-flight workflows
  • You gain better auditability of historical behavior

Professional Growth Takeaway

You’re asking the right question — this is a classic distributed systems lifecycle issue.

The next step is to decouple deployment from execution lifecycle:

  • Deploy freely
  • Let long-running executions finish on pinned versions
  • Clean up asynchronously and safely

For an extra step forward, consider adding version usage tracking (tags or external state) so cleanup becomes deterministic rather than guesswork.

respondido hace 3 meses
  • Sure, but I consider this a workaround rather than the best solution. In a real world, professional environment I'm planning on potentially dozens of durable functions across several different CF stacks. Having to copy and paste cleanup script plumbing in each of these stacks feels like I'm just doing AWS's job for them.

-1

May consider retaining legacy versions until those orchestrations are complete

EXPERTO
respondido hace 3 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.