'Can I have different value in environment variable for the same Task Definition in aws?

I have an Elasticsearch deployment on AWS EC2 based ECS. I want to have different hostnames for different task but I don't want to have different services for it as it would increase my workload a lot when I update the task definition. Is there any aws service that can help me get different values in the same environment variable from the same Task Definition?

Right now if I want something like this I have to use multiple Task Definition and similarly multiple Services. I want to streamline this process and only have one task definition and one service but still provide multiple and unique environment variable in a predefined manner.

Below I am sharing the elasticsearch.yml where I need the hostname.

# node.name: ${ES_NODE_NAME:}

discovery.seed_providers: ec2
discovery.ec2.tag.Name: EL-POC

# cluster.initial_master_nodes: es-node-1, es-node-2, es-node-3

Here I want the ES_NODE_NAME as mentioned in the cluster.initial_master_nodes. I also want to make sure that if the task went down due to any fault when it comes back online again it has the same hostname and not a new name. These names can't be dynamic and has to be as defined in the cluster.initial_master_nodes.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source