How can create datastream automatically

This is my logstash output part :

after run , It will create index with the name of "TXT" but I want to create automatically datastream with all index templates and .. . Is that possible?

output{

  stdout{}
  elasticsearch {
   index => TXT
   hosts => ["https://IP:9200"]
   cacert => '/etc/logstash/certs/http_ca.crt'
   user => "elastic"
   password => "password"

}

}

Now according to above post it just creates an index and cannot create index template so we cannot create ILM . How can put it in that output ?