Search code examples
amazon-web-servicesspring-bootdockeramazon-ecsaws-fargate

AWS Fargate cannot access dockerized spring boot application over Load balancer/ public IP


I have deployed the docker image of my spring boot application over aws ECR, following creation of AWS fargate cluster. PFA screenshots of the configurations stating task, security, service and cluster definition.I can ping my public ip successfully. But I can't access my application over neither load balancer nor public ip. The urls I tried to access application were

public_ip:8081/my_rest_end_point

and

load_balancer_public_dns:8081/my_reset_end_point

I have tested running my docker image on local host using port 8081 and the same 8081 port I have configured for port mapping in my Fargate container configuration (reference: service definition). How can I access my application? I have followed almost all the articles over Medium and AWS.

Task Definition security definition service definition cluster definition Target group load balancer definition1 load balancer definition2 inbound rules Updated security rules service subnet load balancer subnets registered target groups

Tutorials followed: https://medium.com/underscoretec/deploy-your-own-custom-docker-image-on-amazon-ecs-b1584e62484

https://medium.com/faun/aws-fargate-services-deployment-with-continuous-delivery-pipeline-b67d33407c88


Solution

  • Based on the comments and chat discussion.

    The tutorial followed creates a custom VPC with CIDR range of 10.0.0.0/16 with two subnets. There is no internet gateway (IGW); and subsequently, the Fargate tasks launched in the VPC have no internet access nor they can't be accessed from the internet.

    There are two solutions to this problem:

    • use the default VPC which correctly provides internet access
    • create a custom VPC (or modify existing) that is setup with IGW and the corresponding route tables. An example of a custom VPC with internet access is in AWS docs.