I have created an EC2 instance with terraform aws provider. The Instance is an Ubuntu server of free tier t2.micro.
Even though I have followed every Amazon guide about Network ACLs, Security Groups, Route tables, Internet gateways, I still cannot execute a simple command such as
sudo apt-get update
When I log in to my instance from ssh port (22) and execute the sudo command above, I receive back this message:
0% [Connecting to us-east-2.ec2.archive.ubuntu.com (52.15.159.198)]
Resources I have followed:
https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html#vpc-igw-internet-access
https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html#nacl-rules
https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html#AddRemoveRules
And many SO questions.
Note that I connect with ssh to port 22 and ping the public ip of ec2 instance. I have also created a route table which has an internet gateway attached to network interface.
Network rules:
Security group rules:
Route table attached to my instance
My only concern is that the vpc I use has a main acl network (like a default) which is not the one I use (the one with the many rules in the screenshot above). However, the main route table guides to the correct subnet that is also attached to the correct acl network. I guess this is happening because in terraform I use the aws_network_acl resource and not the aws_default_network_acl.
Thus, my only concern might be that I have a wrong acl network attached to my vpc, however even that acl network has allowed all inbound - outbound traffic. So accessing http shouldn't impose a problem. Since I can't download anything from my ec2 instance, I believe that something else is the root of my problem.
Appreciate any help in advance.