4 - ECS Environments
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:
- In your Harness Application, click Environments.
- Click Add Environment. The Environment dialog appears.
- 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.
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:
- On your Environment page, click Add Service Infrastructure.
The Service Infrastructure dialog appears.
- In Select Cloud Provider, specify the following:
- Service - Select the Harness Service to deploy in the Service Infrastructure.
- Deployment Type - Select Amazon EC2 Container Services (ECS).
- Cloud Provider - Select the AWS Cloud Provider you set up for your ECS deployment.
- Click Next. The Configuration section appears.
- In Configuration, specify the following:
- 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.
- Region - Select the AWS region where your ECS cluster is located.
- 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.
- 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.
- VPC - Select the VPC where the ECS Cluster is located.
- 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.
- Subnets - Select the VPC subnet(s) where the EC2 instances will be located.
- Assign Public IP - Select this checkbox to have external public IP addresses assigned to the deployed container tasks.
- 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.
To create an Infrastructure Definition:
- On your Environment page, click Add Infrastructure Definition.
The Infrastructure Definition dialog appears.
- Enter a Name that will identify this Infrastructure Definition when you add it to a Workflow.
- In Cloud Provider Type, select Amazon Web Services.
- In Deployment Type, select Amazon EC2 Container Services (ECS). This expands the Infrastructure Definition dialog to look something like this:
- Select Use Already Provisioned Infrastructure, and follow the Define a Provisioned Infrastructure steps below.
Define a Provisioned Infrastructure
To fill out the Infrastructure Definition dialog's lower section:
- In Cloud Provider, select the AWS Cloud Provider you set up for your ECS deployment.
- In Region, select the AWS region where your ECS cluster is located.
- 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.
- In Launch Type, select either Fargate LaunchType or EC2 Instances.
- In VPC, select the VPC where the ECS Cluster is located.
- 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.)
- In Subnets, select the VPC subnet(s) where the EC2 instances will be located.
- Select Assign Public IP if you want external public IP addresses assigned to the deployed container tasks.
- Enable Scope to Specific Services, and use the adjacent drop-down to select the Harness Service you've configured for ECS.
- 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.