---
title: "Use environment variables in a Custom action"
description: "Set environment variables for a Custom action in the preferences or in the JSON advanced mode"
url: https://docs.ovhcloud.com/it/guides/public-cloud/data-platform/developers-python-sdk-use-environment-variables
lang: it
lastUpdated: 2026-09-14
---
> For AI agents: the complete documentation index is available at https://docs.ovhcloud.com/it/llms.txt, the full documentation bundle is available at https://docs.ovhcloud.com/it/llms-full.txt.

# Use environment variables in a Custom action

## Objective

In a [Custom action](https://docs.ovhcloud.com/it/guides/public-cloud/data-platform/dpe-actions-custom.md), you might want to use environment variables. You can set your own in the preferences or set them in the JSON _Advanced Mode_ of the action, in the `params` JSON object, and re-use them in your custom action.

```python
import sys
from logging import getLogger
from forepaas.core.settings import PARAMS

logger = logging.getLogger(__name__)

def my_custom(event):
	try:
		# Show the parameter value
		logger.info("Environment variable value is: ".format(PARAMS["env variable key"]))

	except Exception as err: 
		raise Exception("err:{} L:{}".format(err,sys.exc_info()[2].tb_lineno))
```

## Go further

If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](https://www.ovhcloud.com/it/professional-services/) to get a quote and ask our Professional Services experts for a custom analysis of your project.

Ask questions, give your feedback and interact directly with the team building the Data Platform on the dedicated [Discord channel](https://discord.gg/ovhcloud).

If you need support with your OVHcloud services, create a request in our [Help Centre](https://help.ovhcloud.com/csm?id=csm_get_help).

Join our [community of users](https://community.ovhcloud.com/).
