> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/harness-platform/new-experience/harness-platform-resources/secrets/secrets-management/custom-secret-manager.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# Add a custom secret manager

This topic explains how to create and use a Custom Secret Manager.

Harness includes a built-in Secrets Management feature that enables you to store encrypted secrets, such as access keys, and use them in your Harness account.

You can also access your encrypted secrets stored in third-party Secret Managers using the Harness Custom Secret Manager.

This topic explains how to add and use a Custom Secret Manager in Harness.

## Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

* [Harness Secret Manager Overview](https://developer.harness.io/harness-platform/new-experience/harness-platform-resources/secrets/secrets-management/harness-secret-manager-overview.md)
* [Store authentication credentials](https://developer.harness.io/harness-platform/new-experience/harness-platform-resources/secrets/secrets-management/store-authentication-credentials.md)

### Permissions <a href="#permissions" id="permissions"></a>

The following permissions are required to create a custom secret manager. However, these permissions are not required to use the custom resource manager after it is created.

* Create/Edit Secrets
* Create/Edit Connectors

{% hint style="info" %}
**IMPORTANT**

* Harness Custom Secret Manager is a read-only Secret Manager. It is not possible to create reference secrets. However, Harness Custom Secret Manager enables you to define templates that include logic to connect to and retrieve secrets from the secret manager. Your template specifies how the secret is retrieved and whether it is a string or JSON format.
* Harness can read/decrypt secrets, but it cannot write secrets to the Custom Secrets Manager.
  {% endhint %}

## Harness Custom Secret Manager overview <a href="#harness-custom-secret-manager-overview" id="harness-custom-secret-manager-overview"></a>

Harness includes a built-in Secrets Management feature that enables you to store encrypted secrets, such as access keys, and use them in your Harness Account.

Harness integrates with the following third-party Secret Managers along with a built-in Secret Manager:

* AWS KMS
* AWS Secrets Manager
* Azure Key Vault
* GCP KMS
* HashiCorp Vault

You can use third-party Secrets Managers not integrated with Harness to store encrypted secrets. With Harness Custom Secret Manager, you can integrate Harness with your third-party Secret Managers and read or access your secrets.

Your Custom Secret Manager uses a shell script that you can execute either on a delegate or on a remote host which is connected to the delegate. Harness fetches and reads your secrets from the third-party Secret Manager through this shell script.

### Step 1: Create a Secret Manager Template <a href="#step-1-create-a-secret-manager-template" id="step-1-create-a-secret-manager-template"></a>

You can create a Secret Manager Template at the account, org, or project [scope](https://developer.harness.io/harness-platform/new-experience/harness-platform-resources/platform-access-control.md#permissions-hierarchy-scopes).

This topic shows you how to create a Secret Manager Template at the Project scope.

1. In your Harness Account, go to your Project.
2. Select **Project Settings**, then under **Project-level resources**, select **Templates**.
3. Select **New Template**, then select **Secret Manager**.
4. Enter a **Name** for your template.
5. (Optional) In **Description**, select the pencil icon and enter a description.
6. (Optional) In **Tags**, select the pencil icon and assign a tag.
7. Enter a **Version Label**.
8. (Optional) Select the upload icon and upload a **Logo**.
9. Under **Save To**, select **Project**, then select **Start**.
10. Select your **Script Type**, then select your script location.
11. Enter your script in **Script**, then select **Save**.

For detailed steps to create a Secret Manager Template, go to [Create a Secret Manager Template](https://app.gitbook.com/s/3F2TpHXhur2QtQnORSM9/harness-platform-resources/templates/create-a-secret-manager-template).

### Step 2: Add a Custom Secret Manager <a href="#step-2-add-a-custom-secret-manager" id="step-2-add-a-custom-secret-manager"></a>

You can add a Custom Secret Manager at the account, org, and project scope.

To do this, go to Project, Organization, or Account settings.

This topic shows you how to add a Custom Secret Manager in the project scope.

1. In your Harness Account, go to your Project.
2. In Project Setup, select **Connectors** and then select **New Connector**.
3. In **Secret Managers**, select **Custom Secret Manager**. The Custom Secret Manager settings open.
4. Enter a **Name** for your Custom Secret Manager. Select **Continue**.
5. Select **Select Template**. The Template Library appears with all the [Secret Manager Templates](https://app.gitbook.com/s/3F2TpHXhur2QtQnORSM9/harness-platform-resources/templates/create-a-secret-manager-template) listed.
6. Select the desired scope and select a Secret Manager Template from the Template Library.

   You can also search for a specific Secret Manager Template by entering its name in **Search**. Once you select the Secret Manager Template, the details are displayed in the Template Studio.
7. Select **Use Template**.
8. Enter values for the required Input Variables. Harness allows you to use [Fixed Values, Runtime Inputs and Expressions](https://developer.harness.io/harness-platform/new-experience/harness-platform-resources/variables-and-expressions/runtime-inputs.md).

{% hint style="info" %}
Only Secret and Variable expressions are supported within Expressions.
{% endhint %}

![](https://204875495-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiHCl4N3pQkjhOYjQoOs7%2Fuploads%2Fgit-blob-2a3c6d557c6d33c9216a988eede621fe355f557c%2Fcustom-secret-manager-36.png?alt=media)

9\. Select **Fixed** to make the variable values fixed. Harness will not ask you these values when you create Secrets. 10. Select **Continue**. 11. In **Delegates** **Setup**, enter [**Selectors**](https://developer.harness.io/harness-platform/use-harness-platform/delegates/delegate/manage-delegates/select-delegates-with-selectors.md#option-select-a-delegate-for-a-connector-using-tags) for specific **Delegates** that you want to allow to connect to this Connector. Select **Save and Continue**. 12. In **Connection Test**, select **Finish** after your connection is successful.

### Step 3: Use the Custom Secret Manager <a href="#step-3-use-the-custom-secret-manager" id="step-3-use-the-custom-secret-manager"></a>

Create an Encrypted Text using the Custom Secrets Manager you created earlier. Enter the name and values of all the Input Variables defined while creating the Shell Script Template.

Go to [Add Encrypted Text](https://developer.harness.io/harness-platform/new-experience/harness-platform-resources/secrets/add-use-text-secrets.md) to create an Encrypted Text Secret.

If you want to create a secret on a Target Host Custom Secrets Manager, you must also select the Connection Attribute.

### Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

Use the following to resolve common Custom Secret Manager issues.

* **The connection test fails in Connection Test:** Confirm the Delegate selectors entered in **Delegates Setup** match tags on a Delegate that can reach the target host or service the Custom Secret Manager Template's script connects to.
* **A required Input Variable has no value prompt when creating a Secret:** Confirm the variable is set to **Runtime Input** rather than **Fixed**, since a Fixed value is set once on the Custom Secret Manager and never prompts again.
* **A Target Host Custom Secret Manager cannot resolve the secret:** Confirm you selected the correct **Connection Attribute** when creating the Secret, since the Custom Secret Manager uses it to reach the specific target host.

## Related concepts <a href="#related-concepts" id="related-concepts"></a>

* [Harness Secret Manager overview](https://developer.harness.io/harness-platform/new-experience/harness-platform-resources/secrets/secrets-management/harness-secret-manager-overview.md)
* [Store authentication credentials](https://developer.harness.io/harness-platform/new-experience/harness-platform-resources/secrets/secrets-management/store-authentication-credentials.md)

{% @harness-feedback/feedback %}
