Error: remote-exec provisioner error

Hello Jbardin, thanks for your response. We have a client that we’re trying to use terraform to provision some servers and using ansible to deploy software on those servers. I’ve google and tried many google Terraform and Ansible examples unsuccessfully. I have the terraform provisioning the aws EC2 instance and etc. However I hadn’t be able to get Terraform and Ansible to work together. Based on your recommendation, I change the private_ip change to public_ip (see modified code below). I received this error:

Begining of Error

Error: remote-exec provisioner error

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

timeout -last error: dial tcp #.##.###.##:22: i/o timeout

Ending of Error

BTW the instance appears in the AWS console and I’m able to logon via putty.

Begin private ip to public ip change

resource “null_resource” “example” {

provisioner “remote-exec” {

connection {

type = “ssh”

user = “centos”

private_key = file(“Test-Key-1.pem”)

host = aws_instance.example.public_ip

file = file(“files/id_rsa”)

}

#END private ip to public ip change

What’s the best practice to use Terraform and Ansible?