Open topic with navigation

# Creating a Target Group for Ports 443, 32081, and 32080

In order for deployed products to correctly operate, you must set up target groups, and then a listener, for ports 443, 32081 and 32080.

To create a target group for port 443 using the web UI:

1. Using the Find Services search tool, locate and browse to the EC2 dashboard.
2. In the left navigation panel, under Load Balancing, click Target Groups.
3. On the Target Groups management page, click Create target group.

1. On the Specify group details page, specify values for the following:
   1. Under Choose a target type, select Instances.
   2. Target group name: Choose a descriptive name for easier identification; for example srgdemo-443-tg.
   3. Protocol: Change to HTTPS.
   4. Port: Select 443.
   5. VPC: Select your VPC.
   6. Tags: (Optional) Add descriptive tags as desired.
   7. Health Checks: Under Health check protocol, select HTTPS. For path, specify /th/cmak.

1. Click Next.
2. On the Register Targets page, set values for the following:
   1. Available instances: Select your instances; do not select the bastion.
   2. Ports: For the selected instances, use the value you retrieved previously and recorded in the AWS worksheet as the `Node Port for Port 443.`

1. Click Include as pending below. All marked instances will be added to the list of pending instances.

1. Click Create target group.
2. You will be redirected back to the target group management page. From the list, select the newly created target group. From the bottom of the page, note its ARN in the AWS worksheet.
3. Repeat Steps 1 through 9 for ports 32081.
4. Repeat Steps 1 through 9 for ports 32080.

To create a target group for port 443 using the CLI:

1. Run the following command:
   `# aws elbv2 create-target-group \
   --name <Target group 443 Name> \
   --protocol HTTPS \
   --port 443 --vpc-id <VPC ID> \
   --health-check-protocol HTTPS \
   --target-type instance`

Where:

`<Target group 443 Name>`: Choose a descriptive name, such as `srgdemo-443-tg`, and record the value in the AWS worksheet.

`<VPC ID>`: The ID of your VPC as recorded in your AWS worksheet.

Example input and output:

    # aws elbv2 create-target-group \
    --name srgdemo-443-tg --protocol HTTPS \
    --port 443 --vpc-id vpc-0143197ca9bd9c117 \
    --health-check-protocol HTTPS \
    --target-type instance

    {
       "TargetGroups":[
          {
             "TargetGroupArn":"arn:aws:elasticloadbalancing:eu-central-1:115370811111:targetgroup/srgdemo-443-tg/6d30f1c7be588bb6",
             "TargetGroupName":"srgdemo-443-tg",
             "Protocol":"HTTPS",
             "Port":443,
             "VpcId":"vpc-0143197ca9bd9c117",
             "HealthCheckProtocol":"HTTPS",
             "HealthCheckPort":"traffic-port",
             "HealthCheckEnabled":true,
             "HealthCheckIntervalSeconds":30,
             "HealthCheckTimeoutSeconds":5,
             "HealthyThresholdCount":5,
             "UnhealthyThresholdCount":2,
             "HealthCheckPath":"/",
             "Matcher":{
                "HttpCode":"200"
             },
             "TargetType":"instance"
          }
       ]
    }

1. From the output, record the value of `TargetGroupArn` in your AWS worksheet.
2. Repeat Steps 1-2 for port 32081.
3. Repeat Steps 1-2 for port 32080.

## Tagging the Target Group (CLI)

Optionally, you can tag any newly-created target group for easier identification.

To tag the target group for port 443 using the CLI:

1. Run the following command:
   `# aws elbv2 add-tags \
   --resource-arns <Target group 443 ARN> \
   --tags Key=owner,Value=<owner>`
2. Repeat Step 1 for port 32081.
3. Repeat Step 1 for port 32080.

Example:

`# aws elbv2 add-tags \
--resource-arns arn:aws:elasticloadbalancing:eu-central-1:115370811111:targetgroup/srgdemo-443-tg/c0684be94405b6b7 \
--tags Key=owner,Value=srgdemo`

Next Step: Adding Targets to the Target Group for Ports 443, 32081, and 32080