AWS Elastic Beanstalk

Home » AWS Cheat Sheets » AWS Compute Services » AWS Elastic Beanstalk

AWS Elastic Beanstalk

Last updated on February 24, 2024

AWS Elastic Beanstalk Cheat Sheet

  • Allows you to quickly deploy and manage applications in the AWS Cloud without worrying about the infrastructure that runs those applications.
  • Elastic Beanstalk automatically handles the details of capacity provisioning, load balancing, scaling, and application health monitoring for your applications.
  • It is a Platform-as-a-Service
  • Elastic Beanstalk supports the following languages:
    • Go
    • Java
    • .NET
    • Node.js
    • PHP
    • Python
    • Ruby
  • Elastic Beanstalk supports the following web containers:
    • Tomcat
    • Passenger
    • Puma
  • Elastic Beanstalk supports Docker containers.
  • Elastic Beanstalk Workflow

AWS Training Elastic Beanstalk

  • Your application’s domain name is in the format:
    subdomain.region.elasticbeanstalk.com
Tutorials dojo strip

Environment Pages

  • The Configuration page shows the resources provisioned for this environment. This page also lets you configure some of the provisioned resources.
  • The Health page shows the status and detailed health information about the EC2 instances running your application.
  • The Monitoring page shows the statistics for the environment, such as average latency and CPU utilization. You also use this page to create alarms for the metrics that you are monitoring.
  • The Events page shows any informational or error messages from services that this environment is using.
  • The Tags page shows tags — key-value pairs that are applied to resources in the environment. You use this page to manage your environment’s tags.

AWS Elastic Beanstalk Concepts

  • Application – a logical collection of Elastic Beanstalk components, including environments, versions, and environment configurations. It is conceptually similar to a folder.
  • Application Version – refers to a specific, labeled iteration of deployable code for a web application. An application version points to an Amazon S3 object that contains the deployable code. Applications can have many versions and each application version is unique.
  • Environment – a version that is deployed on to AWS resources. Each environment runs only a single application version at a time, however, you can run the same version or different versions in many environments at the same time.
  • Environment Tier – determines whether Elastic Beanstalk provisions resources to support an application that handles HTTP requests or an application that pulls tasks from a queue. An application that serves HTTP requests runs in a web server environment. An environment that pulls tasks from an Amazon SQS queue runs in a worker environment.
  • Environment Configuration – identifies a collection of parameters and settings that define how an environment and its associated resources behave.
  • Saved Configuration – a starting point for creating unique environment configurations.
  • Platform – a combination of OS, language runtime, web/application server, and Elastic Beanstalk components.
  • There is a limit to the number of application versions you can have. You can avoid hitting the limit by applying an application version lifecycle policy to your applications to tell Elastic Beanstalk to delete application versions that are old or to delete application versions when the total number of versions for an application exceeds a specified number.

Environment Types

  • Load-balancing, Autoscaling Environment – automatically starts additional instances to accommodate increasing load on your application.
  • Single-Instance Environment – contains one Amazon EC2 instance with an Elastic IP address.

Environment Configurations

  • Your environment contains:
    • Your EC2 virtual machines are configured to run web apps on the platform that you choose.
    • An Auto Scaling group that ensures that there is always one instance running in a single-instance environment, and allows configuration of the group with a range of instances to run in a load-balanced environment.
    • When you enable load balancing, Elastic Beanstalk creates an Elastic Load Balancing load balancer to distribute traffic among your environment’s instances.
    • Elastic Beanstalk provides integration with Amazon RDS to help you add a database instance to your Elastic Beanstalk environment : MySQL, PostgreSQL, Oracle, or SQL Server. When you add a database instance to your environment, Elastic Beanstalk provides connection information to your application by setting environment properties for the database hostname, port, user name, password, and database name.
    • You can use environment properties to pass secrets, endpoints, debug settings, and other information to your application. Environment properties help you run your application in multiple environments for different purposes, such as development, testing, staging, and production.
    • You can configure your environment to use Amazon SNS to notify you of important events that affect your application.
    • Your environment is available to users at a subdomain of elasticbeanstalk.com. When you create an environment, you can choose a unique subdomain that represents your application.
  • You can use a shared Application Load Balancer to serve traffic for multiple applications running on multiple Elastic Beanstalk environments within the same VPC. 
  • Deployment policies:
    • All at once – deploys the new version to all instances simultaneously and will be out of service for a short time.
    • Rolling – deploys the new version in batches.
    • Rolling with additional batch – deploys the new version in batches, but first launch a new batch of instances.
    • Immutable – deploys the new version to a new set of instances.
    • Traffic splitting – deploys the new version to a new set of instances and temporarily splits incoming client traffic.
  • The connections between your application’s component environments can be specified as named references using environment links.
  • You can rebuild terminated environments within six weeks of their termination with the same name, ID, and configuration.

