AWS offers security at protocol and port access level. This is usually done by AWS Security Groups. These safety groups are like firewalls, they have set of specified rules which filter out the incoming and outgoing traffic coming into and out of an EC2 instance and deny any kind of unauthorized access to EC2 instances.
Moreover, you can configure both INBOUND and OUTBOUND traffic to enables secured access for the EC2 instance