You can control access to your instances by using Security Groups. By default, all traffic is denied; you must create inbound rules that allow traffic. For example, you will already have a rule that allows SSH (for Linux) or RDP (for Windows). To allow ICMP (for ping), create a rule that permits ICMP only from the hosts that you wish to ping your instances.
Note that you don't have to create outbound rules for traffic that is allowed inbound. Security Groups are stateful; they automatically allow outbound traffic for inbound sessions that were allowed.
Unable to ping EC2 instance from local and remote bothasked a month ago
Do I get charged for stopped instances?Accepted Answerasked 5 years ago
SSMAgent fails to connect on some instancesasked 2 years ago
How to Restrict Client machines to Ping EC2 Instances?asked 14 days ago
details of IAM role which is attached to ec2 instances with cloudshellAccepted Answerasked 3 months ago
Client VPN access to VPCasked a year ago
VPN Tunnel Established but cant ping to client gateway ipasked a year ago
Unable to ping shortname in private hosted zoneasked 3 years ago
EC2 virtual machines with virtual audio devices when headless (no remote desktop)asked 18 days ago
AWS Site-to-Site VPN ping working, TCP not (EC2 networking details)asked a month ago