I have created a vpc, and created two subnets one is public subnet(attached to internet gateway) and another is private subnet. I am able to access private subnet from public subnet. My question is how the traffic goes out from private subnet to public subnet? The private subnet is associated with main route table. And it has only route to local.
If possible can you please met me know how the traffic goes in route tables(in bound and out bound)?

The public subnet can communicate with the private subnet because the CIDR of the private subnet falls within the local route of the route table associated with the public subnet. Likewise, the private subnet can communicate with the public one because the local route in its route table includes the CIDR of the public subnet.
You can run a little experiment with the VPC reachability analyzer to visualize this. Here's an example which illustrates TCP traffic going from one network interface in a public subnet (associated with the default route table), to a network interface in a private subnet (associated with a custom route table):

and here's what it looks like the other way around:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With