5

I'm building a slack app, and my application is expected to receive webhook calls from slack. SO I need to give Slack the "endpoint URL for my service"

I'm not sure I understand what AWS bricks I need to put together to make this work. So far, I have configured my service using Fargate and it is running on ECS with 1 task.

I'm not really sure how I can successfully connect the internet (slack) to my container instance. How do I make an "endpoint" that slack can send requests to ? I believe I need to use API Gateway for this, but I'm not sure how I'm supposed to configure API Gateway so it redirect my URLs to my ECS service...?

Notes :

  • I am not planning to have more than one task right now, so it would be more convenient if I did not have to setup a load balancer
  • However I'm planning to make some regular updates to the service itself, and the tasks will be restarted often
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164

1 Answers1

5

I'm not sure if there's an alternative or not, but when setting up a service on fargate, in order to receive traffic you will need

  • To have a load balancer (either an ALB or NLB should work)
  • In case of an ALB, a target group targeting "IP" must be created
  • It's only during the creation of the service that you can select to put your containers behind a target group or ALB

For instance, to distribute traffic from a target group, you can use this to configure the service

"loadBalancers": [
        {
            "containerName": "your-container-name-app",
            "containerPort": 80,
            "targetGroupArn": "arn:aws:elasticloadbalancing:eu-central-1:account-id:targetgroup/targetgroup-name/RANDOM-ID"
        }
    ],

Create the target group like this

aws elbv2 create-target-group \
--name targetgroup-name \
--protocol HTTP \
--port 80 \
--vpc-id vpc-YOUR_VPC_ID \
--health-check-protocol HTTP \
--health-check-path /healthcheck \
--target-type ip

So you'll basically use the load balancer DNS to route traffic to your instances. Using an ALB, you can easily intercept a certain path (eg /slack/*) to route to your specific target group, so the same ALB can be used for multiple different services.

But you need a load balancer, and cannot target Fargate containers directly from what I understand.

Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
  • 1
    That's correct, you cannot target a Fargate container without an balancing interface in the middle (such as ALB or API GW). The main Fargate feature is that there's no underlying hardware access nor control from user perspective, so, there's no way of accessing a container from outside (access being actually getting to an endpoint or console). – marianogg9 Jan 27 '20 at 15:52
  • How do you connect Fargate containers to API Gateway ? In my case I just needed a single container, and it is a bit overkill (and expensive) to add an additional load balancer. – Cyril Duchon-Doris May 27 '20 at 22:58
  • 1
    There's an option in API Gateway to integrate with a list of AWS Services, ECS being one of them: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-integration-types.html - Integration Type: AWS. Hope it helps. – marianogg9 Jun 24 '20 at 19:46