Elastic Beanstalk Environment Management
In this, we will learn about Elastic Beanstalk Environment Management.
- Elastic Beanstalk manage separate environments
for 
- Development
 
- Testing
 
- production use
 
 - Deploy any version of application to any environment.
 - Environments can be long-running or temporary.
 - If terminating an environment, you can save its configuration to recreate later.
 - During application development, it is deployed often to different environments for different purposes.
 - Elastic Beanstalk easily configure how deployments are performed.
 - Either deploy to all of the instances simultaneously or split deployment into batches with rolling deployments.
 - Select platform version when launching an environment
 - Can also split application into multiple components, each running in a separate environment.
 
Elastic Beanstalk Environment Management Console:
- provides a management page for each Elastic Beanstalk environments
 - manage environment’s configuration
 - perform common actions like
- restarting the web servers running
 
- cloning the environment
 
- rebuilding the environment from scratch.
 
 

Environment Dashboard
- main view of the environment management console is a dashboard
 - To view
- choose Dashboard on the navigation pane.
 
 - environment management dashboard shows 
- environment’s health
 
- application version
 
- information about the in-use platform
 
- list of recent events generated by the environment.
 
 
Various sections of Dashboard are:
Health
- Shows the overall health of the environment.
 - environment status is shown with a Causes button
 - choose to view more information about current status.
 
Recent Events
- Shows most recent events emitted by environment.
 - List is updated in real time when environment is being updated.
 
Environment Management Actions
- Actions menu perform common operations on environment.
 - This menu is on right side of environment header under the Create New Environment option.
 - Actions include
- Load Configuration – Load a previously saved configuration.
 
- Save Configuration – Save current configuration of environment to application.
 
- Swap Environment URLs – Swap CNAME of current environment with a new environment.
 
- Clone Environment – Launch a new environment with the same configuration as currently running environment.
 
- Abort Current Operation – Stop an in-progress environment update.
 
- Restart App Servers – Restart the web server running on environment’s instances.
 
- Rebuild Environment – Terminate all resources in the running environment and build a new environment with the same settings.
 
- Terminate Environment – Terminate all resources in the running environment, and remove the environment from the application.
 
- Restore Environment – If the environment has been terminated in the last hour, restore it from this page. After an hour, you can restore it from the application overview page.
 
 
Configuration
- It shows current configuration of environment and resources,
 - It lists 
- EC2 instances
 
- load balancer
 
- notifications
 
- health monitoring settings
 
 - It helps to customize 
- behavior of environment during deployments
 
- enable additional features
 
 
modify the instance type and other settings chosen during environment creation.

Logs
- lets you retrieve logs from EC2 instances in environment.
 - When logs are requested, 
- Elastic Beanstalk sends a command to the instances
 
- which then upload logs to Elastic Beanstalk storage bucket in S3.
 
- When requesting logs on this page, Elastic Beanstalk automatically deletes them from S3 after 15 minutes.
 
 
Environment Types
- Can create one of environment types, as
- load-balancing
 
- autoscaling environment
 
- single-instance
 
 - environment type depends on application to deploy.
 
Load-balancing, Autoscaling Environment
- uses ELB and EC2 Auto Scaling
 - EC2 Auto Scaling starts additional instances
 - If need to running in multiple Availability Zones, use a load-balancing, autoscaling environment. Can switch environment type later.
 
Single-Instance Environment
- It contains one EC2 instance with an Elastic IP address.
 - It doesn’t have a load balancer
 - It uses EC2 Auto Scaling service but, minimum, maximum and desired capacity are set to 1. Hence, , new instances are not started if increased load.
 - Use it, if application to have low traffic or doing remote development.
 
To change an environment’s type
- Open the Elastic Beanstalk console.
 - Navigate to the management page for your environment.
 - Choose Configuration.
 - In the Capacity category, choose Modify.
 
Recommended values
The recommended values set in API, are
Elastic Beanstalk console
- Namespace: aws:autoscaling:launchconfiguration
 
Option Names: IamInstanceProfile, EC2KeyName, InstanceType
- Namespace: aws:autoscaling:updatepolicy:rollingupdate
 
Option Names: RollingUpdateType and RollingUpdateEnabled
- Namespace: aws:elasticbeanstalk:application
 
Option Name: Application Healthcheck URL
- Namespace: aws:elasticbeanstalk:command
 
Option Name: DeploymentPolicy, BatchSize and BatchSizeType
- Namespace: aws:elasticbeanstalk:environment
 
Option Name: ServiceRole
- Namespace: aws:elasticbeanstalk:healthreporting:system
 
Option Name: SystemType and HealthCheckSuccessThreshold
- Namespace: aws:elasticbeanstalk:sns:topics
 
Option Name: Notification Endpoint
- Namespace: aws:elasticbeanstalk:sqsd
 
Option Name: HttpConnections
- Namespace: aws:elb:loadbalancer
 
Option Name: CrossZone
- Namespace: aws:elb:policies
 
Option Names: ConnectionDrainingTimeout and ConnectionDrainingEnabled
EB CLI
- Namespace: aws:autoscaling:launchconfiguration
 
Option Names: IamInstanceProfile, InstanceType
- Namespace: aws:autoscaling:updatepolicy:rollingupdate
 
Option Names: RollingUpdateType and RollingUpdateEnabled
- Namespace: aws:elasticbeanstalk:command
 
Option Name: BatchSize and BatchSizeType
- Namespace: aws:elasticbeanstalk:environment
 
Option Name: ServiceRole
- Namespace: aws:elasticbeanstalk:healthreporting:system
 
Option Name: SystemType
- Namespace: aws:elb:loadbalancer
 
Option Name: CrossZone
- Namespace: aws:elb:policies
 - Option Names: ConnectionDrainingEnabled
 
