AWS Developer Associate (DVA-C01) Review Material – ElasticBeanstalk

General

  • AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS
  • Concepts:
    1. Application: A logical collection of Elastic Beanstalk components, including environmentsversions, and environment configurations. In Elastic Beanstalk an application is conceptually similar to a folder
    2. Application version: Refers to a specific, labelled iteration of deployable code for a web application. An application version points to an S3 object that contains the deployable code, such as a Java WAR file
    3. Environment: A collection of AWS resources running an application version. Each environment runs only one application version at a time, however, you can run the same application version or different application versions in many environments simultaneously
    4. Environment tier:  Designates the type of application that the environment runs, and determines what resources Elastic Beanstalk provisions to support it.
    5. Environment configuration:  Identifies a collection of parameters and settings that define how an environment and its associated resources behave.
    6. Saved configuration:  A template that you can use as a starting point for creating unique environment configurations.
    7. Platform: A combination of an operating system, programming language runtime, web server, application server, and Elastic Beanstalk components. You design and target your web application to a platform (e.g. Go, Java, Python)
  • Use CloudFormation behind the scene.
  • Uses one (1) S3 to store environment settings
  • Can clone environments (if with DB will not clone the DB)

Configuration

  • Presets:
    • Single, HA,Custom
    • On-demand or Spot
  • Software
    • Enable X-Ray, log to S3 or CloudWatch.
    • Set environment properties
  • Instances
    • Root Volume, SG
  • Capacity
    • ASG (min,max,fleet composition) , Instance Type, Scaling Trigger
  • Load balancer
    • ELB Type (ALB/NLB/CLB). Once set it cannot be changed.
      • To change need to manually re-create the configuration
      • Deploy the environment
      • Do a URL swap or Route 53 update.
    • Listeners
  • Network
    • VPC
    • Instance, ELB, DB subnets
  • Database
    • RDS DB Engine (MySQL, SQLServer, Oracle, PostgreSQL)
    • username/password
    • DB Lifecycle is tied to the Beanstalk environment
    • To de-couple from Beanstalk
      1. Create an RDS snapshot for backup
      2. Enable RDS deletion protection
      3. Create a new environment (manually) without the RDS.
      4. The application version should still point to the existing RDS.
      5. Perform a URL Swap or Route 53 DNS change
      6. Terminate the old environment.
      7. Delete the CloudFormation stack of the old environment
  • Security
    • Service Role
    • Instance Role and SSH KP

Deployment Mode

  • All at once
    • The quickest deployment method.
    • Suitable if you can accept a short loss of service, and if quick deployments are important to you.
    • With this method, Elastic Beanstalk deploys the new application version to each instance all at once.
    • Has downtime
  • Rolling
    • Suitable if you can’t accept any period of completely lost service.
    • Bucket/Batch size concept – the no. of instances to be updated
    • Application is deployed to the environment one batch of instances at a time
    • Can set the batch size (Fixed or percentage)
    • NO downtime but with reduced capacity
    • No additional cost.
  • Rolling with additional batch
    • Suitable if you must maintain the same bandwidth throughout the deployment.
    • Elastic Beanstalk launches an extra batch of instances, then performs a rolling deployment.
    • NO downtime and NO reduced capacity
    • Small additional cost due to new instances being created
  • Immutable
    •  A second temporary Auto Scaling group (with new instances) is launched in your environment and the new version serves traffic alongside the old version until the new instances pass health checks.
    • When everything is passed, the new instances will be moved to the current ASG and the old instances will be terminated.
    • Quick rollback
    • NO downtime and NO reduced capacity
    • Higher additional cost
  • Traffic splitting
    • A canary testing deployment method.
    • Suitable if you want to test the health of your new application version using a portion of incoming traffic while keeping the rest of the traffic served by the old application version
    • A second temporary Auto Scaling group (with new instances) is launched in your environment and the new version serves traffic alongside the old version until the new instances pass health checks.
    • A small % of traffic is sent to the temp ASG. Traffic will be monitored for a configurable amount of time,
    • When health is ok during the monitoring period, the new instances will be moved to the current ASG and the old instances will be terminated.
  • Blue/green
    • Not really a feature of Elastic BeanStalk
    • Done manually:
      1. Create a new environment
      2. Validate (can use Route 53 to route a small % of traffic to the new environment)
      3. If ok then use Elastic Beanstalk ‘SWAP URL’ to switch traffic.
  • https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.deploy-existing-version.html

Version Lifecycle

  • Tells 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
    • Specify how many to keep, or Age
    • If to keep the source bundle in S3
  • Applies an application’s lifecycle policy each time you create a new application version.
  • Deletes up to 100 versions each time the lifecycle policy is applied.
  • The application version quota applies across all applications in a region.
  • The quota is 1000/region.
  • Need to specify the role that EB will use to manage the version

Beanstalk Extension (.ebextensions)

  • Configure the environment and customize the AWS resources using a config file embedded in the source code bundle.
  • Must be in the directory .ebextensions and file must end with .config (e.g. .ebextensions/network-load-balancer.config)
  • Can add resources e.g. ElasticCache, RDS.
  • Must be in YAML or JSON format
  • Use option_settings

Docker Deployment

  • Single Docker
    •  Use docker-compose.yml file to pull and run your image if you are using Docker Compose or,
    • Dockerrun.aws.json at root of source
    • Run plain docker in an EC2 instance (no ECS)  
  • Multicontainer Docker
    • Requires a configuration file Dockerrun.aws.json to create task definitions
    • Run docker in an ECS

Leave a Comment

Your email address will not be published. Required fields are marked *