Elastic Beanstalk Flashcards

1
Q

price

A

is free, but you pay for the underlying resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

3 architecture models

A
  1. single instance deployment: good for dev
  2. LB + ASG : for production or pre-prod web app
  3. ASG only: non-web apps in production
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

BeanStalk has three components.

A
  1. an application
  2. an application version, so every time you upload new code, you’ll get an application version,
  3. and environment name, so you’re going to deploy your code to DEV, TEST, and PROD.

And you’re free to name your environments just the way you want, and have as many environments as you wish. You’re going to deploy applications to your environments, and basically will be able to promote
these application versions to the next environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

rollback

A

there is a rollback feature to previous app versions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Beanstalk workflow

A

you create an application, and you create an environment or multiple environments, and then, you’re going to upload a version and you’re going to give it an alias, so, just a name that you want.

And then, this alias, you will release it to environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

deployment options for updates

A
  1. all at once - deploy in one go
  2. rolling: update a few instances at a time (bucket)
  3. rolling with additional batches
  4. immutable: spins up new ASG and then swaps
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

deployment strategy All at once

A

the fastest but the application has a downtime

for quick iterations in dev environment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

deployment strategy Rolling

A

say, we have 4 instances. We define bucket size as 2. So two instances will receive update deployments, and while these 2 updates are being deployed, they will not be available. The application will still be running on the other 2, not-updated instances. So app is running below capacity. When the first two have been updated and are running with the new version, the other tow will receive update deployments.

Application is running both versions simultaneously. No additional costs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

deployment strategy Rolling with additional batches

A

say, we have 4 instances running with version 1. We add two more instances (bucket size) with the new version. Then we start update deployment on 2 instances with the old version. So these two are not available, but we have 2 running with old version and 2 extra running with new version.
When the update on 2 instances is finished, we start update on the last 2 instances with the old version. In the end, we have 6 instances with the new version instead of initial 4, and we terminate 2 of them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

deployment strategy Rolling with additional batches

Evaluation

A
  1. app is running at capacity
  2. running 2 versions at the same time
  3. small additional cost
  4. longer deployment
  5. good for prod
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

deployment strategy immutable

A

new instances are deployed in a completely new ASG. When the new version is deployed on them, they are added to the ASG where instances are running with the old version. These old instances are then terminated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

deployment strategy immutable

Evaluation

A

zero downtime

the longest deployment

high costs for double capacity

quick rollback in case of failures

good for prod

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

blue/green deployment

A

is not a direct feature of AWS. Required manual intervention

  1. create a new environment and deploy v2 there
  2. it can be validated independently and rolled back
  3. Route 53 can be set up with weighted policies to redirect a little bit of traffic to the stage environment
  4. using beanstalk swap URLs when done with testing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

BeanStalk can store at most how many versions

A

1000

if you don’t remove old - you wont be able to deploy anymore

to phase out old versions - use a lifecycle policy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

lifecycle policy to remove old versions

A
  1. can be based on age - how old the version is
    or
  2. how many total versions exist

you can still choose to retain the removed version in S3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

all the parameters that we set in the UI, can also be configured

A

in files inside folder .ebextensions in the root of your source code, with .config as file extension

It must be in the YAML or JSON formats.

you have the ability to add resources, using the EB extensions, such as RDS, ElastiCache, DynamoDB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

anything that is managed by the EB extensions

A

gets deleted if the environment goes away. So that means that if you create for example, an ElastiCache as part of your Elastic Beanstalk environment, and then you delete your Elastic Beanstalk environment,
then your ElastiCache will go away as well.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

if we wanted to connect, for example, to an external RDS database, maybe Postgresql RDS database,
then we will need to set up environment variables

A

with an EB extension

option_settings:
# see: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-elasticbeanstalkapplicationenvironment
aws:elasticbeanstalk:application:environment:
DB_URL: “jdbc:postgresql://rds-url-here.com/db”
DB_USER: username

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

under the hood, Beanstalk relies on

A

CloudFormation = is used to provision other AWS services so we have our infrastructure as code.

20
Q

using the CloudFormation resources in your .ebextensions folder

A

you can provision an ElastiCache, an S3 bucket, an DynamoDB table, whatever you want

with EB extensions and CloudFormation, you can configure anything you want in your AWS.

if you go in AWS Management Console to CloudFormation, you will see the resources that we reserved when we created our elastic beanstalk environment

21
Q

Cloning

A

you can clone an existing environment into a new environment and it will have the exact same configuration.
helpful if you already have a production version of your application and you want to deploy a test version with the exact same settings.

All the resources and the configuration of the original environment are preserved so that includes the load balancer type and the configuration, the RDS database type, although if you have an RDS database, the data is not going to be preserved, but the configuration of your RDS database will,

22
Q

Migration

A

after you create a Beanstalk environment you cannot change the Elastic Load Balancer type, only its configuration. So if you want it to somehow upgrade
from a Classic Load Balancer to an Application Load Balancer you will need to perform a migration

23
Q

Migration steps

A
  1. create a new environment with the same configuration except the Load Balancer. (we can’t use the clone feature because the clone feature would copy the exact same Load Balancer type and configuration. So you have to recreate manually the same configuration)
  2. then we will deploy our application onto the new environment with the new load balancer
  3. shift the traffic from the old environment to the new environment. (CNAME swap or Route 53)
24
Q

Decoupling RDS

A

RDS can be provisioned with your Beanstalk application, which is great if you want to do development and test.

