I need to create an AWS instance with user-data using terraform. I'm using terraform 0.10.0.
ec2.tf
data "template_file" "user_data" {
template = "userdata.tpl"
}
resource "aws_instance" "fluentd-web" {
ami = "${lookup(var.amis, var.aws_region)}"
instance_type = "t2.micro"
subnet_id = "${var.subnet_id}"
user_data = "${data.template_file.user_data.rendered}"
security_groups =[ "${aws_security_group.ec2_sg.id}" ]
connection {
***
}
}
userdata.tpl
#! /bin/bash
apt install <**>
On applying the terraform, It shows no error. But the contents of the file is not getting populated as user-data. It just shows the file name as user-data.

How can I get the contents of the file as user-data?