# Dynamic Values

The dynamic values option provides the ability to reference parameters (standard or secret), templates, or other CloudTruth objects (project, environment, template) within a company's organization and interpolate their values. Dynamic values are obtained by using the [mustache](https://mustache.github.io/) logic-less template syntax.

{% hint style="info" %}
Only non-secret parameters can contain Dynamic Values; however, they can reference parameters marked as secrets.
{% endhint %}

## Creating a dynamic value

1. After creating a new standard parameter, the `ADD ENVIRONMENT VALUE` modal is displayed, where clicking the `DYNAMIC` option switches the `ENVIRONMENT VALUE` input into a code editor and adds the `Evaluate` button for previewing the dynamic value before saving:

<figure><img src="/files/dsj0cwCOWV1kL0YOFQUv" alt="" width="563"><figcaption><p>DYNAMIC unchecked</p></figcaption></figure>

<figure><img src="/files/uX8RhhVkALjJnfWND7qI" alt="" width="563"><figcaption><p>DYNAMIC checked</p></figcaption></figure>

2. Starting with two left-hand braces `{{`, the editor will automatically insert the two right-hand braces `}}`. Start typing `cloudtruth` to access the available automatic parameter options, we'll select `project` for this example:

<figure><img src="/files/P0M6Dn8ygEjVs0HJmX4z" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/2pICQQgGHehA1d7HYXoK" alt="" width="563"><figcaption></figcaption></figure>

3. Click `Evaluate` to display the actual value of the parameter (to revert back the the code editor, click `Show Raw`):

<figure><img src="/files/SP0p3yDEZae6cj2I6XmM" alt="" width="563"><figcaption></figcaption></figure>

4. Once satisfied, click `Save` to save the dynamic value.

{% hint style="info" %}
More information regarding available automatic parameters is covered in our Templates documentation in the [Automatic Parameters](/configuration-management/using-basic-templates.md#automatic-parameters) section
{% endhint %}

## Interpolation

The ability to interpolate, or retrieve values from existing parameters, is a great way to automatically produce values for a given environment based on data within the environment. Here's a simple example:

Say we want to programmatically build a site per environment within a project. Normally, we would need to add a domain parameter for each environment which is unique such as:

* production.example-app.com

Hard-coding these parameters and overriding the values in each environment is doable, but quickly becomes overhead and error prone when new environments are created. Interpolation gives us the ability to 'build' this value at retrieval time, every time. When new environments are added, the dynamic variable is inherited and produces the correct value when retrieved without the need to manually update the value. Here's how we might do this:

1. Create a new project parameter for the default environment with a dynamic value which references the project:

<figure><img src="/files/dgay8qilXd1NOeBSflCN" alt="" width="563"><figcaption></figcaption></figure>

2. This will produce a domain with top-level-domain base for the project:

<figure><img src="/files/80Jm6ooLkaGRijEQFNnU" alt="" width="563"><figcaption></figcaption></figure>

3. Next, let's create another project parameter for the default environment with a dynamic value which references the environment *and* the previously created project parameter:

<figure><img src="/files/NhqCF32ApijsJWa0chJ3" alt="" width="563"><figcaption></figcaption></figure>

4. This will produce the full-domain string in a per environment fashion for the project:

<figure><img src="/files/sQD4TfIVDaaKArlwYO0s" alt="" width="563"><figcaption></figcaption></figure>

5. Going back to the project's parameter list, we can see how useful this is by evaluating the values (click `Show Evaluated`) then selecting different environments to see the value update to reflect the currently selected environment:&#x20;

<figure><img src="/files/IVx8CWvdhPaIK8Cr2iiI" alt="" width="563"><figcaption><p><code>development</code> environment</p></figcaption></figure>

<figure><img src="/files/ciKRyfV6sQTIJO24COSd" alt="" width="563"><figcaption><p><code>production</code> environment</p></figcaption></figure>

This is a simple example of how interpolation produces values automatically and accurately every time they are retrieved and evaluated.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudtruth.com/configuration-management/parameters/parameter-management/managing-parameters/dynamic-values.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
