Describe the issue:
I need to use environment variables for the security settings related to OpenID Connect authentication (URL, client id and secret) in a docker compose file.
I’ve tried different combinations but the only one that works is to provide the literal value in the opensearch_dashboards.yml file.
I tried adding environmetns section in the docker compose file:
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:2.18.0
environment:
..
# using variable from .env file:
OPENSEARCH_SECURITY_OPENID_CONNECT_URL: "${OPENSEARCH_OPENID_CONNECT_URL}"
# using lower case variable:
opensearch_security.openid.connect_url: '${OPENSEARCH_SECURITY_OPENID_CONNECT_URL}'
The opensearch_dashboards.yml file also is not taking variables. I tried:
I also tried using literal values but none are taken. The error always says:
2024-12-18T23:21:11.658631690Z {“type”:“log”,“@timestamp”:“2024-12-18T23:21:11Z”,“tags”:[“fatal”,“root”],“pid”:1,“message”:"Error: Failed when trying to obtain the endpoints from your IdP\n at OpenIdAuthentication.init (/usr/share/opensearch-dashboards/plugins/securityDashboards/server/auth/types/openid/openid_auth.ts:126:13)\n at MultipleAuthentication.init
The only thing that works is using literal values in opensearch_dashboards.yml file. Is there no way to use environment variables for these settings?
@dmossakowski According to my tests, OpenSearch Dashboards will ignore environmental settings for security plugin. It must be placed directly in the opensearch_dashboards.yml file.
After many tests I was able to use environment variables for all services: open search nodes, dashboards and data prepper. In all cases I load the variables from local .env file and so my docker compose file has:
Data prepper config doesn’t support environment variables so I used envsubst. Locally I only have a config file named data-prepper-pipelines.yaml.template and in docker I create a shared volume so the template file is processed and put on the shared volume where then it is read by data prepper service.