Hey all!

I'm using localstack for a project where I consume data from kinesis, process it and put it in elasticsearch.

In the later versions of localstack 'elasticsearch' was removed and is now lazily loaded after call to es::CreateElasticsearchDomain (at least that's how I understand it from #1881, #1865, #1870).

I'm running localstack in a docker using testcontainers (which gives me dynamic port mappings etc). My processing code is running on localhost.

The problem I'm facing now is that the response from es::CreateElasticsearchDomain returns an elasticsearch endpoint like: http://[docker container id]:port.
With my set up, this gives me two issues:
1. [docker container id] host is not (I believe) reachable from localhost unless I add it to /etc/hosts or something like that. I can surely "hack" my way around this by just replacing [docker container id] with localhost.
2. It says here: https://github.com/localstack/localstack/issues/1881#issuecomment-567495056 that we should not assume that elasticsearch will run on a static port in the future. When running localstack in a docker, how would I know which port to expose then in order to reach elasticsearch from localhost?

I currently have my tests running using 1.10.7 but there I just make a dummy call to es::CreateElasticsearchDomain and hardcode elasticsearch endpoint to http://localhost:4571. (It seems like it always chooses 4571 as of now?)

Thanks
Stefan
cls._delete_document(TEST_DOC_ID)
        
        es_client = aws_stack.connect_to_service('es')
        es_client.delete_elasticsearch_domain(DomainName=TEST_DOMAIN_NAME)
        assert_not_in(TEST_DOMAIN_NAME,
            [d['DomainName'] for d in es_client.list_domain_names()['DomainNames']])
    def test_domain_es_version(self):
        es_client = aws_stack.connect_to_service('es')
        status = es_client.describe_elasticsearch_domain(DomainName=TEST_DOMAIN_NAME)['DomainStatus']
        self.assertEqual(status['ElasticsearchVersion'], DEFAULT_ES_VERSION)
        domain_name = 'es-%s' % short_uid()
        self._create_domain(name=domain_name, version='6.8')
        status = es_client.describe_elasticsearch_domain(DomainName=domain_name)['DomainStatus']
        self.assertEqual(status['ElasticsearchVersion'], '6.8')
    def test_domain_creation(self):
        es_client = aws_stack.connect_to_service('es')
        
        self.assertRaises(ClientError, es_client.create_elasticsearch_domain, DomainName=TEST_DOMAIN_NAME)
        
        status = es_client.describe_elasticsearch_domain(DomainName=TEST_DOMAIN_NAME)
        self.assertEqual(status['DomainStatus']['DomainName'], TEST_DOMAIN_NAME)
        self.assertTrue(status['DomainStatus']['Created'])
        self.assertFalse(status['DomainStatus']['Processing'])
        self.assertFalse(status['DomainStatus']['Deleted'])
        self.assertEqual(status['DomainStatus']['Endpoint'], aws_stack.get_elasticsearch_endpoint())
        self.assertTrue(status['DomainStatus']['EBSOptions']['EBSEnabled'])
        
        response = es_client.add_tags(ARN='string', TagList=[{'Key': 'SOME_TAG', 'Value': 'SOME_VALUE'}])
        self.assertEqual(response['ResponseMetadata']['HTTPStatusCode'], 200)
    def test_elasticsearch_get_document(self):