Terraform create a file

Hello All,

I am new to using terraform and working on building a new EC2 instance. I was able to deploy the EC2 instance but need to do some post configuration steps which I am planning on doing using ansible playbook. In order to do this, I wrote a ansible playbook that I need to deliver via terraform to this new EC2 instance. I have tried the local_file resource but even though the code runs without any issues it is not really creating a local file:


resource “local_file” “ansible-playbook” {
content = “${data.template_file.ansible-playbook}”
filename = “/var/tmp/setup.yaml”
}

data “template_file” “ansible-playbook” {
template = “${file(“setup.yaml”)}”
}

Do I need to add anything to my resource “aws_instance” section as well? Let me know if there is a better way to approach this.

Thanks!