Creating an Elastic Beanstalk instance under VPC on AWS.

Creating an Elastic Beanstalk instance under VPC on AWS.

Amazon Elastic Beanstalk is a robust platform-as-a-service (PaaS) offering by Amazon Web Services (AWS) that simplifies deploying and managing applications. With Elastic Beanstalk, you can easily create and deploy scalable web applications without worrying about the underlying infrastructure. In this tutorial, I will walk you through the process of creating an Elastic Beanstalk instance under a Virtual Private Cloud (VPC) using the command line.

Prerequisites:

  1. An AWS account with appropriate permissions to create and manage Elastic Beanstalk environments.

  2. AWS Command Line Interface (CLI) installed on your Linux machine.

  3. Basic knowledge of VPCs and networking concepts.

  4. VPC subnet and security groups have already been created.

To create an Elastic Beanstalk instance under VPC using the eb create command, follow these steps:

Step 1: Configure AWS CLI:

Configure AWS CLI Before proceeding, ensure that you have configured the AWS CLI with your AWS access key and secret access key. You can do this by running the following command and following the prompts:

$ aws configure

Step 2: Navigate to your project directory

Navigate to your project directory Change your current working directory to the root directory of your Elastic Beanstalk project.

$ cd /path/to/your/project

Step 3: Initialize Elastic Beanstalk:

Initialize Elastic Beanstalk If you haven't already initialized Elastic Beanstalk for your project, run the following command:

$ eb init

This command initializes your project with Elastic Beanstalk and prompts you to select your desired region and other configuration options.

Step 4: Create the environment:

Create the environment To create an Elastic Beanstalk environment under your VPC, use the eb create command:

$ eb create --vpc.id <VPC_ID> --vpc.ec2subnets <SUBNET_ID_1> <SUBNET_ID_2> --vpc.securitygroups <GROUP_ID_1> <GROUP_ID_2>

Replace <VPC_ID> with the ID of your VPC, <SUBNET_ID_1> <SUBNET_ID_2> with the IDs of your subnets (comma-separated if more than one), and <GROUP_ID_1> <GROUP_ID_2> with the IDs of your security groups (comma-separated if more than one).

This command creates an Elastic Beanstalk environment under your specified VPC, utilizing the provided subnets and security groups.

Step 5: Monitor the environment creation:

Monitor the environment creation The eb create command will initiate the environment creation process. You can monitor the progress and check the status of your environment using the following command:

$ eb status

Wait until the environment status is "Ready" before proceeding.

Step 6: Accessing your Elastic Beanstalk instance:

Accessing your Elastic Beanstalk instance Once the environment is ready, you can access your Elastic Beanstalk instance using the following command:

$ eb open

This command will open the application URL in your default web browser.

Conclusion: By using the eb create command with the appropriate parameters, you can easily create an Elastic Beanstalk instance under a VPC. Elastic Beanstalk simplifies the deployment and management of your applications, allowing you to focus on development while AWS handles the underlying infrastructure.

What else can be done via command?

The usage of command for creation does not limit to only this. We can do a lot like selecting EC2 instance types, regions, database details, load balancer visibility, type, and a lot more.

Here is one basic command that can be used to create a Beanstalk instance under VPC with an instance type of t3.medium and a public load balancer of type application.

💡
AWS Documentation says that the default load balancer type is application if none is set by you. But in my case, it is set to classic unless I specify the type as application.
$ eb create --vpc.id <VPC_ID> --vpc.ec2subnets <SUBNET_ID_1> <SUBNET_ID_2> --vpc.securitygroups <GROUP_ID_1> <GROUP_ID_2> --instance-type t3.medium --vpc.elbpublic --elb-type application

For more details please visit AWS Docs

Did you find this article valuable?

Support Sai Lokesh Reddy by becoming a sponsor. Any amount is appreciated!