Hi @Stallone,
I will share my understanding:
"Could you please explain why traffic that goes through the VPN tunnel from on-premises resources is not blocked by the vMX instance's security group"
It is not blocked by the Security Group because of the very nature of VPN. The vMX is a software that acts as the encryption termination point for your VPN tunnel, inside the EC2 instance; this means the ENI of the EC2 instance only sees encrypted traffic (in this case, Auto VPN traffic, which uses UDP encapsulation, choosing UDP ports in high ranges, 32768-61000 last I checked).
Try this:
- Setup VPC Flow logs for the vMX ENI. Pick the destination you prefer (CloudWatch Logs or an S3 bucket, depending what the type of permissions you have in AWS). Now ping through the tunnel (for example, from on-prem to an EC2 instance behind the vMX inside the VPC - or anything through the tunnel, in whichever direction). Check your VPC Flog logs, you won't see any of those ICMP packets (except the vMX itself pinging 8.8.8.8 for connectivity checks, which happens outside the tunnel, so you will see those), you will only see the outer encapsulation, meaning UDP packets on high port ranges which are for the tunnel between the vMX and the on-prem MX, as well as packets towards the Meraki VPN Registry on UDP 9350-9381.
As an analogy, it's a bit like you establishing a VPN from your laptop (representing the vMX) towards somewhere on the internet (representing your on-prem MX), your network firewall (representing the EC2 ENI) won't see what you do inside the tunnel, will only see the outer encapsulation.
"while traffic going from AWS to the on-premises resources is blocked?"
Can you share what test led you to this conclusion? Are you actually referring to this: "yes traffic from the another EC2 instance was blocked"? Because if that's the case, the traffic is blocked because once the vMX decrypts it, it sends it to the other EC2 instance unencrypted, so the ENI will see the ICMP packets.
If you mean traffic from AWS to on-prem is blocked when you block all outbound traffic on the vMX ENI, that is because if you do so (block all outbound), then the result is you are actually causing the tunnel to drop eventually (I say eventually because the tunnel may stay up for some time, but soon will drop. Or if you reboot the vMX you will see the tunnel won't come back up), because you are effectively blocking the vMX connectivity to the Meraki cloud and to your MX on-prem.
Let me know if your tests tell you otherwise.