You are currently viewing Environment Configuration Options In Elastic Beanstalk

Environment Configuration Options In Elastic Beanstalk

Environment Configuration Options In Elastic Beanstalk

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed how to create a new application environment using Elastic Beanstalk.

https://cloudaffaire.com/how-to-create-a-new-application-environment-in-elastic-beanstalk/

In this blog post, we will discuss different environment configuration options available in Elastic Beanstalk.

Environment configuration options:

Elastic Beanstalk provides a wide range of options for customizing the resources in your environment, and Elastic Beanstalk behavior and platform settings. The configuration options changes depending upon environment tier (web or worker), application platform (PHP, python, ruby, etc.) and application requirement (database, auto-scaling, etc.) but more or less can be set in below configuration options.

  • Software: Controls environment specific configurations like application environment variables.
  • Instance: Controls EC2 instances for your environment.
  • Capacity: Controls Auto Scaling group configuration that manages the AWS EC2 instances in your environment.
  • Load Balancer: Controls Load balancer configuration for your environment.
  • Rolling updates and deployments: Controls EC2 instance replacement behavior for updates or new deployments.
  • Security: Controls the security of your environment and EC2 instances in it.
  • Monitoring: Controls CloudWatch monitoring configurations.
  • Managed updates: Controls environment platform updates.
  • Notification: Controls email notification.
  • Network: Controls network for your environment.
  • Database: Controls the database for your environment.
  • Worker: Controls SQS queue for your environment. Only available in worker tier.
  • Tags: Controls tags for your environment.

Environment Configuration Options In Elastic Beanstalk

There are a number of ways you can apply configuration options to your environment and if the same option is set in multiple locations, the value used is determined by the order of precedence.

Ways to apply configuration options:

  • Configuration option applied directly: Configuration option that is applied directly using AWS Management Console, EB CLI, AWS CLI, and SDKs gets the highest precedence.
  • Configuration option applied through Saved Configurations: Configuration options that are not applied directly to the environment can be loaded from a saved configuration and gets the next precedence.
  • Configuration option applied through configuration Files (.ebextensions): Configuration options that are not applied directly to the environment, and also not specified in a saved configuration, are loaded from configuration files in the .ebextensions folder at the root of the application source bundle and gets the next precedence.
  • Configuration option applied through default Values: If a configuration option has a default value, it only applies when the option is not set at any of the above levels.

Saved Configurations:

You can create a saved configuration to save settings that you have applied to an existing environment during or after environment creation by using the AWS Management Console, EB CLI, or AWS CLI. Saved configurations belong to an application and can be applied to new or existing environments for that application.

Configuration Files (.ebextensions):

You can add AWS Elastic Beanstalk configuration files (.ebextensions) to your application’s source code to configure your environment and customize the AWS resources that it contains. Configuration files are YAML- or JSON-formatted documents with a .config file extension that you place in a folder named .ebextensions and deploy in your application source bundle.

Next, we will dig down in each individual configuration options available in AWS Elastic Beanstalk console for a PHP application. In this blog post, we are only listing the different environment configuration options. In the next blog post, we will create a new environment utilizing most of the environment configurations options.

