Getting Intermittent Error while local_exec is trying to run a shell script

Hey Folks!
I am using the below code to execute a shell script. In the first step the resource local_file will just create the shell file. In second step null_resource will execute the script. The shell is kept in repo along with the terraform code. The file is getting created as shown in the terraform apply, however intermittently it shows the shell is not present while trying to execute it.