Skip to content

feat: retain replaced WebFunction revisions by default - #4022

Open
seshubaws wants to merge 1 commit into
aws:developfrom
seshubaws:seshub/webfunction-retain-revisions
Open

seshubaws wants to merge 1 commit into
aws:developfrom
seshubaws:seshub/webfunction-retain-revisions

Conversation

@seshubaws

@seshubaws seshubaws commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Issue #, if available

Description of changes

Sets UpdateReplacePolicy: Retain on the generated AWS::Lambda::WebFunctionRevision, for both AutoDeploymentMode values. The endpoint, function and role are unchanged.

Every revision property is create-only, so each code or configuration change replaces <LogicalId>Revision. With AutoDeploymentMode: Disabled, the endpoint usually still routes to the old revision through RevisionWeights. CloudFormation's cleanup then fails to delete it ("cannot be deleted because the endpoints [prod] are using it") and retries for about 10 minutes before finishing with "One or more resources could not be deleted". With Retain, CloudFormation skips that delete.

  • An UpdateReplacePolicy set on the AWS::Serverless::WebFunction still applies to every generated resource and overrides this default.
  • Replaced revisions are no longer tracked by the stack. Deleting the stack deletes the function, which deletes all of its revisions.

Description of how you validated changes

  • Transform tests: updated the WebFunction outputs, and added webfunction_update_replace_policy for the override.
  • make format-check, make lint and make test pass.
  • Deployed templates transformed with this branch, in us-east-2:
    • LatestRevision update: the endpoint moved to the new revision, and the old one was DELETE_SKIPPED (37s).
    • Disabled update with the endpoint pinned to the old revision: DELETE_SKIPPED, then UPDATE_COMPLETE in 38s with no warning (previously about 10 minutes and "could not be deleted").
    • Failed update with rollback: the endpoint's weights and WebFnRevision were restored. The revision created by the failed update was also DELETE_SKIPPED, because UpdateReplacePolicy applies to rollback cleanup too.
    • Stack deletion: completed in 32s, and the function and all 4 revisions were deleted.

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@seshubaws
seshubaws requested a review from a team as a code owner October 20, 2026 22:52

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants