スキップしてコンテンツを表示

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?

質問済み 3ヶ月前58ビュー
2回答
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.

回答済み 3ヶ月前
  • 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

エキスパート
回答済み 3ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