@@ -307,20 +307,26 @@ def on_after_state_load(self):
307307 for region_name , state in account_bundle .items ():
308308 for fn in state .functions .values ():
309309 for fn_version in fn .versions .values ():
310- # restore the "Pending" state for every function version and start it
311310 try :
312- new_state = VersionState (
313- state = State .Pending ,
314- code = StateReasonCode .Creating ,
315- reason = "The function is being created." ,
316- )
317- new_config = dataclasses .replace (fn_version .config , state = new_state )
318- new_version = dataclasses .replace (fn_version , config = new_config )
319- fn .versions [fn_version .id .qualifier ] = new_version
320- # TODO: consider skipping this for $LATEST versions of functions with a capacity provider
321- self .lambda_service .create_function_version (fn_version ).result (
322- timeout = 5
311+ # $LATEST is not invokable for Lambda functions with a capacity provider
312+ # and has a different State (i.e., ActiveNonInvokable)
313+ is_capacity_provider_latest = (
314+ fn_version .config .CapacityProviderConfig
315+ and fn_version .id .qualifier == "$LATEST"
323316 )
317+ if not is_capacity_provider_latest :
318+ # Restore the "Pending" state for the function version and start it
319+ new_state = VersionState (
320+ state = State .Pending ,
321+ code = StateReasonCode .Creating ,
322+ reason = "The function is being created." ,
323+ )
324+ new_config = dataclasses .replace (fn_version .config , state = new_state )
325+ new_version = dataclasses .replace (fn_version , config = new_config )
326+ fn .versions [fn_version .id .qualifier ] = new_version
327+ self .lambda_service .create_function_version (fn_version ).result (
328+ timeout = 5
329+ )
324330 except Exception :
325331 LOG .warning (
326332 "Failed to restore function version %s" ,
0 commit comments