.ebextensions can help you attach custom security groups to the instance.
* Create a new security group, make sure to name the security group appropriately. You can add your custom inbound and outbound rules to the configuration. Let us name it demo-security-group, make sure to use the Security Group Name and