Deploying an Application Using AWS Elastic Beanstalk

We can see here deploying a basic PHP based application using AWS beanstalk service. we want to run y our application in AWS without having to provision, configure, or manage the EC2 instances ourself.

First, you’ll need to create a service role for Elastic Beanstalk, allowing the service to deploy AWS services on your behalf. Follow these steps:

  1. Search for IAM in the AWS console.
  2. Select “Roles” and then “Create role”.
  3. Set the Trusted entity type to AWS service.
  4. Under Use cases, search for Elastic Beanstalk and select “Elastic Beanstalk – Customizable”.
  5. Click “Next”, and then “Next” again as the permissions are automatically selected.
  6. Name the role ServiceRoleForElasticBeanstalk.
  7. Scroll to the bottom and click “Create role”.

REFERENCE SCREENSHOT

Next, you’ll configure an EC2 instance profile to give the instance the required permissions to interact with Elastic Beanstalk:

  1. Select “Create role” again in IAM.
  2. Set the Trusted entity type to AWS service.
  3. Under Use case, select EC2 under Commonly used services.
  4. Click “Next”.
  5. Search for AWS Elastic Beanstalk read only policy and select it.
  6. Click “Next”.
  7. Name the role CustomEC2InstanceProfileForElasticBeanstalk.
  8. Scroll to the bottom and click “Create role”.

REFERENCE SCREENSHOT

Now, you’re ready to create your application by uploading the provided code:

  1. Search for Elastic Beanstalk in the AWS console.
  2. Select “Create application”.
  3. Choose “Web server environment”.
  4. Enter the application name as BeanStalkDemo.
  5. Choose a managed platform and select PHP.
  6. Under Application code, upload your code. Set the version label to v1.
  1. Use the file you downloaded earlier.
  2. Under Service role, select ServiceRoleForElasticBeanstalk.
  3. Under EC2 instance profile, select EC2InstanceProfileForElasticBeanstalk.
  4. Click “Next” through the optional configuration pages.
  1. On the Configure updates, monitoring, and logging page, select basic health reporting and deactivate managed updates.
  2. Click “Submit”.

After a few minutes, your Elastic Beanstalk environment will be ready. You’ll see a confirmation message, and you can click the domain URL under the Environment overview to access your application.

Hit the Domain URL it should take us to the deployed website.

And there you have it! Elastic Beanstalk deploys and scales your web applications, provisioning the necessary AWS resources such as EC2 instances, RDS databases, S3 storage, Elastic Load Balancers, and auto-scaling groups.

Leave a Reply