Cannot access to my website on ECS from outside AWS network - amazon-web-services

I deployed an instance(A small SpringBoot Hello World app) to AWS ECS and it's running. But, I can't access to this website from my computer. My configurations are as below :
Security Group inbound rules :
Security Group outbound rules :
Main Route table routings :
ACL inbound rules :
ACL outbound rules :
Also I'd like to note that the network type of my task definition of my service is bridge. It is a simple hello world application and there are not any probable bugs in the app and it's running. I also do have an internet gateway which is connected to the VPC of the instance. I did a reachibility analysis through the tool Amazon provides, and it tells that from that internet gateway to my instance the path is reachable. Although I cannot access my app from the browser. I had it running before. What could be going wrong? I'm really stuck here, any help will be appreciated.

Access your Spring application using configured port. It would be in this format - protocol://AWS-hostname:port/spring-endpoint
Example - http://ec2-54-79-157-118.ap-southeast-2.compute.amazonaws.com:8080/hello

Related

AWS App Runner service cannot access Internet when added to a VPC

I've set up an AWS App Runner service, which works fine. Currently for networking it's configured as public access, but I'd like to change this to a VPC so that I can connect the service to an RDS instance without having to open the database up to the world.
When I change the networking config to use my default security group, the service is unable to access the Internet. Cloning a git repo from Bitbucket brings up the error: ssh: Could not resolve hostname bitbucket.org: Try again
... and trying to run npm install brings up:
npm ERR! network request to https://registry.npmjs.org/gulp failed, reason: connect ETIMEDOUT 104.16.24.35:443
My security group has an outgoing rule allowing all traffic out to any destination. My RDS instance is in the same VPC/security group and I'm able to connect to this without issue (currently I've opened up port 3306 to the world). Everything else I've read from a bunch of Googling seems fine: route tables, internet gateways, firewall rules, etc.
Any help would be much appreciated!
Probably too late to be really helpful but moving the App Runner to a VPC sends all outgoing traffic to the VPC.
The two options given in the docs are
Adding NAT gateways to each VPC
Setting up VPC endpoints
Documented within the first bullet point of the Considerations when selecting a subnet section
https://docs.aws.amazon.com/apprunner/latest/dg/network-vpc.html

Cannot connect two ECS services via Service Discovery

I am new to AWS and I am trying to deploy simple app to AWS ECS. I have two simple docker containers, running in ECS Fargate:
‘Frontend’: Vue Js app, which makes a single request to backend;
‘Backend’: Django app, which serves the request;
Both services were launched within the same cluster, in default VPC and the same, single public subnet. For ‘Backend’ I configured Service Discovery: Namespace – test, Service Discovery Name – backend. Security group configured to allow All Traffic.
So, the problem is when frontend makes request:
axios.get('http://backend.test:8000/api/get-test/')
I got error: Failed to load resource: net::ERR_NAME_NOT_RESOLVED backend.test:8000/api/get-test/
However, executing in AWS Cloud9 command: dig +short backend.test returns correct private IP of the backend container.
When I change request to something like
axios.get('http://172.17.3.85:8000/api/get-test/')
where 172.17.3.85 is valid private IP of the backend container, I got following error:
GET http://172.17.3.85:8000/api/get-test/ net::ERR_CONNECTION_TIMED_OUT
However, if I spin out EC2 instance in the same VPC and subnet and SSH to it, I can ping backend container, and requests -
curl -v http://172.17.3.85:8000/api/get-test/
as well as
curl -v http://backend.test:8000/api/get-test/
return desired response.
The only case when everything is working as expected is when the request is like
axios.get('http://3.18.59.133:8000/api/get-test/'),
where 3.18.59.133 is valid Public IP of the backend container.
I would appreciate any suggestion where look further or how to connect two containers via service discovery as right now I am out of ideas.
Based on the discussion in comments and description of the problem, the reason is that the Frontend’: Vue Js app executes on the client side, for example, in the browser.
This explains all the issues described and discussed:
axios.get('http://backend.test:8000/api/get-test/') does not work as on the client side you can't resolve privte hosted zone.
axios.get('http://172.17.3.85:8000/api/get-test/') does not work because the 172.17.3.85 is valid only in the VPC, not on the client's network.
spin out EC2 instance in the same VPC and subnet and SSH works because private hosted zones can be resolved inside VPC.
axios.get('http://3.18.59.133:8000/api/get-test/') works because public IP can be used on the clinet side, unlike private IPs.

AWS ElasticBeans With Eureka and Zuul , how to Restrict access to services?