AWS Elastic Beanstalk Monitoring

  • Elastic Beanstalk Monitoring console displays your environment’s status and application health at a glance.
  • Elastic Beanstalk reports the health of a web server environment depending on how the application running in it responds to the health check.
  • Enhanced health reporting is a feature that you can enable on your environment to allow AWS Elastic Beanstalk to gather additional information about resources in your environment. Elastic Beanstalk analyzes the information gathered to provide a better picture of overall environment health and aid in the identification of issues that can cause your application to become unavailable.
  • You can create alarms for metrics to help you monitor changes to your environment so that you can easily identify and mitigate problems before they occur.
  • EC2 instances in your Elastic Beanstalk environment generate logs that you can view to troubleshoot issues with your application or configuration files.

AWS Elastic Beanstalk Security

  • When you create an environment, Elastic Beanstalk prompts you to provide two AWS IAM roles: a service role and an instance profile.
    • Service Roles – assumed by Elastic Beanstalk to use other AWS services on your behalf.
    • Instance Profiles – applied to the instances in your environment and allows them to retrieve application versions from S3, upload logs to S3, and perform other tasks that vary depending on the environment type and platform.
  • User Policies – allow users to create and manage Elastic Beanstalk applications and environments.

AWS Elastic Beanstalk Pricing

  • There is no additional charge for Elastic Beanstalk. You pay only for the underlying AWS resources that your application consumes.

AWS Elastic Beanstalk Tutorials on YouTube:

https://www.youtube.com/user/AmazonWebServices/search?query=elastic+beanstalk

 

Validate Your Knowledge

Question 1

An online shopping platform has been deployed to AWS using Elastic Beanstalk. They simply uploaded their Node.js application, and Elastic Beanstalk automatically handles the details of capacity provisioning, load balancing, scaling, and application health monitoring. Since the entire deployment process is automated, the DevOps team is not sure where to get the application log files of their shopping platform.

In Elastic Beanstalk, where does it store the application files and server log files?

  1. Application files are stored in S3. The server log files can only be stored in the attached EBS volumes of the EC2 instances, which were launched by AWS Elastic Beanstalk.
  2. Application files are stored in S3. The server log files can be stored directly in Glacier or in CloudWatch Logs.
  3. Application files are stored in S3. The server log files can be optionally stored in CloudTrail or in CloudWatch Logs.
  4. Application files are stored in S3. The server log files can also optionally be stored in S3 or in CloudWatch Logs.

Correct Answer: 4

AWS Elastic Beanstalk stores your application files and optionally, server log files in Amazon S3. If you are using the AWS Management Console, the AWS Toolkit for Visual Studio, or AWS Toolkit for Eclipse, an Amazon S3 bucket will be created in your account and the files you upload will be automatically copied from your local client to Amazon S3. Optionally, you may configure Elastic Beanstalk to copy your server log files every hour to Amazon S3. You do this by editing the environment configuration settings.

Thus, the correct answer is the option that says: Application files are stored in S3. The server log files can also optionally be stored in S3 or in CloudWatch Logs.

With CloudWatch Logs, you can monitor and archive your Elastic Beanstalk application, system, and custom log files from Amazon EC2 instances of your environments. You can also configure alarms that make it easier for you to react to specific log stream events that your metric filters extract. The CloudWatch Logs agent installed on each Amazon EC2 instance in your environment publishes metric data points to the CloudWatch service for each log group you configure. Each log group applies its own filter patterns to determine what log stream events to send to CloudWatch as data points. Log streams that belong to the same log group share the same retention, monitoring, and access control settings. You can configure Elastic Beanstalk to automatically stream logs to the CloudWatch service.

The option that says: Application files are stored in S3. The server log files can only be stored in the attached EBS volumes of the EC2 instances, which were launched by AWS Elastic Beanstalk is incorrect because the server log files can also be stored in either S3 or CloudWatch Logs, and not only on the EBS volumes of the EC2 instances which are launched by AWS Elastic Beanstalk.

