As mentioned at Terraform Resource: Connection Error while executing apply
I changed my code to the the below
provisioner "remote-exec" {