2
votes

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
1
Don't know much about Fargate, but your endpoint need to be able to receive HTTP requests. So you basically need a web server running at the endpoint.Erik Kalkoken
That's a given and already what I had. The problem is how do I route traffic to my container instance / how do I configure a DNS entry to route to my containerCyril Duchon-Doris
In general you need to create an "A record" with the server name that points to the IP address of your web server, e.g.` mydomain.example.com`Erik Kalkoken
How do you retrieve the IP address of a running container ?Cyril Duchon-Doris

1 Answers

3
votes

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.