Add userdata for aws instance using data-source in terraform
Set the template as below:
template = "${file("${path.module}/userdata.tpl")}"
Here we use ${path.module}
to get a module-relative path.
Reference: https://www.terraform.io/docs/modules/create.html