Environment configuration options (Detailed view):

  • Software:
    • Container Options: The following settings control container behavior and let you pass key-value pairs in as OS environment variables.
      • Document root: Used as your web-server root directory (equivalent to /var/www/html).
      • Memory limit: The amount of memory allocated to the PHP environment.
      • Zlib output compression: Whether PHP should use compression for output.
      • Allow URL fopen: Whether the PHP’s file functions are allowed to retrieve data from remote locations, such as websites or FTP servers.
      • Display errors: Whether error messages should be part of the output.
      • Max execution time (seconds): The maximum time a script is allowed to run before the environment terminates it.
    • S3 log storage: Configure the instances in your environment to upload rotated logs to Amazon S3.
      • Rotate logs: Enable or disable S3 log storage.
    • Instance log streaming to CloudWatch Logs: Configure the instances in your environment to stream logs to CloudWatch Logs.
      • Log streaming: Enable or disable log streaming.
      • Retention: No. of day’s the logs will be available in CloudWatch.
      • Lifecycle: Keep or delete the logs, if the environment is terminated.
    • Environment properties: Used to pass secrets, endpoints, debug settings, etc. in the form of environment variables to your application.
  • Instance:
    • Instance type: To control the EC2 instance size and os.
      • Instance type: Controls instance size
      • AMI ID: Controls instance OS.
    • CloudWatch monitoring interval: Controls monitoring of the EC2 instance (Detailed or basic monitoring).
    • Root volume: Controls storage of the EC2 instance.
      • Root volume type: Controls EBS volume type (Magnetic or SSD)
      • Size: The number of gigabytes of the root volume attached to each instance.
      • IOPS: Input/output operations per second for a provisioned IOPS (SSD) volume.
    • Security Groups: Controls firewall of your EC2 instance.
  • Capacity:
    • Auto Scaling Group: Configure the compute capacity of your environment and Auto Scaling settings to optimize the number of instances used.
      • Environment type: Single instance or load balanced.
      • Instances: Number of instances for auto-scaling.
      • Availability Zones: Number of Availability Zones (AZs) to use.
      • Placement: Availability Zones (AZs) to use.
    • Scaling triggers:
      • Scaling cooldown: Duration for which Auto Scaling group doesn’t launch or terminate additional instances before the previous scaling activity takes effect.
      • Metric: Metric that is monitored to determine if the environment’s capacity is too low or too high. For example, CPU_Utilization.
      • Statistic: Controls how the metric is interpreted. For example, Average or Maximum CPU_Utilization.
      • Unit: Metrics units like percentage, seconds, count, etc. For example, Average CPU_Utilization percentage.
      • Period: The period between metric evaluations. For example, check the Average CPU_Utilization percentage every 5 mins.
      • Breach duration: The amount of time a metric can exceed a threshold before triggering a scaling operation. For example, Avg CPU_Utilizatio some condition for 1 min.
      • Upper threshold: A scale up will happen when this threshold is breached. For example, Avg CPU_Utilizatio > 90 % for 1 mins.
      • Scale up increment: No. of instances that will be added.
      • Lower threshold: A scale down will happen when this threshold is breached. For example, Avg CPU_Utilizatio < 50 % for 1 mins.
      • Scale down increment: No. of instances that will be removed.
    • Time-based Scaling: You can also schedule scale up or scale down as per your requirement.
  • Load Balancer:
    • Application Load Balancer:
      • Listener: listener routes incoming client traffic on a specified port using a specified protocol to your environment processes.
        • Port: The port that the listener will listen to (default port 80)
        • Protocol: The transport protocol that the load balancer uses for routing incoming traffic from clients.
      • Processes: For each environment process, you can specify the protocol and port that the load balancer uses to route requests to the process.
        • Environment process:
          • Name: Name of the process
          • Port: The port used to communicate.
          • Protocol: The protocol used to communicate.
        • Health check:
          • HTTP code: HTTP status code of a healthy instance in your environment.
          • Path: Path to which the load balancer sends HTTP health check requests.
          • Timeout: Amount of time to wait for a health check response.
          • Interval: Amount of time between health checks of an individual instance. The interval must be greater than the timeout.
          • Unhealthy/Healthy threshold: The number of health checks that must fail or pass, respectively, before Elastic Load Balancing changes an instance’s health state.
          • Deregistration delay: The amount of time, in seconds, to wait for active requests to complete before deregistering an instance.
      • Rules: load balancer uses rules to routes requests to environment processes.
        • Name: Name of the rule
        • Listener Port: The port of the listener that the rule applies to.
        • Priority: The rule’s priority. A lower priority number has higher precedence. Priorities of a listener’s rules must be unique.
        • Path pattern: A pattern defining the request paths that the rule applies to.
        • Process: The process to which the load balancer routes requests that match the rule.
      • Access log files: Configure Elastic Load Balancing to capture logs with detailed information about requests sent to your Load Balancer.
        • Store logs: Enable or disable storing access logs in S3 bucket.
        • S3 bucket: Bucket name where the logs will be stored.
        • Prefix: Logical hierarchy in the bucket. If you don’t specify a prefix, Elastic Load Balancing stores access logs at the bucket’s root.
    • Classic Load Balancer:
      • Listener: listener routes incoming client traffic on a specified port using a specified protocol to your environment processes.
        • Listener Port: The port that the listener will listen to.
        • Listener protocol: The load balancer transport protocol to use for routing.
        • Instance port: The port on which the instance server is listening (default is 80).
        • Instance protocol: The protocol to use for routing traffic to backend instances.
      • Sessions: let you control whether the load balancer routes requests for the same session to the Amazon EC2 instance with the smallest load, or consistently to the same instance.
        • Session stickiness enabled: To enable or disable sticky sessions.
          • Cookie duration: Lifetime of the sticky session cookie between an Amazon EC2 instance and the load balancer.
        • Load balancer ports: List of the listener ports that the default policy (AWSEB-ELB-StickinessPolicy) applies to.
      • Cross-zone load balancing: Load balancing across multiple Availability Zones enabled
      • Connection draining timeout: Maximum time that the load balancer maintains connections to an Amazon EC2 instance before forcibly closing connections.
      • Health check: Instance health check.
        • Health check path: The path to which the load balancer sends health check requests. If you don’t set the path, the load balancer attempts to make a TCP connection on port 80 to verify the health.
        • Timeout: The amount of time, in seconds, to wait for a health check response.
        • Interval: The amount of time, in seconds, between health checks of an individual instance. The interval must be greater than the timeout.
        • Unhealthy\Healthy threshold – The number of health checks that must fail or pass, respectively, before Elastic Load Balancing changes an instance’s health state.
    • Network Load Balancer:
      • Listener: listener routes incoming client traffic on a specified port using a specified protocol to your environment processes.
        • Listener port: The port that the listener will listen to.
        • Protocol: The transport protocol that the load balancer uses for routing incoming traffic from clients.
        • Process port: The port to which this listener routes traffic. It determines the environment process that receives traffic from the listener.
      • Processes: For each environment process, you can specify the protocol and port that the load balancer uses to route requests to the process.
        • Environment process:
          • Name: Name of the process
          • Process Port: The port used to communicate.
        • Health check:
          • Interval: Amount of time between health checks of an individual instance.
          • Unhealthy\Healthy threshold: The number of health checks that must fail or pass, respectively, before Elastic Load Balancing changes an instance’s health state.
          • Deregistration delay: Amount of time to wait for active requests to complete before deregistering.
  • Rolling updates and deployments:
    • Application deployments: Choose how AWS Elastic Beanstalk propagates source code changes and software configuration updates.
      • Deployment policy: Controls how updates are deployed.
      • Batch size: In how many instances the update will be applied (Percentage or Fixed)
    • Configuration updates: Changes to virtual machine settings and VPC configuration trigger rolling updates to replace the instances in your environment without downtime.
      • Rolling update type: Controls when the updates will be deployed.
      • Batch size: The maximum number of instances to replace in each phase of the update.
      • Minimum capacity: The minimum number of instances to keep in service at all times.
      • Pause time: Pause the update for up to an hour between each batch.
    • Deployment preferences: Customize health check requirements and deployment timeouts.
      • Ignore health check: Don’t fail deployments due to health check failures.
      • Healthy threshold: Lower the threshold for an instance in a batch to pass health checks during an update or deployment.
      • Command timeout: Change the amount of time in seconds that AWS Elastic Beanstalk allows an instance to complete deployment commands.
  • Security:
    • Service role: Service role used by Elastic Beanstalk to access other AWS services.
    • EC2 key pair: Key pair to use for EC2 instances.
    • IAM instance profile: Service role used by EC2 to access other AWS services.
  • Monitoring:
    • Health reporting: Enhanced health reporting provides free real-time application and operating system monitoring of the instances and other resources in your environment.
      • System: Granularity of monitoring, basic or enhanced.
      • CloudWatch Custom Metrics: CloudWatch instance and application-level metrics.
    • Health monitoring rule customization: Configure the HTTP application status codes included in determining your environment’s health.
      • Ignore HTTP 4xx: Allows you to configure this rule and ignore application HTTP 4xx errors on the environment’s instances.
    • Health event streaming to CloudWatch Logs: Configure Elastic Beanstalk to stream environment health events to CloudWatch Logs.
      • Log streaming: Enable or disable log streaming.
      • Retention: No. of day’s the logs will be available in CloudWatch.
      • Lifecycle: Keep or delete the logs, if the environment is terminated.
  • Managed updates:
    • Managed platform updates: Enable managed platform updates to apply platform updates automatically during a weekly maintenance window that you choose.
      • Managed updates: Enable or disable managed updates.
      • Weekly update window: Timeframe when the update will happen.
      • Update level: Controls whether to apply only patch or patch+minor
      • Instance replacement: If enabled, an instance replacement will be scheduled if no other updates are available.
  • Notification:
    • Email notifications: Enter an email address to receive email notifications for important events from your environment.
  • Network:
    • Virtual private cloud (VPC): Launch your environment in a custom VPC instead of the default VPC. You can create a VPC and subnets in the VPC management console.
      • VPC: Provide VPC ID.
    • Load balancer settings:
      • Visibility: Make your load balancer internal if your application serves requests only from connected VPCs. Public load balancers serve requests from the Internet.
      • Load balancer subnets: Assign your load balancer to a subnet in each Availability Zone (AZ) in which your application runs.
    • Instance settings:
      • Public IP address: Assign a public IP address to the Amazon EC2 instances in your environment.
      • Instance subnets: Choose a subnet in each AZ for the instances that run your application.
  • Database:
    • Restore a snapshot: Restore an existing snapshot in your account, or create a new database.
      • Snapshot: Choose an existing database snapshot. Elastic Beanstalk restores the snapshot and adds it to your environment.
    • Database settings: Choose an engine and instance type for your environment’s database.
      • Engine: Choose a database engine.
      • Engine version: Choose a specific version of the database engine.
      • Instance class: Choose the DB instance class.
      • Storage: Choose the amount of storage to provision for your database. You can increase allocated storage later, but you cannot decrease it.
      • Username: Type a user name of your choice using alphanumeric characters.
      • Password: Type a password of your choice containing 8–16 printable ASCII characters (excluding /, \, and @).
      • Retention: Choose to create a snapshot of the database when you terminate your environment.
      • Availability: Choose High (Multi-AZ) to run a warm back up in a second Availability Zone for high availability.
  • Worker:
    • Queue: You can create a new Amazon SQS queue for your worker application or pull work items from an existing queue.
      • Worker queue: SQS queue from which to read work items.
    • Messages:
      • HTTP path: The daemon pulls items from the Amazon SQS queue and posts them locally to this path.
      • MIME type: Change the MIME type of the POST requests that the worker daemon sends to your application.
      • HTTP connections: Maximum number of concurrent connections to the application.
      • Visibility timeout: The amount of time to lock an incoming message for processing before returning it to the queue.
      • Error visibility timeout: The amount of time to wait before resending a message after an error response from the application.
    • Advanced options:
      • Max retries: Maximum number of retries after which the message is discarded.
      • Connection timeout: Number of seconds to wait for a response from the application when establishing a new connection.
      • Inactivity timeout: Number of seconds to wait for a response from the application on an existing connection.
      • Retention period: Number of seconds that a message is valid for active processing.
  • Tags: Apply up to 50 tags to the resources in your environment in addition to the default tags.

Hope you have enjoyed this article. In the next blog post, we will discuss the command line interface in Elastic Beanstalk.

You can refer below links to get a complete list of configuration options.

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-specific.html

To get more details on AWS Elastic Beanstalk, please refer below AWS documentation

https://docs.aws.amazon.com/elastic-beanstalk/index.html