I have created a full micro services solution on AWS elasticBeansTalk(each service in its own container) on port 5000(default port for elasticbeans) -> this creates each micro service in its own security group.
I am using Zuul and eureka and everything is working great,
But my problem is that I had to create inbound and outbound rules for all of my containers(with all IP white listed 0.0.0.0/0).
I would like to block public access to each of the micro services except Zuul and the spring config server(And I am a really bad devops guy),
can Anyone help me with the correct configuration?
Many thanks and Kind regards,
Roie Beck
I am attaching an image of the structure(there is also a config server in there but I didn't find an image of one):
You would want to create a private subnet to run all of your micro-services and have your zuul gateway proxy all requests in your public subnet. Zuul and the micro-services can communicate through the NAT-gateway. More information can be found here: https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Scenario2.html

How can I access my application from the public IP of AWS?

Whenever I tried to access to my deployed application on an EC2 instance of AWS using the public IP, I get the following messages on Chrome: "This site can’t be reached
ec2-54-194-153-202.eu-west-1.compute.amazonaws.com took too long to respond."
then, What changes shall I apply in order to grant access to the application properly ?,
Thank you,
The first thing to check in this case is The Security-Group inbound rules attached to your Ec2.
If your application is running behind a webserver like Nginx or Apache, check that your security_group is open in inbound for the public range (0.0.0.0/0) on the http port (80).
You can get this info on the Ec2 panel, click on your instance and check the attached security_group, click on it and check the inbound rules.
Here is a guide for you.
Notice : If nothing is running on your Ec2 it will never respond, be sure your app is served by a Nginx/Apache/Tomcat daemon.
Hope it helps !

How to avoid the configuration error while using AWS API Gateway with VPC Link? [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last month.
Improve this question
I have created the VPC Link using the Network Load Balancer (NLB) as per the AWS documentation and attached the same with the API Gateway resource / method. But it throws "Internal Server Error" when accessing the "Invoke URL" and displays this error while testing: "Execution failed due to configuration error: There was an internal error while executing your request".
Procedure I followed:
1) Created Network Load Balancer :
Load Balancer Scheme: Internal
Load Balancer Protocol / port : TCP / 80
Availability Zone : Created VPC with CIDR "10.0.0.0/16" and public subnet with CIDR "1XX.XX.0.0/16".
Target Group : Protocol / Port / Target Type - TCP / 80 / Instance
No Target Registration.
Launched NLB.
2) Created VPC Link in API Gateway using the newly created NLB.
3) Created new API :
Method : Get
Integration Type : VPC Link
Use Proxy Integration : True
VPC Link : ${stageVariables.vpcLinkId}
Endpoint URL : "My ec2 instance URL with port" (Ex: http://ec2-XX-XXX-XXX-XXX.compute-1.amazonaws.com:3000)
Created API resource.
4) Deployed the selected API using the "Deploy API" action and newly created stage.
5) Configured the "vpcLinkId" in the "Stage Variables" section.
Now if I hit the "Invoke URL", the web page displays " {"message": "Internal server error"} ".
Note: If I use the same EC2 url with the "Integration Type : HTTP", the "Invoke URL" works. Same is not working with the VPC Link.
Error:
Other Points Worth Noting:
In EC2 instance with security policy will allow all TCP ports.
EC2 instance was launched by using ECS / ECR (Docker Container).
Enabled the Cloud Watch logs from API Gateway stage, but it produces nothing.
I'm happy to provide additional information, if required.
EDIT 1
Based on JNY's (jny) input I have changed the API gateway end point to the NLB and added my EC2 instance as Target in the NLB. Still I'm facing the same issue. Below images will show all the configurations that I have done.
Load Balancer Config:
Load Balancer Target Group settings:
Target Group Port Settings:
Here I have given 3000 as port to check the instance health as my application (Node) listens on 3000 port.
Enabled the port numbers 80 and 3000 in the security policy.
API Gateway Settings:
Finally I changed the Endpoint the API Gateway to NLB
Result of the same:
Still I'm not sure what is the mistake I'm making here.
I was also getting 500 Internal server error, then I have added inbound rules in EC2 security group and allow HTTP with CIDR of VPC subnet and now I able to access the API using NLB
Your NLB is missing inbound permissions to the EC2 instance (in their security Groups) for port 80. But since an NLB does not have as security group (but does have permanent IP), you will have to use its ip and add it directly to the security group for the EC2 instance.
Here's how you can find the ip of your NLBs: https://docs.aws.amazon.com/elasticloadbalancing/latest/network/target-group-register-targets.html#target-security-groups.
You did it correctly, but maybe it will help someone:
My fault was to use HTTPS for the endpoint url in the api gateway. It must be HTTP.
Correct:
http://myLoadBalancer.elb.us-east-1.amazonaws.com
The textfield was too short to show the whole url, so I didn't see it.
Issue got resolved after using the same port for NLB, EC2, ECS, etc..