<@U04S8PLJWMT> - Is there a way to pass environmen...
# replication-ask-ai
s
@kapa.ai - Is there a way to pass environment variables to a connector image ?
k
There are several ways to pass environment variables to a connector image depending on whether you are developing, testing, or running the connector in production. ### 1. During Connector Development (Python CDK) If you are using the Airbyte Python CDK and migrating to the Airbyte base image, you can set environment variables by adding a
build_customization.py
file to your connector folder. This file uses a pre/post build hook framework to mutate the container:
Copy code
python from __future__ import annotations from typing import TYPE_CHECKING  if TYPE_CHECKING:     from dagger import Container  async def pre_connector_install(base_image_container: Container) -> Container:     return await base_image_container.with_env_variable("MY_PRE_BUILD_ENV_VAR", "value")  async def post_connector_install(connector_container: Container) -> Container:     return await connector_container.with_env_variable("MY_POST_BUILD_ENV_VAR", "value")
[[Migration Guide](https://docs.airbyte.com/platform/connector-development/cdk-python/migration-to-base-image)] ### 2. During Acceptance Testing When running Connector Acceptance Tests (CAT), you can specify custom environment variables in the test configuration file:
Copy code
yaml connector_image: "airbyte/source-pokeapi" custom_environment_variables:   my_custom_environment_variable: value
[[Acceptance Tests Reference](https://docs.airbyte.com/platform/connector-development/testing-connectors/connector-acceptance-tests-reference#custom-environment-variable)] ### 3. During Debugging (Docker Compose) If you are debugging a connector launched by the Airbyte worker, you can pass environment variables (specifically for Java options) through the
worker
container. By setting
DEBUG_CONTAINER_IMAGE
and
DEBUG_CONTAINER_JAVA_OPTS
in your
docker-compose.debug.yaml
, the worker will inject these into the target connector container when it spawns [[Debugging Docker](https://docs.airbyte.com/platform/connector-development/debugging-docker#debugging-containers-launched-by-the-worker-container)]. ### 4. Limitations for Production Operators Currently, there is no built-in "out of the box" solution for an operator to globally inject environment variables into all connector instances without including them in the
Dockerfile
or the connector
spec
(which makes them visible to users) [[Forum Post 1861](https://discuss.airbyte.io/t/1861); [Forum Post 986](https://discuss.airbyte.io/t/986)]. Suggested workarounds include: * Hardcoding constants into the connector's
Dockerfile
. * Passing variables through the API during source/destination creation if you want to avoid user-facing fields in the UI.