The logic to get the LogGroupName is wrong. It searches for a function whose short name ends with the argument, not whose name equals the argument.
That means if you have two functions name lambdafunction and anotherlambdafunction, you can end up with resource conflicts because the LogGroupName for lambdafunction is used for both functions.