Error: remote-exec provisioner error

I’m trying to use Terraform to build my aws EC2 infrastructure and use Anisble for configuration management with null_resource. I also tried to use the remote exec and the local exec. See Code below. I’m reaching the following:

Error: remote-exec provisioner error
with null_resource.example
on main.tf line 15, in resource “null_resource” “example”:

error executing “/tmp/terraform_853853788.sh”: Process exited with status 126

Thanks in Advance

Michael

resource “aws_instance” “example” {
ami = “ami-000000…”
instance_type = “t2.medium”
vpc_security_group_ids = [“sg-00000000000x”]
key_name = “Test-Key”
tags = {
name = “example”
}

}

resource “null_resource” “example” {
provisioner “remote-exec” {
connection {
type = “ssh”
user = “centos”
private_key = file(“Test-Key-1.pem”)
host = aws_instance.example.private_ip
file = file(“files/id_rsa”)
}

inline = [“echo ‘connected!’”]
}

provisioner “local-exec” {
command = “ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u centos --private-key ./Test-Key-1.pem -T 300 -i ${aws_instance.example.public_ip}, playbook.yml”
}
}