title: Application Load Balancer with ECS Fargate
body: <p>I am trying to configure load-balancing for Fargate ECS. My understanding is that there are at least two target groups. One target group gets created along with the Application Load Balancer, and one target group gets created along with the ECS service.</p>
  <p>My containers are running their service on TCP port 5000. I want the load balancer only to expose HTTPS over the regular 443 port, and redirect HTTP to HTTPS, or if that is difficult, just drop HTTP.</p>
  <p>I see that Listeners allows specifying a whole bunch of things. However, I am confused by the target group created with the service. It - the <code>IP</code> -type group, listens on port 80. Whether I select HTTP or HTTPS during the service creation/configuration.</p>
  <p>My containers never get any traffic. I enabled load-balancer logging, it seems that the balancer does not understand what I want it to do. There <code>&quot;forward&quot; &quot;-&quot; &quot;-&quot; &quot;-&quot; &quot;-&quot; &quot;-&quot; &quot;-&quot;</code>in the log at end of every request.</p>
  <p>I ran <code>aws elbv2 describe-target-groups</code> to get the definitions.</p>
  <pre><code>{
    &quot;TargetGroups&quot;: [
      {
          &quot;TargetGroupArn&quot;: &quot;arn:aws:elasticloadbalancing:us-east-1:505963211XXX:targetgroup/ecs-fargate-api-service-tg/1ebb89754b34d072&quot;,
          &quot;TargetGroupName&quot;: &quot;ecs-fargate-api-service-tg&quot;,
          &quot;Protocol&quot;: &quot;HTTPS&quot;,
          &quot;Port&quot;: 80,
          &quot;VpcId&quot;: &quot;vpc-e623dd9b&quot;,
          &quot;HealthCheckProtocol&quot;: &quot;HTTPS&quot;,
          &quot;HealthCheckPort&quot;: &quot;traffic-port&quot;,
          &quot;HealthCheckEnabled&quot;: true,
          &quot;HealthCheckIntervalSeconds&quot;: 30,
          &quot;HealthCheckTimeoutSeconds&quot;: 5,
          &quot;HealthyThresholdCount&quot;: 5,
          &quot;UnhealthyThresholdCount&quot;: 2,
          &quot;HealthCheckPath&quot;: &quot;/cookie-policy&quot;,
          &quot;Matcher&quot;: {
              &quot;HttpCode&quot;: &quot;200&quot;
          },
          &quot;LoadBalancerArns&quot;: [
              &quot;arn:aws:elasticloadbalancing:us-east-1:505963211XXX:loadbalancer/app/node-api-lb/f5e512a2678688f5&quot;
          ],
          &quot;TargetType&quot;: &quot;ip&quot;
      },
      {
          &quot;TargetGroupArn&quot;: &quot;arn:aws:elasticloadbalancing:us-east-1:505963211XXX:targetgroup/node-api-tg/7544b53ab1720e0d&quot;,
          &quot;TargetGroupName&quot;: &quot;node-api-tg&quot;,
          &quot;Protocol&quot;: &quot;HTTPS&quot;,
          &quot;Port&quot;: 443,
          &quot;VpcId&quot;: &quot;vpc-e623dd9b&quot;,
          &quot;HealthCheckProtocol&quot;: &quot;HTTPS&quot;,
          &quot;HealthCheckPort&quot;: &quot;traffic-port&quot;,
          &quot;HealthCheckEnabled&quot;: true,
          &quot;HealthCheckIntervalSeconds&quot;: 300,
          &quot;HealthCheckTimeoutSeconds&quot;: 5,
          &quot;HealthyThresholdCount&quot;: 5,
          &quot;UnhealthyThresholdCount&quot;: 2,
          &quot;HealthCheckPath&quot;: &quot;/cookie-policy&quot;,
          &quot;Matcher&quot;: {
              &quot;HttpCode&quot;: &quot;200&quot;
          },
          &quot;LoadBalancerArns&quot;: [
              &quot;arn:aws:elasticloadbalancing:us-east-1:505963211XXX:loadbalancer/app/node-api-lb/f5e512a2678688f5&quot;
          ],
          &quot;TargetType&quot;: &quot;instance&quot;
      }
    ]
  }
  </code></pre>
  <p>What am I doing wrong? How should I go about setting up an application load-balancer for ECS Fargate to have HTTPS on the outside and route everything to the correct container PORT?</p>