4 - ECS Environments

Updated 13 hours ago by Michael Cretzman

Creating a Harness Environment for ECS is a simple process. First, you specify the ECS Deployment Type. Then, you specify the ECS cluster where you want to deploy the ECS Task and Service that you defined in your Harness Services.

Create an Environment

To create the Harness Environment for ECS, do the following:

  1. In your Harness Application, click Environments.
  2. Click Add Environment. The Environment dialog appears.

  3. In the Environment dialog, enter a name (such as Stage), select the Non-Production type (you can add your production environment later), and click Submit. The new Environment appears.

Define the Infrastructure

Next, you define one or more Service Infrastructures—or Infrastructure Definitions—for the Environment.

Infrastructure Definition is replacing Service Infrastructure as a more flexible method for defining your target infrastructure. Currently, Infrastructure Definition is behind a feature flag. Contact Harness Support to migrate to the Infrastructure Definition feature.

During the transition, we document both options:

Add a Service Infrastructure

For ECS, a Service Infrastructure specifies the ECS cluster, launch type, and related VPC information. To create a Service Infrastructure:

  1. On your Environment page, click Add Service Infrastructure.

    The Service Infrastructure dialog appears.

  2. In Select Cloud Provider, specify the following:
    1. Service - Select the Harness Service to deploy in the Service Infrastructure.
    2. Deployment Type - Select Amazon EC2 Container Services (ECS).
    3. Cloud Provider - Select the AWS Cloud Provider you set up for your ECS deployment.
    4. Click Next. The Configuration section appears.
  3. In Configuration, specify the following:
    1. Provision Type - Select Already Provisioned. If you are using a configured Harness Infrastructure Provisioner, select Dynamically Provisioned and then select the Harness Infrastructure Provisioner you set up and click SUBMIT.
    2. Region - Select the AWS region where your ECS cluster is located.
    3. Cluster Name - Select the ECS cluster where Harness will deploy the Task Definition and Service defined in the Harness Service you selected for this Environment.  
    4. Launch Type - Select Fargate LaunchType or EC2 Instances. The only difference when configuring these launch types is Fargate LaunchType requires that you specify the Target Execution Role.
    5. VPC - Select the VPC where the ECS Cluster is located.
    6. SecurityGroups - Select the AWS security group(s) you want to use when creating instances. When selecting the SecurityGroups, the Group ID for the security groups are listed. You can locate the Group ID in the ECS Dashboard, under Security Groups.
    7. Subnets - Select the VPC subnet(s) where the EC2 instances will be located.
    8. Assign Public IP - Select this checkbox to have external public IP addresses assigned to the deployed container tasks.
  4. Click SUBMIT. The new Service Infrastructure is added to your Environment. You will select this Environment and Service Infrastructure when you create your Harness Workflow.

Add an Infrastructure Definition

For ECS, an Infrastructure Definition specifies the ECS cluster, launch type, and related VPC information.

Currently, Infrastructure Definition is behind a feature flag. Contact Harness Support to migrate to the Infrastructure Definition feature.

To create an Infrastructure Definition:

  1. On your Environment page, click Add Infrastructure Definition.

    The Infrastructure Definition dialog appears.

  2. Enter a Name that will identify this Infrastructure Definition when you add it to a Workflow.
  3. In Cloud Provider Type, select Amazon Web Services.
  4. In Deployment Type, select Amazon EC2 Container Services (ECS). This expands the Infrastructure Definition dialog to look something like this:

  5. Select Use Already Provisioned Infrastructure, and follow the Define a Provisioned Infrastructure steps below.

If you are using a configured Harness Infrastructure Provisioner, instead select Map Dynamically Provisioned Infrastructure, select the Harness Infrastructure Provisioner you set up, and click Submit.

Define a Provisioned Infrastructure

To fill out the Infrastructure Definition dialog's lower section:

  1. In Cloud Provider, select the AWS Cloud Provider you set up for your ECS deployment.
  2. In Region, select the AWS region where your ECS cluster is located.
  3. In Cluster Name, select the ECS cluster where Harness will deploy the Task Definition and Service defined in the Harness Service you will use with this Environment.  
  4. In Launch Type, select either Fargate LaunchType or EC2 Instances.
The only difference when configuring these launch types is that Fargate LaunchType requires that you specify the Target Execution Role in the next field.
  1. In VPC, select the VPC where the ECS Cluster is located.
  2. In Security Groups, select the AWS security group(s) that you want to use when creating instances. (This drop-down lists Security Groups by Group ID. You can locate the Group ID in the ECS Dashboard under Security Groups.)
  3. In Subnets, select the VPC subnet(s) where the EC2 instances will be located.
  4. Select Assign Public IP if you want external public IP addresses assigned to the deployed container tasks.
  5. Enable Scope to Specific Services, and use the adjacent drop-down to select the Harness Service you've configured for ECS.
Scoping is a recommended step, to make this Infrastructure Definition available to any Workflow or Phase that uses this Service.
  1. Click Submit. The new Infrastructure Definition is added to your Environment. You will select this Environment and Infrastructure Definition when you create your Harness Workflow.

Next Step

Now that you have an ECS Service and Environment set up, you can create an ECS Workflow:


How did we do?