0

I am Building a solution, where I have 10-15 micro-services REST Applications running in ECS Container and few will be in EC2. I am using Cognito as API Gateway authentication. Now UI Application will send the request to API Gateway, which in turn connect with REST Application and returns the response.

I have tried implementing API Gateway authentication with Cognito and I am able to connect to the REST endpoint running in EC2.

Now I need a solution like API Gateway -> Application Load Balancer -> Target Group -> ECS/EC2 will be running in Public Subnet.

How do I Configure this?

Am I following the correct approach?

nima
  • 7,796
  • 12
  • 36
  • 53
Gowtham
  • 53
  • 3
  • 10
  • 1
    Your question still not clear what exactly are you looking ,are you looking how to configure api getway then cognito then load balancer then ec2 or ecs – vaquar khan Apr 20 '19 at 12:09
  • Just point API Gateway to the URL of the load balancer instead of the URL of the ECS/EC2 instance. Are you running into some sort of issue here? What is the problem you are encountering exactly? – Mark B Apr 20 '19 at 14:07
  • The question seems to be about injecting ALB in the middle. If you are using API-Gateway just for cognito auth, you can now do it directly on the ALB: https://aws.amazon.com/de/blogs/aws/built-in-authentication-in-alb/ – alextsil Jan 06 '21 at 16:35

2 Answers2

-1
  • Api getway you need to expose your microservice and cognito authorizer will take care authentication and authorization.

To register your instances using the console

  • Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  • On the navigation pane, under LOAD BALANCING, choose Load Balancers.

  • Select your load balancer.

  • In the bottom pane, select the Instances tab.

  • Choose Edit Instances.

  • Select the instance to register with your load balancer.

  • Choose Save.

https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-deregister-register-instances.html

https://docs.aws.amazon.com/AmazonECS/latest/userguide/create-load-balancer.html

https://docs.aws.amazon.com/AmazonECS/latest/userguide/create-application-load-balancer.html

vaquar khan
  • 10,864
  • 5
  • 72
  • 96
-1

When you setup your API Gateway,

Create a proxy resource with a greedy path {proxy+}. Set ANY Method on the proxy resource. Set the endpoint URL to your ALB endpoint.

Ex. ENDPOINT URL: https://alb-example-123456789.us-east-1.elb.amazonaws.com/example/{proxy}

For more details, refer to this links: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-set-up-simple-proxy.html https://docs.aws.amazon.com/apigateway/latest/developerguide/setup-http-integrations.html?shortFooter=true

user11389395
  • 287
  • 1
  • 2