Open In App

Amazon Web Services – Adding Security Group to Elastic Beanstalk Environment

Improve
Improve
Like Article
Like
Save
Share
Report

The AWS Elastic Beanstalk is a service provided by AWS that is used to deploy and scale web applications built on Java, Python, Go, Ruby, Node.js and Docker, etc.

In this article, we will look into how users can add their own security group to their AWS Elastic Beanstalk environment.

To do so follow the below steps:

Step 1: Login to the AWS management console and then navigate to the Amazon Elastic Compute Cloud console.

Step 2:  From the navigation pane on the left choose security groups.

Step 3: Now note the pre-existing security group that you want to add to your Elastic Beanstalk environment.

If the security group doesn’t exist create one. By default, Elastic Beanstalk creates a security group for your environment but you can also add your own security group to your environment. To do this we’ll use EB extensions.

Step 4: Now let’s open the application source bundle on your local system. The create a directory named .ebextensions in the root of the application source bundle if not already created.

cd Desktop/
cd eb-application/
cd .ebextensions/

Step 5: In the EB extensions directory create a file named securitygroup.config.

vi securitygroup.config

Note: If your instances are launched within a virtual private cloud make sure you specify security group ids instead of security group names. Your custom security group should belong to the same VPC where your EBS environment resides. 

Now let’s add the option settings.

Step 6:  Now compress the code and then deploy it using EBS console or the elastic beanstalk command line:

cd ..
eb deploy

After the deployment is successful the security group is attached to your EC2 instances. The environment is now successfully using your existing security group that you have attached through EB extensions in addition to the default security group.


Last Updated : 27 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads