Clean Up Mod Lambdas

Each mod update deploys new Lambda function versions. Over time, unused older versions accumulate, consuming storage and potentially running on end-of-life Node.js runtimes. In this guide, you will enable the maintenance container to automatically clean up these old mod Lambda versions.

[!WARNING] Do not manually delete mod Lambda versions. It's easy to accidentally remove a version that is still in use, which can break mod functionality. Always use the automated cleanup process described below.

Prerequisites

Step 1: Check Current Lambda Storage

Open the AWS Lambda console in the account hosting Guardrails. Note the current storage usage and any mod Lambdas running on outdated Node.js versions. This gives you a baseline to compare against after cleanup runs.

Step 2: Enable Cleanup in TEF

In your Turbot Enterprise Foundation (TEF) stack:

  1. Set the Mods Cleanup parameter to On.
  2. Toggle the Deployment Trigger to force re-evaluation of all SSM parameters.

Step 3: Apply to TE

Choose one of the following approaches:

Option A: Keep the current TE version and toggle the Deployment Trigger to pick up the updated SSM parameters from TEF.

Option B: Deploy a new TE version. If Mods Cleanup has already been enabled in TEF, the new TE deployment will pick up the parameter automatically.

Step 4: Upgrade Stale Mods

Any mods that haven't been updated since TE 5.36 was deployed will need to be upgraded or reinstalled for cleanup to apply. Upgrading is recommended over reinstalling.

[!TIP] If you have pinned mod versions or auto-update disabled, upgrade to the latest mod release to ensure compatibility with the cleanup process.

Step 5: Verify Cleanup Is Running

There is no visible indicator in the Guardrails console that Lambda cleanup is active. Verification is done through CloudWatch Logs.

  1. Open the CloudWatch log group: /{turbot_prefix}/{current_te_version}/maintenance
  2. Search for the string Running delete operation.

Example log entry:

Running delete operation for {
  functionName: 'turbot-turbotawsguarddutyipSetDelete-0a4a2dd2',
  aliasName: '5_6_1'
}

If Mods Cleanup was just enabled in a long-lived environment, you may see hundreds or thousands of deletion entries as the backlog is processed. Subsequent runs will only clean up a handful of versions per mod update.

Troubleshooting

IssueSolution
No cleanup log entries in CloudWatchVerify that Mods Cleanup is set to On in TEF and the Deployment Trigger was toggled. Check that the maintenance container is running.
Lambda storage not decreasingAllow time for the cleanup to process the backlog. Check CloudWatch logs for errors during deletion.
Further assistanceOpen a Support Ticket

Next Steps