Fleet preconfiguration in docker without kibana.yml

Hi there,

we're using beets for a while now and want to migrate to elasit_agent and fleet.
Our complete setup is in k8s, will created and maintained with terraform and init-containers which are configuring elastic and kibana.

So we're using your docker images and using env vars because it's very helpful to not have a configuration file for every service.

Everyting else is done by speaking with the API.

I'm stuck by creating/preconfiguring the agent policies.
There is the Fleet API where you can create a agent policy you havn't the option to define the id for. And because for assigning packages to agent_policies the ID is needed(or is there a way by referencing the agent policy name?? havn't found it).

But when preconfiguring the fleet settings by the kibana.yml, you have the option to define a custom id.

The problem is that i can't find a way of passing the yml configuration trough docker environment vars.
I've played around with the XPACK_FLEET settings a bit and came to a point where a error message of kibana was something like "can't parse json array". So i thougt it may a option to pass the value as json, but that results in the error:

Configuring logger failed: TypeError: Cannot read properties of undefined (reading 'length')

Is there either a way of set a agent_policy with a custom id trough the API or to let kibana preconfigure Fleet by using the env vars?

My sample compose:

version: '3.7'
services:
  kibana:
    image: docker.elastic.co/kibana/kibana:7.16.2
    container_name: testkibana
    ports:
      - 127.0.0.1:5601:5601
    environment:
      - ELASTICSEARCH_URL=http://elasticsearch:9200
      - ELASTICSEARCH_USERNAME=kibana_system
      - ELASTICSEARCH_PASSWORD=..Password56
      - SERVER_NAME=kibana
      - SERVER_BASEPATH=/kibana
      - SERVER_REWRITEBASEPATH=true
      - TELEMETRY_ENABLED=false
      - XPACK_FLEET_AGENTS_ENABLED=true
      - XPACK_FLEET_PACKAGES=[{"name":"fleet_server","version":"latest"}]
      - XPACK_FLEET_AGENTPOLICIES={"name":"Test compose policy","id":"test-compose-policy","namespace":"default","package_policies":[{"name":"fleet_server-1","package":{"name":"fleet_server"}}]}