> 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-ai/use-harness-platform/connectors/cloud-providers/add-a-spot-connector.md).

# Add a Spot connector

Connect Harness to your Spot account for Elastigroup deployments.

Use a Harness Spot connector to connect Harness to your Spot account. Use the Spot connector to provision and deploy to Spot Elastigroup resources from Harness pipelines.

***

## What you will learn from this topic

* How to [create a Spot connector](#create-a-spot-connector) using the Harness Manager.
* How to [create a Spot connector using the API](#create-a-spot-connector-using-the-api).
* How to define a Spot connector using a [YAML example](#yaml-example).
* How to create a Spot connector using the [Harness Terraform Provider](#terraform-provider-examples).

***

## Before you begin

* **Spot account ID and API token**: Harness authenticates to your Spot account using a permanent token. Go to [Get your account ID](https://docs.flexera.com/spot/administration/organizations/#get-your-account-id) and [Create an API token](https://docs.flexera.com/spot/administration/api/create-api-token) to generate a Spot account ID and API token.
* **Harness Delegate**: A running Harness Delegate that can reach your Spot account. Go to [Delegate installation overview](/harness-ai/use-harness-platform/delegates/delegate/install-delegates/overview.md) to install one. Connect through a Harness Delegate rather than the Harness Platform, because you need a delegate later when you deploy to your Spot cloud.

***

## Create a Spot connector <a href="#create-a-spot-connector" id="create-a-spot-connector"></a>

Perform the following steps to create the Spot connector using the Harness Manager.

1. Open a Harness project, and select **Connectors** under **Project Setup**. You can also create connectors at the account or organization levels.
2. Select **New Connector**, and then select **Spot** under **Cloud Providers**.

### Overview <a href="#overview" id="overview"></a>

Enter a **Name** for the connector. **Description** and **Tags** are optional. Harness automatically creates an **Id** ([entity identifier](/harness-ai/use-harness-platform/references/entity-identifier-reference.md)) for the connector based on the **Name**. Select **Continue** to proceed to **Credentials**.

![Spot connector overview step](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-7b254c12de971472914b7a8d725057a69cf1a71b%2FSpot-connector-overview.png?alt=media)

### Credentials <a href="#credentials" id="credentials"></a>

Under **Authentication**, select one of the following options for the **Spot Account Id** field, and then select **Continue**:

* **Plaintext**: Enter the **Spot Account Id** directly, and select **Create or Select a Secret** to add the **API Token**.
* **Encrypted**: Create or select a secret for both the Spot account ID and the API token.

![Spot connector credentials step](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-75db210581593f1de649e511d81d1766103eb3f5%2Fspot-connector-credentials.png?alt=media)

### Select Connectivity Mode <a href="#select-connectivity-mode" id="select-connectivity-mode"></a>

Under **Connect to the provider**, select how you want Harness to connect to Spot, and then select **Save and Continue**:

* **Connect through Harness Platform**: Harness communicates with Spot securely through the Harness Platform. Credentials are encrypted and stored in the Secret Manager configured in Harness.
* **Connect through a Harness Delegate**: Harness communicates with Spot through a Harness Delegate installed in your environment. Select this option if Spot is behind a corporate firewall.

{% hint style="info" %}
A Harness Delegate is used for deployment operations even if you select **Connect through Harness Platform**.
{% endhint %}

![Spot connector connectivity mode step](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-430731673f6444dfc2692699ac3394d7e3b07d02%2Fspotconnector-connectivity-mode.png?alt=media)

### Delegates Setup <a href="#delegates-setup" id="delegates-setup"></a>

This step appears only if you selected **Connect through a Harness Delegate**. Select one of the following options, and then select **Save and Continue**:

* **Use any available Delegate**.
* **Only use Delegates with all of the following tags**: Enter the tag of the [delegate](#before-you-begin) you installed.

![Spot connector delegates setup step](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-bdf2271bdbac0e374431592b3320b079dacc0075%2Fspot-delegate-setup.png?alt=media)

### Connection Test <a href="#connection-test" id="connection-test"></a>

Harness validates the Spot connector authentication and permissions. Once verification succeeds, select **Finish**.

![Spot connector connection test step](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-205e79dca51b779c88d63b8de45a0e7107383376%2Fspot-connection-test.png?alt=media)

The connector now appears in the **Connectors** list.

***

## Create a Spot connector using the API <a href="#create-a-spot-connector-using-the-api" id="create-a-spot-connector-using-the-api"></a>

Create the Spot connector using the [Create a Connector](https://apidocs.harness.io/tag/Connectors#operation/createConnector) API. The request sends the connector definition as JSON in the request body.

<details>

<summary>Create Connector API request</summary>

```bash
curl --location --request POST 'https://app.harness.io/gateway/ng/api/connectors?accountIdentifier=<YOUR_ACCOUNT_ID>' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <YOUR_API_KEY>' \
--data-raw '{
  "connector": {
    "name": "Spot-Connector",
    "identifier": "SpotConnector",
    "description": "",
    "orgIdentifier": "default",
    "projectIdentifier": "CD_Docs",
    "type": "Spot",
    "spec": {
      "credential": {
        "type": "PermanentTokenConfig",
        "spec": {
          "spotAccountId": "<YOUR_SPOT_ACCOUNT_ID>",
          "apiTokenRef": "<YOUR_API_TOKEN_SECRET_REF>"
        }
      },
      "executeOnDelegate": true
    }
  }
}'
```

</details>

The request uses the following query parameter, headers, and body fields.

* **`accountIdentifier`** (query parameter, required): The identifier of the Harness account where the connector is created. Replace `<YOUR_ACCOUNT_ID>` with your account identifier.
* **`Content-Type`** (header, required): Set to `application/json` because the request body is JSON.
* **`x-api-key`** (header, required): A Harness API key with permission to create connectors in the target scope. Replace `<YOUR_API_KEY>` with your API key. For details on creating one, go to [Add and manage API keys](/harness-ai/use-harness-platform/automation/api/add-and-manage-api-keys.md).
* **`connector.name`**: The connector display name shown in the Harness UI.
* **`connector.identifier`**: A unique identifier for the connector. You cannot change the identifier after creation. For the identifier format, go to the [Entity Identifier reference](/harness-ai/use-harness-platform/references/entity-identifier-reference.md).
* **`connector.description`**: An optional description for the connector.
* **`connector.orgIdentifier`**: The identifier of the organization that owns the connector. Omit this field to create the connector at the account scope.
* **`connector.projectIdentifier`**: The identifier of the project that owns the connector. Omit this field to create the connector at the account or organization scope. A project-scoped connector requires `orgIdentifier` as well.
* **`connector.type`**: The connector type. Use `Spot` for a Spot connector.
* **`connector.spec.credential.type`**: The authentication method. Use `PermanentTokenConfig` to authenticate with a Spot account ID and API token.
* **`connector.spec.credential.spec.spotAccountId`**: Your Spot account ID. Replace `<YOUR_SPOT_ACCOUNT_ID>` with your account ID, or use `spotAccountIdRef` instead to reference the value from a secret.
* **`connector.spec.credential.spec.apiTokenRef`**: A reference to the Harness secret that stores your Spot API token. Replace `<YOUR_API_TOKEN_SECRET_REF>` with your secret reference.
* **`connector.spec.executeOnDelegate`**: Set to `true` to connect through a Harness Delegate, or `false` to connect through the Harness Platform.

***

## YAML example <a href="#yaml-example" id="yaml-example"></a>

The following YAML defines a Spot connector that authenticates using a permanent token.

<details>

<summary>Spot connector YAML</summary>

```yaml
connector:
  name: Spot-Connector # Connector display name shown in the Harness UI
  identifier: SpotConnector # Unique connector identifier, cannot be changed after creation
  description: "" # Optional description for the connector
  orgIdentifier: default # Harness org identifier that owns the connector
  projectIdentifier: CD_Docs # Harness project identifier that owns the connector
  type: Spot
  spec:
    credential:
      type: PermanentTokenConfig
      spec:
        spotAccountId: <YOUR_SPOT_ACCOUNT_ID> # Your Spot account ID
        apiTokenRef: <YOUR_API_TOKEN_SECRET_REF> # Harness secret reference storing your Spot API token
    executeOnDelegate: true # Set to false to connect through the Harness Platform instead of a delegate
```

</details>

***

## Terraform Provider examples <a href="#terraform-provider-examples" id="terraform-provider-examples"></a>

You can also create a Spot connector using the [Harness Terraform Provider](https://registry.terraform.io/providers/harness/harness/latest/docs/resources/platform_connector_spot).

<details>

<summary>Create a Spot connector using a permanent token and a plaintext Spot account ID</summary>

```hcl
resource "harness_platform_connector_spot" "spot" {
  identifier  = "example_spot_cloud_provider"
  name        = "Example spot cloud provider"
  description = "description of spot connector"
  tags        = ["foo:bar"]
  permanent_token {
    spot_account_id    = "<YOUR_SPOT_ACCOUNT_ID>"
    api_token_ref      = "account.<YOUR_API_TOKEN_SECRET_REF>"
    delegate_selectors = ["harness-delegate"]
  }
}
```

</details>

<details>

<summary>Create a Spot connector using a permanent token and a secret-referenced Spot account ID</summary>

```hcl
resource "harness_platform_connector_spot" "spot" {
  identifier  = "example_spot_cloud_provider"
  name        = "Example spot cloud provider"
  description = "description of spot connector"
  tags        = ["foo:bar"]
  permanent_token {
    spot_account_id_ref = "account.<YOUR_SPOT_ACCOUNT_ID_SECRET_REF>"
    api_token_ref       = "account.<YOUR_API_TOKEN_SECRET_REF>"
    delegate_selectors  = ["harness-delegate"]
  }
}
```

</details>

<details>

<summary>Connect through the Harness Platform instead of a delegate</summary>

By default, the Spot connector connects through a Harness Delegate. Set `execute_on_delegate` to `false` to connect through the Harness Platform instead.

```hcl
resource "harness_platform_connector_spot" "spot" {
  identifier  = "example_spot_cloud_provider"
  name        = "Example spot cloud provider"
  description = "description of spot connector"
  tags        = ["foo:bar"]
  permanent_token {
    spot_account_id     = "<YOUR_SPOT_ACCOUNT_ID>"
    api_token_ref       = "account.<YOUR_API_TOKEN_SECRET_REF>"
    delegate_selectors  = ["harness-delegate"]
    execute_on_delegate = false
  }
}
```

</details>

***

## Next steps <a href="#next-steps" id="next-steps"></a>

* [Delegate installation overview](/harness-ai/use-harness-platform/delegates/delegate/install-delegates/overview.md): Install and configure a Harness Delegate for your Spot connector.
* [Harness Terraform Provider connector resources](https://registry.terraform.io/providers/harness/harness/latest/docs/resources/platform_connector_spot): Manage the Spot connector using Terraform.

{% @harness-feedback/feedback module="harness-ai" pagePath="harness-ai/use-harness-platform/connectors/cloud-providers/add-a-spot-connector" %}
