# Environments and Tags

## Environments

CloudTruth Environments allow us to model an organization's hierarchy and define parameter values specific to the current environment context.

Each CloudTruth Organization starts with the following environment tree:

* **default** (the root environment, cannot be deleted or renamed)
  * **development**
  * **production**
  * **staging**

Parameters inherit values from branches in the Environment tree allowing you to have a common default value throughout the Organization while also granting fine grain control over those values where required.

### Creating an Environment

1. Select **Create Environment** from the global Project and Environment action menu at the top of the page to open the **CREATE NEW ENVIRONMENT** dialog:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FW2trv7LtMzvociJPDGUR%2Fimage.png?alt=media&#x26;token=833f6d48-c160-45f1-9072-3883c71a0301" alt="" width="221"><figcaption></figcaption></figure>

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2Fc9S6o62Sle1VXaYBv0M1%2Fimage.png?alt=media&#x26;token=c8e0188d-e193-4e00-96eb-3debcea05b17" alt="" width="199"><figcaption></figcaption></figure>

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2Fc7dKkJxYTl6PlsTJI7ZI%2Fimage.png?alt=media&#x26;token=5182c41f-6452-4d7e-a280-efd26be7b0f0" alt="" width="563"><figcaption></figcaption></figure>

* **ENVIRONMENT NAME** - Typically a name representing a real world environment (required)
* **PARENT ENVIRONMENT** - Existing environment to nest the new environment under (required, defaults to the current globally selected environment)
* **DESCRIPTION** - Further describe the environment's purpose (optional)

2. Fill out the form with the appropriate information:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FxiAOmz2B2nKmv7WfW9v0%2Fimage.png?alt=media&#x26;token=57ecbf99-13b8-43bc-ae5c-20869d6b6384" alt=""><figcaption></figcaption></figure>

3. Submit the form to create the `dev1` environment as a child of the `development` environment.

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FLjS2xAJ9ow5NmeKUiqWs%2Fimage.png?alt=media&#x26;token=6e3f7e6f-dcaf-44d3-a4e9-6bcf0c59ebfd" alt="" width="563"><figcaption></figcaption></figure>

### Environment Hierarchy

In the example above, we have created a single child environment under the development environment:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FUUwMnZjO2obdRvI2Dyh9%2Fimage.png?alt=media&#x26;token=efd81acb-c9c6-40d6-9316-bf171d67c2d9" alt="" width="242"><figcaption></figcaption></figure>

This process can be repeated for complex models allowing very distinct parameter customization at multiple levels of your organization:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FGQXRMJlZL0J28yIYMunX%2Fimage.png?alt=media&#x26;token=b2a4f673-2dad-461d-b280-0407b158efc8" alt="" width="243"><figcaption></figcaption></figure>

### Copying an Environment

1. On the Environments page, select the source environment to copy in either the global environment selector at the top or in the environment tree, then select the Copy option from the selected environment's action menu:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2Ffrhlqp5oE4UuUOzmx4Q7%2Fimage.png?alt=media&#x26;token=16b6845c-8b86-4752-a7e5-0cfd833feb70" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FDjRUyWxXTO3YedNGv8j7%2Fimage.png?alt=media&#x26;token=9366bdd1-a608-403d-82e0-bd23a9a0d326" alt="" width="563"><figcaption></figcaption></figure>

* **ENVIRONMENT NAME** - Typically a name representing a real world environment (required)
* **DESCRIPTION** - Further describe the environment's purpose (optional)
* **COPY DEPENDENTS** - This option is only available if there are dependent environments to the environment being copied.

2. Enter the appropriate information and click `Next`:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FFOz3K20hpZDFtGy0WcNo%2Fimage.png?alt=media&#x26;token=a7b3fc51-0cae-4c14-8786-2f37e875ec86" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2F1T74z96V37xzPKwwRex8%2Fimage.png?alt=media&#x26;token=7f8f8214-a80e-443d-a267-702a506974a9" alt=""><figcaption></figcaption></figure>