But if you are doing a production deployment, this is not great because the database lifecycle is going to be tied to the Beanstalk environment lifecycle. So the best way to do it in prod is to separate the RDS Database from your Beanstalk environment and reference it using a connection string for example using an environment variable.

25
Q

Decoupling RDS steps

A
  1. create a snapshot of our RDS Database as a safeguard in case things go wrong, so we have a backup or data
  2. go to the RDS console and protect the RDS Database from deletion. This will prevent it from being deleted no matter what
  3. we create a new Elastic Beanstalk environment, this time without RDS. And we point our application to the already existing RDS Database, for example, using an environment variable. So now we have the new environment pointing to the same database.
  4. perform a CNAME swap, so a blue/green deployment or route 53 DNS updates and we confirm it’s working.

So now we have shifted all the traffic from the old version to the new version then we terminate the old environment. And because we have enabled RDS deletion protection then RDS will stay.

  1. Because it’s the CloudFormation stack, behind our Elastic Beanstalk environment - it will be in the Delete Failed state, but not deleted. And so we need to just go in CloudFormation and delete that CloudFormation stack manually.
26
Q

run our application as a single Docker container

A

either provide

  1. Dockerfile: E Beanstalk will build and run the Docker container

or

  1. Dockerrun.aws.json (v1): Describe where already built Docker image is

if you use a single container mode for Docker, it does not use ECS behind the scenes, it just uses Docker on EC2.

27
Q

multi Docker container

A

helps you run multiple containers per EC2 instance in Elastic Beanstalk.

It will create for you:

  • ECS cluster
  • EC2 instances configured to use this cluster
  • LoadBalancer in high availability mode
  • task definitons and execution

Requires Dockerrun.aws.json (v2) at the root of the source code. It is used to generate ECS task definition

Docker images must be pre-built and stored for ex., on Docker Hub

28
Q

HTTPS on Beanstalk

A
  1. Beanstalk with HTTPS

2. Beanstalk redirect HTTP to HTTPS

29
Q

Beanstalk with HTTPS

A

Load SSL certificate onto Load Balancer (from EB console or from ebextensions/securelistener-alb.config)

The certificate can be provisioned via ACM or CLI

Configure security group to allow incoming port 443

30
Q

Beanstalk redirect HTTP to HTTPS

A

configure your instances or your load balancer to redirect HTTP to HTTPS

31
Q

web server versus a worker environment

A

if you’re performing tasks that are very long to complete, you want to offload these tasks to a dedicated environment called a worker environment,
this is to decouple your application into two tiers

For this you can define these periodic tasks into a cron.yaml

you have your web tier which is corresponding to your load balancer and your auto scaling group

and then you would send the messages to an SQS Queue, and your worker tier will be reading from the SQS Queue, and performing these long tasks for you,

32
Q

custom platform (advanced)

A

allow you to define from scratch the operating system, the additional software, the scripts that Beanstalk runs on these platforms,

the only use case for a custom platform is if you have an application language that is both incompatible with Beanstalk and also does not use Docker,

33
Q

To create your own custom platform (advanced)

A

define your own AMI using a platform.yaml file, and then you need to use the Packer software, which is an open source tool to create AMI, to build that platform,

34
Q

I am creating an application and would like for it to be running with minimal cost in a development environment. I should run it in

A

Single Instance Mode

35
Q

I would like to customize the runtime of Elastic Beanstalk and include some of my company wide security software. I should

A

provide a custom platform

36
Q

I would like to update my development environment as soon as a new version is available. Because my Elastic Beanstalk environment is internal and only used by me, I don’t mind downtime. Which deployment options is the best fit?

A

All at once

37
Q

I would like to update my Elastic Beanstalk application so that we are able to roll back very quickly in case of issues with the new application version. Which deployment mode is the best fit?

A

immutable

to roll back quickly, this deployment mode terminates the temporary ASG that has the new version, while the current one is untouched and already running at capacity

38
Q

I want to update my Elastic Beanstalk application gradually without incurring new costs on update. My application has been over provisioned and can temporarily decrease in size for the number of serving instances, but I still want to serve my users without downtime. I do not want to incur extra costs over updates. Which deployment mode is the best fit?

A

Rolling

39
Q

We would like to update our EB application with minimal added cost, while maintaining the full capacity to serve our current users in production. Which deployment is the best fit?

A

Rolling with additional batches

40
Q

I would like to create an ElastiCache with my Elastic Beanstalk environment. I should

A

create an elasticcache.config file in .ebextensions folder at the root of the code zip file and provide the configuration

41
Q

My deployments on Elastic Beanstalk have been painfully slow, and after looking at the logs, I realize this is due to the fact that my dependencies are resolved on each EC2 machine at deployment time. How can I speed up my deployment with the minimal impact?

A

resolve dependencies beforehand and package them into zip file uploaded to Elastic Beanstalk

42
Q

You would like your Elastic Beanstalk environment to expose an HTTPS endpoint instead of an HTTP endpoint in order to get in-flight encryption between your clients and your web servers. What must be done to setup HTTPS on Beanstalk?

A

create an .ebextensions/elb.config file to configure LB

43
Q

How can you remove older versions that are not used by Elastic Beanstalk so that new versions can be created for your applications?

A

Use Lifecycle policy

44
Q

You are looking to perform a set of repetitive and scheduled tasks asynchronously. Which Elastic Beanstalk environment should you setup?

A

set up a worker environment and cron.yaml

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-tiers.html

45
Q

You have created a test environment in Elastic Beanstalk and as part of that environment, you have created an RDS database. How can you make sure the database can be explored after the environment is destroyed?

A

make a snapshot of the database before it is deleted