data "template_file" "cloud_init" {
template = "${file("init.tpl")}"
template = <<EOF
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==BOUNDARY=="
--==BOUNDARY==
Content-Type: text/cloud-config; charset="us-ascii"
write_files:
- path: /etc/sysctl.d/55-elasticsearch.conf
owner: root
content: |
vm.max_map_count=262144
runcmd:
- sysctl -w vm.max_map_count=262144
--==BOUNDARY==--\
EOF
}
resource "aws_launch_template" "foo" {
...
user_data = "${base64encode(data.template_file.cloud_init.rendered)}"
...
}