From f7edd72302b34f10787244eadf4b076785063b9b Mon Sep 17 00:00:00 2001 From: abregman Date: Sat, 13 Nov 2021 20:57:18 +0200 Subject: [PATCH] Add a couple of AWS exercises Questions as well :) --- README.md | 6 +- exercises/aws/README.md | 149 +++++++++++++++++- exercises/aws/elastic_ip.md | 10 ++ exercises/aws/elastic_network_interfaces.md | 10 ++ exercises/aws/placement_groups.md | 6 + exercises/aws/solutions/elastic_ip.md | 28 ++++ .../solutions/elastic_network_interfaces.md | 25 +++ exercises/aws/solutions/placement_groups.md | 23 +++ 8 files changed, 249 insertions(+), 8 deletions(-) create mode 100644 exercises/aws/elastic_ip.md create mode 100644 exercises/aws/elastic_network_interfaces.md create mode 100644 exercises/aws/placement_groups.md create mode 100644 exercises/aws/solutions/elastic_ip.md create mode 100644 exercises/aws/solutions/elastic_network_interfaces.md create mode 100644 exercises/aws/solutions/placement_groups.md diff --git a/README.md b/README.md index af63d35..0bb402f 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@

-:information_source:  This repo contains questions and exercises on various technical topics, sometimes related to DevOps and SRE :) +:information_source:  This repo contains questions and exercises on various technical topics, sometimes related to DevOps and SRE -:bar_chart:  There are currently **1999** questions +:bar_chart:  There are currently **1999** exercises and questions :books:  To learn more about DevOps and SRE, check the resources in [devops-resources](https://github.com/bregman-arie/devops-resources) repository :warning:  You can use these for preparing for an interview but most of the questions and exercises don't represent an actual interview. Please read [FAQ page](faq.md) for more details -:busts_in_silhouette:  [Join](https://www.facebook.com/groups/538897960007080) our [DevOps community](https://www.facebook.com/groups/538897960007080) where we have discussions and share resources on DevOps +:busts_in_silhouette:  Join our [DevOps community](https://www.facebook.com/groups/538897960007080) where we have discussions and share resources on DevOps :pencil:  You can add more questions and exercises by submitting pull requests :) Read about contribution guidelines [here](CONTRIBUTING.md) diff --git a/exercises/aws/README.md b/exercises/aws/README.md index 70836a9..f2d8c07 100644 --- a/exercises/aws/README.md +++ b/exercises/aws/README.md @@ -18,9 +18,11 @@ |--------|--------|------|----|----| | Launch EC2 web instance | EC2 | [Exercise](launch_ec2_web_instance.md) | [Solution](solutions/launch_ec2_web_instance.md) | Easy | | Security Groups | EC2 | [Exercise](security_groups.md) | [Solution](solutions/security_groups.md) | Easy | -| IAM Roles | EC2 + IAM | [Exercise](ec2_iam_roles.md) | [Solution](solutions/ec2_iam_roles.md) | Easy | +| IAM Roles | EC2, IAM | [Exercise](ec2_iam_roles.md) | [Solution](solutions/ec2_iam_roles.md) | Easy | | Spot Instances | EC2 | [Exercise](create_spot_instances.md) | [Solution](solutions/create_spot_instances.md) | Easy | - +| Elastic IP | EC2, Networking | [Exercise](elastic_ip.md) | [Solution](solutions/elastic_ip.md) | Easy | +| Placement Groups Creation | EC2, Placement Groups | [Exercise](placement_groups.md) | [Solution](solutions/placement_groups.md) | Easy | +| Elastic Network Interfaces | EC2, ENI | [Exercise](elastic_network_interfaces.md) | [Solution](solutions/elastic_network_interfaces.md) | Easy | #### AWS - Lambda @@ -303,6 +305,14 @@ Storage Optimized: * Use cases: databases, OLTP system, distributing file systems +
+What can you attach to an EC2 instance in order to store data?
+ +EBS +
+ +##### AWS EC2 - EBS +
What is EBS?
@@ -310,6 +320,18 @@ Storage Optimized: More on EBS [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html)
+
+What happens to EC2 disk (EBS) when the instance is terminated?
+ +All the related EBS volumes are removed and data is lost. +
+ +
+What happens to the EC2 disk (EBS) when the instance is stopped?
+ +Disk is intact and can be used when the instance starts. +
+
What EC2 pricing models are there?
@@ -509,6 +531,24 @@ Set of Spot instance and if you want, also on-demand instances. * capacityOptimized: optimized based on the number of instances
+
+From networking perspective, what do you get by default when running an EC2 instance?
+ +A private IP and a public IP. +
+ +
+What happens when you hibernate an EC2 instance?
+ +[AWS Docs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Hibernate.html: "Hibernation saves the contents from the instance memory (RAM) to your Amazon Elastic Block Store (Amazon EBS) root volume." +
+ +
+True or False? Using EC2 hibernate option results in having faster instance boot
+ +True. This is because the operating system isn't restarted or stopped. +
+ #### AWS - Lambda
@@ -1100,8 +1140,26 @@ False. Only one internet gateway can be attached to a single VPC.
What is an Elastic IP address?
-An Elastic IP address is a reserved public IP address that you can assign to any EC2 instance in a particular region, until you choose to release it. -When you associate an Elastic IP address with an EC2 instance, it replaces the default public IP address. If an external hostname was allocated to the instance from your launch settings, it will also replace this hostname; otherwise, it will create one for the instance. The Elastic IP address remains in place through events that normally cause the address to change, such as stopping or restarting the instance. + +[AWS Docs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html): "An Elastic IP address is a static IPv4 address designed for dynamic cloud computing. An Elastic IP address is allocated to your AWS account, and is yours until you release it. By using an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account." +
+ +
+True or False? When stopping and starting an EC2 instance, its public IP changes
+ +True +
+ +
+What are the best practices around Elastic IP?
+ +The best practice is actually not using them in the first place. It's more common to use a load balancer without a public IP or use a random public IP and register a DNS record to it +
+ +
+True or False? An Elastic IP is free, as long it's not associated with an EC2 instance
+ +False. An Elastic IP is free of charge as long as **it is ** associated with an EC2 instance. This instance should be running and should have only one Elastic IP.
@@ -1125,6 +1183,88 @@ Read more about it [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec Allows you to connect your corporate network to AWS network.
+
+True or False? When you need a fixed public IP for your instance, you should use an Elastic IP
+ +True +
+ +##### AWS EC2 - ENI + +
+Explain Elastic Network Interfaces (ENI)
+ +[AWS Docs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html): "An elastic network interface is a logical networking component in a VPC that represents a virtual network card." +
+ +
+Name at least three attributes the Elastic Network Interfaces (ENI) can include
+ +1. One public IPv4 address +2. Mac Address +3. A primary private IPv4 address (from the address range of your VPC) +
+ +
+True or False? ENI are not bound to a specific availability zone
+ +False. ENI are bound to specific availability zone. +
+ +
+True or False? ENI can be created independently of EC2 instances
+ +True. They can be attached later on and on the fly (for failover purposes). +
+ +##### AWS EC2 - Placement Groups + +
+What are "Placement Groups"?
+ +[AWS Docs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html): "When you launch a new EC2 instance, the EC2 service attempts to place the instance in such a way that all of your instances are spread out across underlying hardware to minimize correlated failures. You can use placement groups to influence the placement of a group of interdependent instances to meet the needs of your workload." +
+ +
+What Placement Groups strategies are there?
+ +* Cluster: places instance close together in an AZ. +* Spread: spreads the instance across the hardware +* Partition: spreads the instances across different partitions (= different sets of hardware/racks) within an AZ +
+ +
+For each of the following scenarios choose a placement group strategy: + + * High availability is top priority + * Low latency between instances + * Instances must be isolated from each other + * Big Data applications that are partition aware + * Big Data process that needs to end quickly
+ + * High availability is top priority - Spread + * Low latency between instances - Cluster + * Instances must be isolated from each other - Spread + * Big Data applications that are partition aware - Partition + * Big Data process that needs to end quickly - Cluster +
+ +
+What are the cons and pros of the "Cluster" placement group strategy?
+ +Cons: if the hardware fails, all instances fail +Pros: Low latency & high throughput network +
+ +
+What are the cons and pros of the "Spread" placement group strategy?
+ +Cons: + * Current limitation is 7 instances per AZ (per replacement group) +Pros: + * Maximized high availability (instances on different hardware, span across AZs) +
+ #### AWS - Identify the service or tool
@@ -1668,4 +1808,3 @@ AWS definition: "Amazon Simple Queue Service (SQS) is a fully managed message qu Learn more about it [here](https://aws.amazon.com/sqs)
- diff --git a/exercises/aws/elastic_ip.md b/exercises/aws/elastic_ip.md new file mode 100644 index 0000000..5260abe --- /dev/null +++ b/exercises/aws/elastic_ip.md @@ -0,0 +1,10 @@ +## AWS EC2 - Elastic IP + +### Requirements + +* An EC2 instance with public IP (not elastic IP) + +### Objectives + +1. Write down the public IP of your EC2 instance somewhere and stop & start the instance. Does the public IP address is the same? why? +2. Handle this situation so you have the same public IP even after stopping and starting the instance diff --git a/exercises/aws/elastic_network_interfaces.md b/exercises/aws/elastic_network_interfaces.md new file mode 100644 index 0000000..fdc4d9b --- /dev/null +++ b/exercises/aws/elastic_network_interfaces.md @@ -0,0 +1,10 @@ +## AWS EC2 - Elastic Network Interfaces + +### Requirements + +* An EC2 instance with network interface + +### Objectives + +A. Create a network interface and attach it to the EC2 instance that already has one network interface +B. Explain why would anyone use two network interfaces diff --git a/exercises/aws/placement_groups.md b/exercises/aws/placement_groups.md new file mode 100644 index 0000000..781d8f4 --- /dev/null +++ b/exercises/aws/placement_groups.md @@ -0,0 +1,6 @@ +## AWS EC2 - Placement Groups + +### Objectives + +A. Create a placement group. It should be one with a low latency network. Make sure to launch an instance as part of this placement group. +B. Create another placement group. This time high availability is a priority diff --git a/exercises/aws/solutions/elastic_ip.md b/exercises/aws/solutions/elastic_ip.md new file mode 100644 index 0000000..e269292 --- /dev/null +++ b/exercises/aws/solutions/elastic_ip.md @@ -0,0 +1,28 @@ +## AWS EC2 - Elastic IP + +### Requirements + +* An EC2 instance with public IP (not elastic IP) + +### Objectives + +1. Write down the public IP of your EC2 instance somewhere and stop & start the instance. Does the public IP address is the same? why? +2. Handle this situation so you have the same public IP even after stopping and starting the instance + +### Solution + +1. Go to EC2 service -> Instances + 1. Write down current public IP address + 2. Click on "Instance state" -> Stop instance -> Stop + 3. Click on "Instance state" -> Start Instance + 4. Yes, the public IP address has changed +2. Let's use an Elastic IP address + 1. In EC2 service, under "Network & Security" click on "Elastic IP" + 2. Click on the "Allocate elastic IP address" button + 3. Make sure you select "Amazon's pool of IPv4 addresses" and click on "Allocate" + 4. Click on "Actions" and then "Associate Elastic IP address" + 1. Select "instance", choose your instance and provide its private IP address + 2. Click on "Associate" + 5. Now, if we go back to the instance page, we can see it is using the Elastic IP address as its public IP + +Note: to remove it, use "disassociate" option and don't forget to also release it so you won't be billed. diff --git a/exercises/aws/solutions/elastic_network_interfaces.md b/exercises/aws/solutions/elastic_network_interfaces.md new file mode 100644 index 0000000..d6c2210 --- /dev/null +++ b/exercises/aws/solutions/elastic_network_interfaces.md @@ -0,0 +1,25 @@ +## AWS EC2 - Elastic Network Interfaces + +### Requirements + +* An EC2 instance with network interface + +### Objectives + +A. Create a network interface and attach it to the EC2 instance that already has one network interface +B. Explain why would anyone use two network interfaces + +### Solution + +A. +1. Go to EC2 service +2. Click on "Network Interfaces" under "Network & Security" +3. Click on "Create network interface" +4. Provide a description +5. Choose a subnet (one that is in the AZ as the instance) +6. Optionally attach a security group and click on "Create network interface" +7. Click on "Actions" -> "Attach" and choose the instance to attach it to +8. If you go now to "Instances" page you'll see your instance has two network interfaces + +B. +1. You can move the second network interface between instances. This allows us to create kind of a failover mechanism between the instances. diff --git a/exercises/aws/solutions/placement_groups.md b/exercises/aws/solutions/placement_groups.md new file mode 100644 index 0000000..07ded19 --- /dev/null +++ b/exercises/aws/solutions/placement_groups.md @@ -0,0 +1,23 @@ +## AWS EC2 - Placement Groups + +### Objectives + +A. Create a placement group. It should be one with a low latency network. Make sure to launch an instance as part of this placement group. +B. Create another placement group. This time high availability is a priority + +### Solution + +A. +1. Go to EC2 service +2. Click on "Placement Groups" under "Network & Security" +3. Click on "Create placement group" +4. Give it a name and choose the "Cluster" placement strategy because the requirement is low latency network +5. Click on "Create group" +6. Go to "Instances" and click on "Launch an instance". Choose any properties you would like, just make sure to check "Add instance to placement group" and choose the placement group you've created + +B. +1. Go to EC2 service +2. Click on "Placement Groups" under "Network & Security" +3. Click on "Create placement group" +4. Give it a name and choose the "Spread" placement strategy because the requirement is high availability as top priority +5. Click on "Create group"