I seem to have solved this issue by using hash_extra For reference you can take a look at this notes https://github.com/terraform-aws-modules/terraform-aws-lambda?tab=readme-ov-file#-how-does-building-and-packaging-work