How to add custom security groups to beanstalk?
.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 theSecurity Group Name
and not theName
attribute.
- Create a file inside the
.ebextensions
, let us name itsecurity_group.config
and put the following content
- Now when you would deploy your code beanstalk environment, all your instances would have the
demo-security-group
attached 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-group
then add them in a single line.