@@ -876,11 +876,18 @@ def diff(self, stack: Stack, qualifier: str | None = None) -> None:
876876 else self .version .latest
877877 )
878878
879- # If the version already exist then we are not deploying anything
880- # as a version is immutable. So there are no changes in that case
881- if self ._exist_version (version = version ):
882- print (f"No new version for function { name_with_qualifier } " )
883- return
879+ try :
880+ # If the version already exists then we are not deploying anything
881+ # as a version is immutable. So there are no changes in that case
882+ if self ._exist_version (version = version ):
883+ print (f"No new version for function { name_with_qualifier } " )
884+ return
885+ except botocore .exceptions .ClientError as e :
886+ # We can get a genuine AccessDeniedException depending on conditions
887+ # in the policy if the lambda doesn't exist yet. In such cases it's
888+ # better to not fail
889+ if e .response ["Error" ]["Code" ] != "ResourceNotFoundException" :
890+ logger .exception (f"Failed to fetch function { self .name } versions:" )
884891
885892 # Otherwise we are redeploying the function, so we get the list of files
886893 # from the local code asset
@@ -903,9 +910,11 @@ def diff(self, stack: Stack, qualifier: str | None = None) -> None:
903910 os .path .join (tmpd , archive_name )
904911 )
905912 except botocore .exceptions .ClientError as e :
906- # In this case the function has not yet been deployed
913+ # We can get a genuine AccessDeniedException depending on conditions
914+ # in the policy if the lambda doesn't exist yet. In such cases it's
915+ # better to not fail
907916 if e .response ["Error" ]["Code" ] != "ResourceNotFoundException" :
908- raise e
917+ logger . exception ( f"Failed to fetch function { self . name } code asset:" )
909918
910919 diff = modified_diff_lines (
911920 list (difflib .ndiff (active_archive_files , archive_files ))
0 commit comments