.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 Nameand not the
- Create a file inside the
.ebextensions, let us name it
security_group.configand put the following content
- Now when you would deploy your code beanstalk environment, all your instances would have the
demo-security-groupattached to them
- In order to add multiple security groups, you can add them as comma-separated-values, For example, you have 2 security groups,
demo-security-group,another-security-groupthen add them in a single line.