The option that says: Application files are stored in S3. The server log files can be stored directly in Glacier or in CloudWatch Logs is incorrect because the server log files can optionally be stored in either S3 or CloudWatch Logs, but not directly to Glacier. You can create a lifecycle policy to the S3 bucket to store the server logs and archive it in Glacier, but there is no direct way of storing the server logs to Glacier using Elastic Beanstalk unless you do it programmatically.

The option that says: Application files are stored in S3. The server log files can be optionally stored in CloudTrail or in CloudWatch Logs is incorrect because the server log files can optionally be stored in either S3 or CloudWatch Logs, but not directly to CloudTrail as this service is primarily used for auditing API calls.

Reference:
https://aws.amazon.com/elasticbeanstalk/faqs/

Note: This question was extracted from our AWS Certified Solutions Architect Associate Practice Exams.

Question 2

AWS Exam Readiness Courses

A former colleague reached out to you for consultation. He uploads a Django project in Elastic Beanstalk through CLI using instructions he read in a blog post, but for some reason, he could not create the environment he needs for his project. He encounters an error message saying “The instance profile aws-elasticbeanstalk-ec2-role associated with the environment does not exist.”

What are the possible causes of this issue? (Select TWO.)

  1. He selected the wrong platform for the Django code.
  2. Elastic Beanstalk CLI did not create one because your IAM role has no permission to create roles.
  3. Instance profile container for the role needs to be manually replaced every time a new environment is launched.
  4. You have not associated an Elastic Beanstalk role to your CLI.
  5. IAM role already exists but has insufficient permissions that Elastic Beanstalk needs.

Correct Answers: 2,5 

AWS EB CLI cannot create the instance profile for your Beanstalk environment if your IAM role has no access to creating roles.

This error is also thrown when the instance profile has insufficient or outdated policies that Beanstalk needs to function. More details on this can be seen in the references provided.

The error message indicates that the instance profile associated with the environment does not exist, which means that the role used to launch the environment does not have permission to create roles.

Even if the role used to launch the environment has permission to create roles, the instance profile may have insufficient permissions that Elastic Beanstalk needs to launch the environment.

Hence, the correct answers are:

– Elastic Beanstalk CLI did not create one because your IAM role has no permission to create roles.

– IAM role already exists but has insufficient permissions that Elastic Beanstalk needs.

The option that says: He selected the wrong platform for the Django code is incorrect because this would give a different issue.

The option that says: Instance profile container for the role needs to be manually replaced every time a new environment is launched is incorrect because there is no need to manually replace instance profile containers.

The option that says: You have not associated an Elastic Beanstalk role to your CLI is incorrect because logging in to the CLI also assumes the role in your account.

References:

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/troubleshooting-envcreate.html
https://forums.aws.amazon.com/thread.jspa?messageID=637705
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/iam-instanceprofile.html

Note: This question was extracted from our AWS Certified SysOps Administrator Associate Practice Exams.

 

For more AWS practice exam questions with detailed explanations, check this out:Tutorials Dojo AWS Practice Tests

XX

Additional Training Materials: AWS Elastic Beanstalk Video Courses on Udemy

  1. AWS Elastic Beanstalk – Master Class|Hands On Learning! 
  2. DevOps: CI/CD using AWS CodePipeline & Elastic Beanstalk
  3. Up & Running with Containers in AWS

AWS Elastic Beanstalk Cheat Sheet References:

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg
https://aws.amazon.com/elasticbeanstalk/details/
https://aws.amazon.com/elasticbeanstalk/pricing/
https://aws.amazon.com/elasticbeanstalk/faqs/

Tutorials Dojo portal

Be Inspired and Mentored with Cloud Career Journeys!

Tutorials Dojo portal

Enroll Now – Our Azure Certification Exam Reviewers

azure reviewers tutorials dojo

Enroll Now – Our Google Cloud Certification Exam Reviewers

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

FREE Intro to Cloud Computing for Beginners

FREE AWS, Azure, GCP Practice Test Samplers

Recent Posts

Written by: Jon Bonso

Jon Bonso is the co-founder of Tutorials Dojo, an EdTech startup and an AWS Digital Training Partner that provides high-quality educational materials in the cloud computing space. He graduated from Mapúa Institute of Technology in 2007 with a bachelor's degree in Information Technology. Jon holds 10 AWS Certifications and is also an active AWS Community Builder since 2020.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?