3. After reviewing, click `Copy Environment`
4. This will copy the environment as a top-level environment under the `default` environment, along with any dependent environments (with the `COPY DEPENDENTS` option checked):

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2F2UTGCM99paVhdJXeRQmI%2Fimage.png?alt=media&#x26;token=ecc89a10-92b2-4076-905d-143479feb030" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
All copied environments will be placed under the `default` environment.
{% endhint %}

### Deleting an Environment

1. On the Environments page, select the environment to delete in either the global environment selector at the top or in the environment tree, then select the Delete option from the selected environment's action menu:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FJNNjU17WdmXo4CBKFk3J%2Fimage.png?alt=media&#x26;token=adaeed3e-5344-4e23-99cf-6b501db96441" alt="" width="563"><figcaption></figcaption></figure>

2. Click `Yes, delete` on the confirmation dialog to complete the environment deletion process.

{% hint style="info" %}
You will not be allowed to delete the `default` environment or any parent environment containing children.
{% endhint %}

## Tags

Tagging allows you to create a snapshot of parameters and values in a selected environment to a specific point in time. You can then use the tag to retrieve values for your applications. Tags are applied for the chosen environment across all projects in your organization. To see a tag's parameters and values use the [history feature ](https://docs.cloudtruth.com/parameters/history-of-values#history-by-tag)or the via [CLI](https://docs.cloudtruth.com/configuration-management/cli-and-api/cloudtruth-cli).

### Creating a Tag

Select `Environments` in the left-hand navigation menu:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FBk6tAgebOlSK8RztyUGH%2Fimage.png?alt=media&#x26;token=d040511c-0e23-4c7e-8214-de0b0fff7d71" alt=""><figcaption><p>Environments</p></figcaption></figure>

Click the `+ Create Tag` button to open the **CREATE NEW TAG** dialog:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FTRWLP3Ik8dTtEHNadvvm%2Fimage.png?alt=media&#x26;token=4f95b317-f682-4c47-807e-d091ed8483ad" alt="" width="486"><figcaption></figcaption></figure>

* TAG NAME - Use a descriptive name to reference the tag, i.e. (stable, current, nightly)
* IMMUTABLE - Prevents the tag's properties from being edited or updated, the tag will always reflect the data state of the selected timestamp when the tag was created
* ENVIRONMENT - Choose the Environment to which the new tag will be applied
* DESCRIPTION - Further describe the tag's purpose
* TIMESTAMP - Choose a date and time for the parameter values the tag will represent (defaults to current date and time).

### Editing a Tag

You can edit the timestamp, description, or make a tag immutable by selecting `Edit Tag` from the environment tag's ACTIONS menu:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2F7IHg77vJ6lByLqAhejrj%2Fimage.png?alt=media&#x26;token=f7d2ee48-0549-4132-ab6d-aeb36daac537" alt=""><figcaption></figcaption></figure>

Editing the timestamp of a tag will allow you to set the time and date to the last known good configuration in a tag e.g. `stable`:

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2Fm6mkFYwKibqQH8WPD82g%2Fimage.png?alt=media&#x26;token=b7bfd8b9-5b82-4f35-b5c6-86517dfd7273" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Updating a tag will automatically initiate any associated push actions.
{% endhint %}

Setting the `IMMUTABLE` option is useful when you need to take a snapshot of parameter and parameter values in a known good state before making any updates to those parameters. Once a tag has been set to immutable, the timestamp can no longer be updated. This guarantees the  parameter and parameter values from that date and time will always be available to fall back to if needed. Immutable tags can only be deleted.

### Deleting a Tag

The environment tag's ACTIONS menu also allows you to delete your tags.

<figure><img src="https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2FRZSnEqC8kC3dv8QF8QgR%2Fimage.png?alt=media&#x26;token=fd27ce32-eb77-4917-b665-d1ac83694580" alt=""><figcaption></figcaption></figure>
