Cloudformation for elasticsearch cluster on aws

I want to have an elasticsearch cluster deployed on AWS. I want to use Cloudformation to create the infra as well as install elasticsearch on those ec2 instances.

I don't want to use Ansible and am thinking of leveraging UserData in CF template to install the elasticsearch packages and make changes to config yaml files.

Has anyone solved this problem lately ?