> 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/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/aws/spot/spot-deployment.md).

# Spot Elastigroup

Deploy a Spot Elastigroup using Harness Continuous Delivery.

Harness deploys AWS Auto Scaling Group (ASG) workloads through Spot Elastigroups using the Basic, Canary, and Blue Green execution strategies.

{% hint style="info" %}
Spot Elastigroup support is behind the feature flag `CDS_SPOT_ELASTIGROUP_NG`. Contact [Harness Support](mailto:support@harness.io) to enable the feature.
{% endhint %}

## What you will learn from this topic

* How to connect Harness to a Spot cloud provider.
* How to build a Spot Elastigroup pipeline with a service, environment, and execution strategy.
* How to configure Basic, Canary, and Blue Green Spot Elastigroup deployments.

## Before you begin

Complete the following before you build the Spot Elastigroup pipeline:

* Review the requirements and limitations in the following section.
* Make sure your Spot account is connected to the AWS cloud provider.

## Requirements and limitations <a href="#requirements-and-limitations" id="requirements-and-limitations"></a>

Spot Elastigroup deployments have the following requirements and limitations:

* Harness integrates with Spot only for Amazon Web Services (AWS) deployments by using Elastigroups.
* Spot Elastigroup deployments support Amazon Machine Image (AMI) artifacts only.
* Spot Elastigroup deployments support only Basic, Canary, and Blue Green execution types.
* Your Spot account must be connected to the AWS cloud provider. Go to [Connect your cloud account to Spot](https://docs.spot.io/connect-your-cloud-provider/aws-account) to set this up.
* Harness supports using Spot Elastigroup with an **OpenID Connect (OIDC)-enabled AWS connector**, but it requires Delegate version `854xx` or later. Go to the [AWS OIDC connector reference](https://developer.harness.io/harness-platform/use-harness-platform/connectors/cloud-providers/add-aws-connector/aws-connector-settings-reference) for details.

## Connect to a Spot cloud provider <a href="#connect-to-a-spot-cloud-provider" id="connect-to-a-spot-cloud-provider"></a>

You can connect Harness to a Spot cloud provider by adding a [Harness Spot Elastigroup connector](https://developer.harness.io/harness-platform/use-harness-platform/connectors/cloud-providers/add-a-spot-connector) or [AWS connector](https://developer.harness.io/harness-platform/use-harness-platform/connectors/cloud-providers/add-aws-connector).

To connect to a Spot cloud provider using the Spot API, go to [Spot API authentication](https://docs.spot.io/api/#section/Authentication) to review the authentication requirements.

To use an AWS connector, go to [Connect your cloud account to Spot](https://docs.spot.io/connect-your-cloud-provider/aws-account) to connect your Spot account to the AWS cloud provider first.

## Create the Harness Spot Elastigroup pipeline <a href="#create-the-harness-spot-elastigroup-pipeline" id="create-the-harness-spot-elastigroup-pipeline"></a>

You can create a service and environment either when you are building the pipeline or separately in **Services** and **Environments**. This topic walks you through building these within a pipeline.

The pipeline models the release process using execution steps, triggers, and other settings. For more information, go to [CD pipeline modeling overview](/continuous-delivery/troubleshooting-and-resources/resources/new-user/cd-pipeline-modeling-overview.md).

{% tabs %}
{% tab title="Pipeline Studio" %}
Perform the following steps to create the pipeline:

1. In your Harness Project, select **Deployments**.
2. Select **Pipelines**, and then select **Create a Pipeline**.
3. Enter the name **Spot Tutorial** for the pipeline, and then select **Start**.
4. Select **Add Stage**.
5. Select **Deploy**.
6. In **Stage Name**, enter **Spot Tutorial**.
7. In **Deployment Type**, select **Spot Elastigroup**, and then select **Set Up Stage**.

The new stage is created. Next, add a Harness service to represent the application you are deploying, and configure the service with the Spot Elastigroup service definition, artifacts, environment definition, and infrastructure for deployment.

### Add a Harness service <a href="#add-a-harness-service" id="add-a-harness-service"></a>

Harness services represent your microservices or applications. You can add the same service to as many stages as you need. For more information, go to [services overview](/continuous-delivery/use-continuous-delivery/cd-building-blocks/services/services-overview.md).

{% tabs %}
{% tab title="YAML" %}
The following is a sample Spot service YAML:

```yaml
service:
  name: spot-svc
  identifier: spotsvc
  serviceDefinition:
    type: Elastigroup
    spec:
      artifacts:
        primary:
          primaryArtifactRef: <+input>
          sources:
            - identifier: spot_ami
              spec:
                connectorRef: org.myAWSConnector
                region: us-east-1
                version: <+input>.allowedValues(asgAmi-Orderv2,asgAmi-Order)
              type: AmazonMachineImage
  gitOpsEnabled: false
```

{% endtab %}

{% tab title="Harness Manager" %}
Perform the following steps to configure the service:

1. Select the **Service** tab, then select **Add Service**.
2. Enter a service name, for example, spot-svc.

   Services are persistent and can be used throughout the stages of this pipeline or any other pipeline in the project.
3. In **Service Definition**, in **Deployment Type**, verify that **Spot Elastigroup** is selected.
4. In **Artifacts**, select **Add Artifact Source**.
5. In **Specify Artifact Repository Type**, select **Amazon Machine Image**, and then select **Continue**.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p><strong>IMPORTANT</strong></p><p>Spot Elastigroup deployments support AMI artifacts only.</p></div>
6. In **Amazon Machine Image Repository**, select **New AWS Connector**.
7. Enter a name for the connector, and then select **Continue**.
8. In **Credentials**, select **AWS Access Key**.
9. In **Authentication**, select one of the following options.
   * **Plaintext**: Enter the [**Access Key** and **Secret Key**](https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds.html#access-keys-and-secret-access-keys). For Secret Key, you can either create a new secret or use an existing one.
   * **Encrypted**: You can create or select a secret for your Access Key and Secret Key.
10. Select **Enable cross-account access (STS Role)** if you want to use one AWS account for the connection, but want to deploy or build in a different AWS account.

    In this scenario, the AWS account used for AWS access in credentials will assume the IAM role you specify in cross-account role ARN setting. This option uses the [AWS Security Token Service (STS)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html) feature.
11. In **Test Region**, select an AWS region to test the credentials for this connector.
12. In **Delegates Setup**, select **Only use Delegate with all of the following tags** and enter the name of the delegate created when creating the [Harness Spot Elastigroup connector](https://developer.harness.io/harness-platform/use-harness-platform/connectors/cloud-providers/add-a-spot-connector).
13. Select **Save and Continue**.
14. After the connection test succeeds, select **Continue**.
15. In **Artifact Details**, enter the following details:

    1. In **Artifact Source Identifier**, enter a name for the artifact.
    2. In **Region**, select the region where the artifact is located.
    3. (Optional) In **AMI Tags**, add the tags used by your AMI.
    4. (Optional) In **AMI Filters**, add the AMI ID filters to locate the AMI resource.
    5. In **Version Details**, select **Value** to enter the version number of the package you want to use. You can also select **Regex**, and then enter a tag regex to filter the package version.

    ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-c74a2e34307b6941f24c58240dc545ac36e99143%2Fspot-artifacts-ami.png?alt=media)
16. Select **Submit**.
17. Select **Save** to save the service configuration.
    {% endtab %}
    {% endtabs %}

### Add a Spot environment <a href="#add-a-spot-environment" id="add-a-spot-environment"></a>

Define the environment where you deploy your application.

{% tabs %}
{% tab title="YAML" %}
The following is a sample infrastructure definition YAML:

```yaml
infrastructureDefinition:
  name: spot-infra
  identifier: spotinfra
  description: ""
  tags: {}
  orgIdentifier: myorg
  projectIdentifier: myproject
  environmentRef: Spot
  deploymentType: Elastigroup
  type: Elastigroup
  spec:
    connectorRef: spotinstconn
    configuration:
      store:
        type: Harness
        spec:
          files:
            - /spot/spot-cfg
  allowSimultaneousDeployments: false
```

{% endtab %}

{% tab title="Harness Manager" %}
Perform the following steps to configure the environment:

1. In **Environment**, select **New Environment**.
2. Enter the name **Spot**, and then select **Production** or **Pre-Production**.
3. Select **Save**.
4. In **Specify Infrastructure**, select **New Infrastructure**.
5. Enter a name, and then verify that the selected deployment type is **Spot Elastigroup**.
6. Select the [Spot connector](#connect-to-a-spot-cloud-provider) you created earlier.
7. In **Elastigroup Configuration**, select an Elastigroup configuration source file from the [Harness file store](/continuous-delivery/use-continuous-delivery/cd-building-blocks/services/add-inline-manifests-using-file-store.md) or create a new file.

<details>

<summary>Sample Elastigroup configuration source file</summary>

```json
{
  "group": {
    "name": "spotinst__ser__env",
    "capacity": {
      "minimum": 1,
      "maximum": 1,
      "target": 1,
      "unit": "instance"
    },
    "strategy": {
      "risk": 100,
      "availabilityVsCost": "balanced",
      "drainingTimeout": 120,
      "fallbackToOd": true,
      "scalingStrategy": {},
      "persistence": {},
      "revertToSpot": {
        "performAt": "always"
      }
    },
    "compute": {
      "instanceTypes": {
        "ondemand": "t2.small",
        "spot": [
          "m3.medium",
          "t2.small",
          "t3.small",
          "t3a.small",
          "t2.medium",
          "t3.medium",
          "t3a.medium"
        ]
      },
      "availabilityZones": [
        {
          "name": "us-east-1a",
          "subnetIds": [
            "<SUBNET_ID>"
          ]
        },
        {
          "name": "us-east-1b",
          "subnetIds": [
            "<SUBNET_ID>"
          ]
        },
        {
          "name": "us-east-1c",
          "subnetIds": [
            "<SUBNET_ID>"
          ]
        },
        {
          "name": "us-east-1d",
          "subnetIds": [
            "<SUBNET_ID>"
          ]
        },
        {
          "name": "us-east-1e",
          "subnetIds": [
            "<SUBNET_ID>"
          ]
        },
        {
          "name": "us-east-1f",
          "subnetIds": [
            "<SUBNET_ID>"
          ]
        }
      ],
      "product": "Linux/UNIX",
      "launchSpecification": {
        "loadBalancersConfig": {
          "loadBalancers": [
            {
              "name": "asg-tg6",
              "arn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/asg-tg6/abc123def456abcd",
              "type": "TARGET_GROUP"
            }
          ]
        },
        "securityGroupIds": [
         "<SECURITY_GROUP_ID>"
        ],
        "monitoring": false,
        "ebsOptimized": false,
        "imageId": "<AMI_ID>",
        "keyPair": "my-aws-keypair",
        "tenancy": "default"
      }
    },
    "scaling": {},
    "scheduling": {},
    "thirdPartiesIntegration": {}
 }
}
```

</details>

8. Select **Save**.
   {% endtab %}
   {% endtabs %}

### Spot Elastigroup pipeline execution strategies <a href="#spot-elastigroup-pipeline-execution-strategies" id="spot-elastigroup-pipeline-execution-strategies"></a>

You can select a [deployment strategy](/continuous-delivery/use-continuous-delivery/manage-deployments/deployment-concepts.md) for this stage of the pipeline.

{% hint style="info" %}
Spot Elastigroup deployments support only Basic, Canary, and Blue Green execution types.
{% endhint %}

{% tabs %}
{% tab title="Basic" %}
Spot Elastigroups perform the functions that Auto Scaling Groups perform in standard AMI deployments. By default, a Harness Spot Elastigroup Basic deployment pre-configures the following steps:

* Elastigroup Setup: Specify how many instances to launch, and their steady state timeout.
* Elastigroup Deploy: Specify how many instances to deploy, as a number or percentage of the Elastigroup parameters you have set up.

Perform the following steps to apply the Basic strategy:

1. In **Execution Strategies**, select **Basic**, then select **Use Strategy**.
2. The basic execution steps are added.

   ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-48dcd095dfd0095daf3a6cd349e41c8b3ee6bb19%2Fspot-basic.png?alt=media)
3. Select the **Elastigroup Setup** step to define **Step Parameters**.
   * **Name**: Enter the deployment step name.
   * **Timeout**: Set how long you want the Harness Delegate to wait for the Spot cloud to respond to API requests before timeout.
   * **App Name**: Enter a name for the Elastigroup app name that Harness creates. For example, you can use Harness expressions, such as `<+project.identifier>_<+service.identifier>_<+env.identifier>_basic2`. You can select a fixed value, runtime input, or expression for this field.
   * In **Instances**, select:
     * **Same as already running instances**: Replicate the already running instances.
     * **Fixed**: Enter **Min Instances**, **Max Instances**, and **Desired Instances**.
4. Select the **Elastigroup Deploy** step to define **Step Parameters**.
   * **Name**: Enter the deployment step name.
   * **Timeout**: Set how long you want the Harness Delegate to wait for the Spot cloud to respond to API requests before timeout.
   * **New Service**: Select:
     * **Percent**: Specify a percentage of the target instances that you set in the **Elastigroup Setup** step.
     * **Count**: Specify the exact number of instances. This cannot exceed the **Max Instances** that you set in the **Elastigroup Setup** step.
5. In the **Advanced** settings of all steps, you can use the following options:
   * [Delegate Selector](https://developer.harness.io/harness-platform/use-harness-platform/delegates/delegate/manage-delegates/select-delegates-with-selectors)
   * [Conditional Execution](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/step-skip-condition-settings)
   * [Failure Strategy](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps)
   * [Looping Strategy](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/looping-strategies/looping-strategies-matrix-repeat-and-parallelism)
   * [Policy Enforcement](https://developer.harness.io/harness-platform/use-harness-platform/governance/policy-as-code/harness-governance-overview)
6. Select **Apply Changes**.
7. Select **Save**.
   {% endtab %}

{% tab title="Canary" %}
Spot Elastigroups perform the functions that Auto Scaling Groups perform in standard AMI deployments. By default, Harness Spot Elastigroup Canary deployment pre-configures the following steps:

* Elastigroup Setup: Specify how many instances to launch, and their steady state timeout.
* Elastigroup Canary Deploy: Specify how many instances to deploy in this phase. When you add additional phases, each phase automatically includes an Elastigroup Deploy step, which you must configure with the count or percentage of instances you want deployed in that phase.
* Elastigroup Deploy: Specify how many instances to deploy, as a number or percentage of the Elastigroup parameters you have set up.

Perform the following steps to apply the Canary strategy:

1. In **Execution Strategies**, select **Canary**, and then click **Use Strategy**.
2. The canary execution steps are added.

   ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-80a47a3b40686e5e050af3af5eeda43408959cbb%2Fspot-canary.png?alt=media)
3. Select the **Elastigroup Setup** step to define **Step Parameters**.
   * **Name**: Enter the deployment step name.
   * **Timeout**: Set how long you want the Harness Delegate to wait for the Spot cloud to respond to API requests before timeout.
   * **App Name**: Enter a name for the Elastigroup app name that Harness creates. For example, `<+project.identifier>_<+service.identifier>_<+env.identifier>_basic2`. You can select a fixed value, runtime input, or expression for this field.
   * In **Instances**, select:
     * **Same as already running instances**: Replicate the already running instances.
     * **Fixed**: Enter **Min Instances**, **Max Instances**, and **Desired Instances**.
4. Select the **Elastigroup Canary Deploy** step to define **Step Parameters**.
   * **Name**: Enter the deployment step name.
   * **Timeout**: Set how long you want the Harness Delegate to wait for the Spot cloud to respond to API requests before timeout.
   * **New Service**: Select:
     * **Percent**: Specify a percentage of the target instances that you set in the **Elastigroup Setup** step.
     * **Count**: Specify the exact number of instances. This cannot exceed the **Max Instances** that you set in the **Elastigroup Setup** step.
5. Select the **Elastigroup Deploy** step to define **Step Parameters**.
   * **Name**: Enter the deployment step name.
   * **Timeout**: Set how long you want the Harness Delegate to wait for the Spot cloud to respond to API requests before timeout.
   * **New Service**: Select:
     * **Percent**: Specify a percentage of the target instances that you set in the **Elastigroup Setup** step.
     * **Count**: Specify an exact number of instances. This cannot exceed the **Max Instances** that you set in the **Elastigroup Setup** step.
6. In the **Advanced** settings of all steps, you can use the following options:
   * [Delegate Selector](https://developer.harness.io/harness-platform/use-harness-platform/delegates/delegate/manage-delegates/select-delegates-with-selectors)
   * [Conditional Execution](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/step-skip-condition-settings)
   * [Failure Strategy](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps)
   * [Looping Strategy](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/looping-strategies/looping-strategies-matrix-repeat-and-parallelism)
   * [Policy Enforcement](https://developer.harness.io/harness-platform/use-harness-platform/governance/policy-as-code/harness-governance-overview)
7. Select **Apply Changes**.
8. Select **Save**.
   {% endtab %}

{% tab title="Blue Green" %}
Spot Elastigroups perform the functions that Auto Scaling Groups perform in standard AMI deployments.

<details>

<summary>AWS requirements</summary>

Make sure the following AWS requirements are met:

* A pair of [Target Groups](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html) (TG), typically staging (Stage) and production (Prod) both with the **instance** target type.
* A load balancer with listeners for both your Target Groups' ports.
* AWS Elastic Load Balancer (ELB) setup:

  * AWS Application Load Balancer (ALB) configured with one [Listener](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-listener.html).
  * The Listener must have a [Rule](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-update-rules.html) redirecting to two [TGs](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).
  * Registered target instances for the TGs.

  ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-6904274d36421e897cd88b107d54ab1d5e5af0bf%2Faws-elb.png?alt=media)

</details>

By default, Harness Spot Elastigroup Blue Green deployment pre-configures the following steps:

* Elastigroup Blue Green Stage Setup: Specify the production and stage listener ports and rules to use. The new Spot Elastigroup is deployed to the stage target group.
* Elastigroup Swap Route:
  1. Harness modifies the ELB prod listener to forward requests to target groups associated with each new Spot Elastigroup version.
  2. Harness swaps all traffic from stage to production listeners and ports.
  3. Harness modifies the ELB stage listener to forward requests to target groups associated with old Spot Elastigroup version.

This deployment method lets you add steps to incrementally shift traffic from the Target Group used by the previous Elastigroup to the Target Group used by the new Elastigroup you are deploying.

<details>

<summary>Traffic shift summary</summary>

In this strategy, you specify production and stage listener ports and rules to use in the Spot Elastigroup Blue Green Stage Setup step. Next, the Elastigroup Swap Route step swaps all traffic from stage to production.

A Blue Green deployment reliably deploys your Elastigroups by maintaining new and old versions of the Elastigroup. The Elastigroups run behind an ALB using two listeners, stage and prod. These listeners forward respectively to two target groups, stage and prod, where the new and old ASGs are run.

In the first stage of deployment, the new Elastigroup is attached to the stage TG:

![first stage](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-72ae8c15207215b6be7d281323b2c5f0dbc309d8%2Fea87f58fb9e638f26d1c0a7cefde20158f4ad3c88496b3de827121992dd0ba0a.png?alt=media)

Blue Green deployments are achieved by swapping routes between the TGs always attaching the new Elastigroup first to the stage TG, and then to the prod TG:

![second stage](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-689766eddd36cfa7db27ea791700a3de2c90c6a4%2F88aa5c64d8375bea18c47e77b218c94fae1d06e6652c984c912d795132e84e63.png?alt=media)

</details>

With this strategy, you are not shifting traffic from stage and production environments. You are shifting traffic incrementally for a production environment. In this way, it is similar to a Canary strategy.

However, in a Canary deployment, the percentage of traffic that goes to the new Elastigroup is determined by the number of instances or the forwarding policy of the load balancer.

With this incremental traffic shift strategy, you are controlling the percentage of traffic sent to the new Elastigroup.

The Blue Green strategy above moves all traffic from stage to production in a single Elastigroup Swap Route step. If you need to shift traffic gradually with approval gates between phases, go to [Elastigroup Blue-Green traffic shifting step](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/aws/spot/spot-traffic-shifting.md) to configure incremental traffic shifting with ALB weighted target groups.

Perform the following steps to apply the Blue Green strategy:

1. In **Execution Strategies**, select **Blue Green**, and then click **Use Strategy**.
2. The blue green execution steps are added.

   ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-3651373fb5c7a14b76330787e6d757aacdbdeb3a%2Fspot-bg.png?alt=media)
3. Select the **Elastigroup Blue Green Stage Setup** step to define **Step Parameters**.
   * **Name**: Enter the deployment step name.
   * **Timeout**: Set how long you want the Harness Delegate to wait for the Spot cloud to respond to API requests before timeout.
   * **App Name**: Enter a name for the Elastigroup app name that Harness creates. For example, `<+project.identifier>_<+service.identifier>_<+env.identifier>`. You can select a fixed value, runtime input, or expression for this field.
   * In **Instances**, select:
     * **Same as already running instances**: Replicate the already running instances.
     * **Fixed**: Enter **Min Instances**, **Max Instances**, and **Desired Instances**.
   * In **Connected Cloud Provider**, you can override the connector and region you selected in the service configuration.
   * In **AWS Load Balancer Configuration**, select **Add** to add the ELB configuration:
     * **AWS Load Balancer**: Select the load balancer to use.
     * **Prod Listener**: Select the listener to use for prod traffic.
     * **Prod Listener Rule ARN**: Select the ARN for the prod listener rule.
     * **Stage Listener**: Select the listener to use for stage traffic.
     * **Stage Listener Rule ARN**: Select the ARN for the stage listener rule.
4. Select the **Elastigroup Swap Route** step to define **Step Parameters**.
   * **Name**: Enter the deployment step name.
   * **Timeout**: Set how long you want the Harness Delegate to wait for the Spot cloud to respond to API requests before timeout.
   * Select **Downsize old Elastigroup** to downsize the old Elastigroup.
5. In the **Advanced** settings of all steps, you can use the following options:
   * [Delegate Selector](https://developer.harness.io/harness-platform/use-harness-platform/delegates/delegate/manage-delegates/select-delegates-with-selectors)
   * [Conditional Execution](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/step-skip-condition-settings)
   * [Failure Strategy](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps)
   * [Looping Strategy](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/looping-strategies/looping-strategies-matrix-repeat-and-parallelism)
   * [Policy Enforcement](https://developer.harness.io/harness-platform/use-harness-platform/governance/policy-as-code/harness-governance-overview)
6. Select **Apply Changes**.
7. Select **Save**.
   {% endtab %}
   {% endtabs %}
   {% endtab %}

{% tab title="YAML" %}
The following is a YAML sample of a Spot Elastigroup pipeline using the Canary deployment strategy.

```yaml
pipeline:
  name: Spot canary
  identifier: Spot_canary
  projectIdentifier: myproject
  orgIdentifier: myorg
  tags: {}
  stages:
    - stage:
        name: spot canary
        identifier: spot_canary
        description: ""
        type: Deployment
        spec:
          deploymentType: Elastigroup
          service:
            serviceRef: spotsvc
            serviceInputs:
              serviceDefinition:
                type: Elastigroup
                spec:
                  artifacts:
                    primary:
                      primaryArtifactRef: <+input>
                      sources: <+input>
          environment:
            environmentRef: Spot
            deployToAll: false
            infrastructureDefinitions:
              - identifier: spotinfra
          execution:
            steps:
              - step:
                  name: Elastigroup Setup
                  identifier: Elastigroup_Setup
                  type: ElastigroupSetup
                  timeout: 10m
                  spec:
                    name: <+project.identifier>_<+service.identifier>_<+env.identifier>
                    instances:
                      type: Fixed
                      spec:
                        min: 1
                        max: 2
                        desired: 2
                  failureStrategies: []
              - step:
                  type: ElastigroupDeploy
                  name: Elastigroup Canary Deploy
                  identifier: Elastigroup_Canary_Deploy
                  spec:
                    newService:
                      type: Count
                      spec:
                        count: 1
                  timeout: 15m
              - step:
                  type: ElastigroupDeploy
                  name: Elastigroup Deploy
                  identifier: Elastigroup_Deploy
                  spec:
                    newService:
                      type: Percentage
                      spec:
                        percentage: 100
                  timeout: 15m
            rollbackSteps:
              - step:
                  name: Elastigroup Rollback
                  identifier: Elastigroup_Rollback
                  type: ElastigroupRollback
                  timeout: 10m
                  spec: {}
        tags: {}
        failureStrategies:
          - onFailure:
              errors:
                - AllErrors
              action:
                type: StageRollback

```

{% endtab %}
{% endtabs %}

The pipeline stage is complete. Select **Run** to deploy the pipeline.

***

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

* [AWS deployment FAQs](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/aws/aws-deployment-faqs.md): Frequently asked questions about AWS deployments in Harness.

{% @harness-feedback/feedback %}
