diff --git a/README.md b/README.md index 9e32d2c28..3961f81ae 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ programming
Programming
Python
Python
go
Go
- Bash
Scripts
+ Bash
Shell Scripting
kubernetes
Kubernetes
Prometheus
Prometheus
@@ -546,7 +546,6 @@ A development strategy used by developers to release software automatically into For more info please read [here](https://www.atlassian.com/continuous-delivery/continuous-deployment) -
Can you describe an example of a CI (and/or CD) process starting the moment a developer submitted a change/PR to a repository?
@@ -575,6 +574,12 @@ A development strategy used to frequently deliver code to QA and Ops for testing For more info please read [here](https://www.atlassian.com/continuous-delivery/continuous-deployment)
+
+What is difference between Continuous Delivery and Continuous Deployment?
+ +Both encapsulate the same process of deploying the changes which were compiled and/or tested in the CI pipelines.
+The difference between the two is that Continuous Delivery isn't fully automated process as opposed to Continuous Deployment where every change that is tested in the process is eventually deployed to production. In continuous delivery someone is either approving the deployment process or the deployment process is based on constraints and conditions (like time constraint of deploying every week/month/...) +
What CI/CD best practices are you familiar with? Or what do you consider as CI/CD best practice?
@@ -931,7 +936,14 @@ False. Auto scaling adjusts capacity and this can mean removing some resources b ### AWS Exercises -#### AWS Lambda +#### AWS - IAM + +|Name|Topic|Objective & Instructions|Solution|Comments| +|--------|--------|------|----|----| +| Create a User | IAM | [Exercise](exercises/aws/create_user.md) | [Solution](exercises/aws/solutions/create_user.md) | | +| Password Policy | IAM | [Exercise](exercises/aws/password_policy.md) | [Solution](exercises/aws/solutions/password_policy.md) | | + +#### AWS - Lambda |Name|Topic|Objective & Instructions|Solution|Comments| |--------|--------|------|----|----| @@ -948,9 +960,10 @@ False. Auto scaling adjusts capacity and this can mean removing some resources b * Availability zone * Region * Edge location
+ AWS regions are data centers hosted across different geographical locations worldwide.
-Within each region, there are multiple isolated locations known as Availability Zones. Multiple availability zones ensure high availability in case one of them goes down.
+Within each region, there are multiple isolated locations known as Availability Zones. Each availability zone is one or more data-centers with redundant network and connectivity and power supply. Multiple availability zones ensure high availability in case one of them goes down.
Edge locations are basically content delivery network which caches data and insures lower latency and faster delivery to the users in any location. They are located in major cities in the world.
@@ -962,18 +975,21 @@ True.
-Do you agree with the statement "AWS region should be chosen based on proximity alone"?
+True or False? Each region has a minimum number of 1 availability zones and the maximum is 4
-Note: opinionated answer. +False. The minimum is 2 while the maximum is 6. +
-No. There are a couple of factors to consider when choosing a region (order doesn't mean anything): +
+What considerations to take when choosing an AWS region for running a new application?
-1. Cost - regions vary in cost and AWS Price List API can assist in calculating the difference in cost between the different regions. -2. Speed -3. Features +* Services Availability: not all service (and all their features) are available in every region +* Reduced latency: deploy application in a region that is close to customers +* Compliance: some countries have more strict rules and requirements such as making sure the data stays within the borders of the country or the region. In that case, only specific region can be used for running the application +* Pricing: the pricing might not be consistent across regions so, the price for the same service in different regions might be different.
-#### AWS IAM +#### AWS - IAM
What is IAM? What are some of its features?
@@ -989,11 +1005,36 @@ True
-Given an example of IAM best practices?
+True or False? When creating an AWS account, root account is created by default. This is the recommended account to use and share in your organization
+ +False. Instead of using the root account, you should be creating users and use them. +
+ +
+True or False? Groups in AWS IAM, can contain only users and not other groups
+ +True +
+ +
+True or False? Users in AWS IAM, can belong only to a single group
+ +False. Users can belong to multiple groups. +
+ +
+What best practices are there regarding IAM in AWS?
* Set up MFA * Delete root account access keys * Create IAM users instead of using root for daily management +* Apply "least privilege principle": give users only the permissions they need, nothing more than that. +
+ +
+What permissions does a new user have?
+ +Only a login access.
@@ -1026,9 +1067,34 @@ There can be several reasons for that. One of them is lack of policy. To solve t
-What permissions does a new user have?
+What statements are consist of in AWS IAM policies?
-Only a login access. +* Sid: identifier of the statement (optional) +* Effect: allow or deny access +* Action: list of actions (to deny or allow) +* Resource: a list of resources to which the actions are applied +* Principal: role or account or user to which to apply the policy +* Condition: conditions to determine when the policy is applied (optional) +
+ +
+Explain the following policy: + +``` +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect:": "Allow", + "Action": "*", + "Resources": "*" + } + ] +} +``` +
+ +This policy permits to perform any action on any resource. It happens to be the "AdministratorAccess" policy.
#### AWS - Compute @@ -1040,6 +1106,12 @@ Only a login access. Read more [here](https://aws.amazon.com/ec2)
+
+True or False? EC2 is a regional service
+ +True. As opposed to IAM for example, which is a global service, EC2 is a regional service. +
+
What is AMI?
@@ -2557,12 +2629,30 @@ For example, your computer's private IP could be 192.168.1.100, but your router Which factors affect network performances
+#### Network - Data and Control planes +
-What the terms "Data Plane" and "Control Plane" refer?
+What "control plane" refers to?
+ +The control plane is the part of the network that decides how to route and forward packets to a different location. +
+ +
+What "data plane" refers to?
+ +The data plane is the part of the network that actually forwards the data/packets. +
+ +
+What "management plane" refers to?
+ +Refers to monitoring and management functions. +
-The exact meaning is usually depends on the context but overall data plane refers to all the functions that forward packets and/or frames from one interface to another while control plane refers to all the functions that make use of routing protocols. +
+To which plane (data, control, ...) is creating routing tables belongs to?
-There is also "Management Plane" which refers to monitoring and management functions. +Control Plane.
@@ -2836,10 +2926,6 @@ Using the `mv` command. * which
-
-Explain redirection
-
-
What is the difference between these two commands? Will it result in the same output? @@ -2912,6 +2998,37 @@ The tasks are stored in a cron file, you can write in it using crontab -e< Alternatively if you are using a distro with systemd it's recommended to use systemd timers.
+#### Linux - I/O Redirection + +
+Explain Linux I/O redirection
+
+ +
+Demonstrate Linux output redirection
+ +ls > ls_output.txt +
+ +
+Demonstrate Linux stderr output redirection
+ +yippiekaiyay 2> ls_output.txt +
+ +
+Demonstrate Linux stderr to stdout redirection
+ +yippiekaiyay 1>&2 +
+ +
+What is the result of running the following command? yippiekaiyay 1>&2 die_hard
+ +An output similar to: `yippikaiyay: command not found...`
+The file `die_hard` will not be created +
+ #### Linux FHS
@@ -3031,120 +3148,6 @@ True A user accidentally executed the following chmod -x $(which chmod). How to fix it?
-#### Linux - Shell Scripting - -
-What this line in scripts mean?: #!/bin/bash
- - -`#!/bin/bash` is She-bang - -/bin/bash is the most common shell used as default shell for user login of the linux system. The shell’s name is an acronym for Bourne-again shell. Bash can execute the vast majority of scripts and thus is widely used because it has more features, is well developed and better syntax. - -
- -
-True or False?: when a certain command/line fails, the script, by default, will exit and will no keep running
- -Depends on the language and settings used. -When a script written in Bash fails to run a certain command it will keep running and will execute all other commands mentioned after the command which failed. -Most of the time we would actually want the opposite to happen. In order to make Bash exist when a specific command fails, use 'set -e' in your script. -
- -
-Explain what would be the result of each command: - - * echo $0 - * echo $? - * echo $$ - * echo $@ - * echo $#
-
- -
-How do you debug shell scripts?
- -Answer depends on the language you are using for writing your scripts. If Bash is used for example then: - - * Adding -x to the script I'm running in Bash - * Old good way of adding echo statements - -If Python, then using pdb is very useful. -
- -
-How do you get input from the user in shell scripts?
- -Using the keyword read so for example read x will wait for user input and will store it in the variable x. -
- -
-Explain continue and break. When do you use them if at all?
-
- - -
-Running the following bash script, we don't get 2 as a result, why? - -``` -x = 2 -echo $x -``` -
- -Should be `x=2` -
- -
-How to store the output of a command in a variable?
- -``` -OUTPUT=$(ls -1) -echo "${OUTPUT}" -``` -[Source](https://stackoverflow.com/questions/4651437/how-do-i-set-a-variable-to-the-output-of-a-command-in-bash) -
- -
-How do you check variable length?
-
- -
-Generate 8 digit random number
- -shuf -i 9999999-99999999 -n 1 -
- -
-Explain the following code: - -:(){ :|:& };: - -
-
- -
-Can you give an example to some Bash best practices?
-
- -
-What is the ternary operator? How do you use it in bash?
- -A short way of using if/else. An example: - -[[ $a = 1 ]] && b="yes, equal" || b="nope" -
- -
-What does the following code do and when would you use it? - -diff <(ls /tmp) <(ls /var/tmp) - -
-It is called 'process substitution'. It provides a way to pass the output of a command to another command when using a pipe | is not possible. It can be used when a command does not support STDIN or you need the output of multiple commands. -https://superuser.com/a/1060002/167769 -
- #### Linux - systemd
@@ -4524,6 +4527,15 @@ MemAvailable - The amount of available memory for new workloads (without pushing * Software/Packages Management
+#### Linux - Sed + +
+Using sed, extract the date from the following line: 201.7.19.90 - - [05/Jun/1985:13:42:99 +0000] "GET /site HTTP/1.1" 200 32421
+ +`echo $line | sed 's/.*\[//g;s/].*//g;s/:.*//g'` +
+ + #### Linux - Misc
@@ -6572,10 +6584,25 @@ The implementation of CNM specification by Docker is called "libnetwork". It's w * Sandboxes: Isolated network stack (interfaces, routing tables, ports, ...)
+
+True or False? If you would like to connect a container to multiple networks, you need multiple endpoints
+ +True. An endpoint can connect only to a single network. +
+ +
+What are some features of libnetwork?
+ +* Native service discovery +* ingress-based load balancer +* network control plane and management plane +
+ #### Containers - Security
What security best practices are there regarding containers?
+ * Install only the necessary packages in the container * Don't run containers as root when possible * Don't mount the Docker daemon unix socket into any of the containers @@ -6628,6 +6655,11 @@ Restart Policies. It allows you to automatically restart containers after certai * on-failure: restart the container when it exists due to an error (= exit code different than zero)
+#### Containers - Docker Misc +
+Explain what is Docker Bench
+
+ ## Kubernetes @@ -6659,26 +6691,6 @@ To understand what Kubernetes is good for, let's look at some examples: * Handle cases where the current load requires to scale up (or down)
-
-What is a Kubernetes Cluster?
- -Red Hat Definition: "A Kubernetes cluster is a set of node machines for running containerized applications. If you’re running Kubernetes, you’re running a cluster. -At a minimum, a cluster contains a worker node and a master node." - -Read more [here](https://www.redhat.com/en/topics/containers/what-is-a-kubernetes-cluster) -
- -
-Do you have experience with deploying a Kubernetes cluster? If so, can you describe the process in high-level?
- -1. Create multiple instances you will use as Kubernetes nodes/workers. Create also an instance to act as the Master. The instances can be provisioned in a cloud or they can be virtual machines on bare metal hosts. -2. Provision a certificate authority that will be used to generate TLS certificates for the different components of a Kubernetes cluster (kubelet, etcd, ...) - 1. Generate a certificate and private key for the different components -3. Generate kubeconfigs so the different clients of Kubernetes can locate the API servers and authenticate. -4. Generate encryption key that will be used for encrypting the cluster data -5. Create an etcd cluster -
-
When or why NOT to use Kubernetes?
@@ -6719,9 +6731,26 @@ metadata, kind and apiVersion Kubectl is the Kubernetes command line tool that allows you to run commands against Kubernetes clusters. For example, you can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.
+
+ +What Kubernetes objects do you usually use when deploying applications in Kubernetes?
+ +* Deployment - creates and the Pods and watches them +* Service: route traffic to Pods internally +* Ingress: route traffic from outside the cluster +
#### Kubernetes - Cluster +
+What is a Kubernetes Cluster?
+ +Red Hat Definition: "A Kubernetes cluster is a set of node machines for running containerized applications. If you’re running Kubernetes, you’re running a cluster. +At a minimum, a cluster contains a worker node and a master node." + +Read more [here](https://www.redhat.com/en/topics/containers/what-is-a-kubernetes-cluster) +
+
What is a Node?
@@ -6787,6 +6816,17 @@ False. A Kubernetes cluster consists of at least 1 master and can have 0 workers Apply requests and limits, especially on third party applications (where the uncertainty is even bigger)
+
+Do you have experience with deploying a Kubernetes cluster? If so, can you describe the process in high-level?
+ +1. Create multiple instances you will use as Kubernetes nodes/workers. Create also an instance to act as the Master. The instances can be provisioned in a cloud or they can be virtual machines on bare metal hosts. +2. Provision a certificate authority that will be used to generate TLS certificates for the different components of a Kubernetes cluster (kubelet, etcd, ...) + 1. Generate a certificate and private key for the different components +3. Generate kubeconfigs so the different clients of Kubernetes can locate the API servers and authenticate. +4. Generate encryption key that will be used for encrypting the cluster data +5. Create an etcd cluster +
+ #### Kubernetes - Pods
@@ -7069,6 +7109,12 @@ The pod related to the deployment will terminate and the replicaset will be remo Using a Service.
+
+An internal load balancer in Kubernetes is called ____ and an external load balancer is called ____
+ +An internal load balancer in Kubernetes is called Service and an external load balancer is Ingress +
+ #### Kubernetes - Services
@@ -7095,6 +7141,19 @@ True More on this topic [here](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types)
+
+How Service and Deployment are connected?
+ +The truth is they aren't connected. Service points to Pod(s) directly, without connecting to the Deployment in any way. +
+ +
+What are important steps in defining/adding a Service?
+ +1. Making sure that targetPort of the Service is matching the containerPort of the POd +2. Making sure that selector matches at least one of the Pod's labels +
+
What is the default service type in Kubernetes and what is it used for?
@@ -8497,7 +8556,7 @@ Helm allows you to upgrade, remove and rollback to previous versions of charts. #### Kubernetes - Security
-What best practices do you follow in regards to the Kubernetes cluster?
+What security best practices do you follow in regards to the Kubernetes cluster?
* Secure inter-service communication (one way is to use Istio to provide mutual TLS) * Isolate different resources into separate namespaces based on some logical groups @@ -8508,7 +8567,29 @@ Helm allows you to upgrade, remove and rollback to previous versions of charts. * Consider using tools (e.g. Falco) for monitoring threats
-#### Submariner +#### Kubernetes - Troubleshooting Scenarios + +
+Running kubectl get pods you see Pods in "Pending" status. What would you do?
+ +One possible path is to run `kubectl describe pod ` to get more details.
+You might see one of the following: + * Cluster is full. In this case, extend the cluster. + * ResourcesQuota limits are met. In this case you might want to modify them + * Check if PersistentVolumeClaim mount is pending + +If none of the above helped, run the command (`get pods`) with `-o wide` to see if the node is assigned to a node. If not, there might be an issue with scheduler. +
+ +
+Users unable to reach an application running on a Pod on Kubernetes. What might be the issue and how to check?
+ +One possible path is to start with checking the Pod status. +1. Is the Pod pending? if yes, check for the reason with `kubectl describe pod ` +TODO: finish this... +
+ +#### Kubernetes - Submariner
Explain what is Submariner and what is it used for
@@ -8527,7 +8608,7 @@ You can learn more [here](https://submariner-io.github.io) * Route Agent
-#### Istio +#### Kubernetes - Istio
What is Istio? What is it used for?
@@ -8966,6 +9047,15 @@ def my_function(): You can then assign a function to a variables like this `x = my_function` or you can return functions as return values like this `return my_function`
+#### Python - Integer + +
+Write a function to determine if a number is a Palindrome
+ +``` +``` +
+ #### Python - OOP
@@ -11477,7 +11567,45 @@ If more pods are running than needed -> it deletes some of them
If not enough pods are running -> it creates more
-## Scripts +## Shell Scripting + +### Shell Scripting Exercises + +|Name|Topic|Objective & Instructions|Solution|Comments| +|--------|--------|------|----|----| +|Hello World|Variables|[Exercise](exercises/shell/hello_world.md)|[Solution](exercises/shell/solutions/hello_world.md) | Basic +|Basic date|Variables|[Exercise](exercises/shell/basic_date.md)|[Solution](exercises/shell/solutions/basic_date.md) | Basic +|Great Day|Variables|[Exercise](exercises/shell/great_day.md)|[Solution](exercises/shell/solutions/great_day.md) | Basic +|Factors|Arithmetic|[Exercise](exercises/shell/factors.md)|[Solution](exercises/shell/solutions/factors.md) | Basic +|Argument Check|Conditionals|[Exercise](exercises/shell/argument_check.md)|[Solution](exercises/shell/solutions/argument_check.md) | Basic +|Files Size|For Loops|[Exercise](exercises/shell/files_size.md)|[Solution](exercises/shell/solutions/files_size.md) | Basic +|Count Chars|Input + While Loops|[Exercise](exercises/shell/count_chars.md)|[Solution](exercises/shell/solutions/count_chars.md) | Basic +|Sum|Functions|[Exercise](exercises/shell/sum.md)|[Solution](exercises/shell/solutions/sum.md) | Basic +|Number of Arguments|Case Statement|[Exercise](exercises/shell/num_of_args.md)|[Solution](exercises/shell/solutions/num_of_args.md) | Basic +|Empty Files|Misc|[Exercise](exercises/shell/empty_files.md)|[Solution](exercises/shell/solutions/empty_files.md) | Basic +|Directories Comparison|Misc|[Exercise](exercises/shell/directories_comparison.md)| :( | Basic +|It's alive!|Misc|[Exercise](exercises/shell/host_status.md)|[Solution](exercises/shell/solutions/host_status.md) | Intermediate + +## Shell Scripting - Self Assessment + +
+What does this line in shell scripts means?: #!/bin/bash
+ + +`#!/bin/bash` is She-bang + +/bin/bash is the most common shell used as default shell for user login of the linux system. The shell’s name is an acronym for Bourne-again shell. Bash can execute the vast majority of scripts and thus is widely used because it has more features, is well developed and better syntax. + +
+ +
+True or False? When a certain command/line fails in a shell script, the shell script, by default, will exit and stop running
+ +Depends on the language and settings used. +If the script is a bash script then this statement is true. When a script written in Bash fails to run a certain command it will keep running and will execute all other commands mentioned after the command which failed. + +Most of the time we might actually want the opposite to happen. In order to make Bash exist when a specific command fails, use 'set -e' in your script. +
What do you tend to include in every script you write?
@@ -11491,7 +11619,7 @@ You can have an entirely different answer. It's based only on your experience an
-Today we have tools and technologies like Ansible. Why would someone still use scripting?
+Today we have tools and technologies like Ansible, Puppet, Chef, ... Why would someone still use shell scripting?
* Speed * Flexibility @@ -11499,62 +11627,208 @@ You can have an entirely different answer. It's based only on your experience an * We are delivering the scripts to customers who don't have access to the public network and don't necessarily have Ansible installed on their systems.
-#### Scripts Fundamentals +#### Shell Scripting - Variables
-Explain conditionals and how do you use them
+How to define a variable with the value "Hello World"?
+ +`HW="Hello World`
-What is a loop? What types of loops are you familiar with?
+How to define a variable with the value of the current date?
+ +`DATE=$(date)`
-Demonstrate how to use loops
+How to print the first argument passed to a script?
+ +`echo $1` +
+ +
+Write a script to print "yay" unless an argument was passed and then print that argument
+ +``` +echo "${1:-yay}" +```
-#### Writing Scripts +
+What would be the output of the following script? -Note: write them in any language you prefer +``` +#!/usr/bin/env bash +NINJA_TURTLE=Donatello +function the_best_ninja_turtle { + local NINJA_TURTLE=Michelangelo + echo $NINJA_TURTLE +} +NINJA_TURTLE=Raphael +the_best_ninja_turtle +``` +
+Michelangelo +
-Write a script which will list the differences between two directories
+Explain what would be the result of each command: + + * echo $0 + * echo $? + * echo $$ + * echo $#
-Write a script to determine whether a host is up or down
+What is $@?
+
+ +
+What is difference between $@ and $*?
+ +`$@` is an array of all the arguments passed to the script +`$*` is a single string of all the arguments passed to the script +
+ +
+How do you get input from the user in shell scripts?
+ +Using the keyword read so for example read x will wait for user input and will store it in the variable x. +
+ +
+How to compare variables length?
-**EXAMPLE ONE** ``` -#!/bin/bash -SERVERIP= -NOTIFYEMAIL=test@example.com +if [ ${#1} -ne ${#2} ]; then + ... +``` +
-ping -c 3 $SERVERIP > /dev/null 2>&1 -if [ $? -ne 0 ] -then - # Use mailer here: - mailx -s "Server $SERVERIP is down" -t "$NOTIFYEMAIL" < /dev/null -fi +#### Shell Scripting - Conditionals + +
+Explain conditionals and demonstrate how to use them
+
+ +
+In shell scripting, how to negate a conditional?
+
+ +
+In shell scripting, how to check if a given argument is a number?
+ +``` +regex='^[0-9]+$' +if [[ ${var//*.} =~ $regex ]]; then +... ```
+#### Shell Scripting - Arithmetic Operations + +
+How to perform arithmetic operations on numbers?
+ +One way: `$(( 1 + 2 ))` +Another way: `expr 1 + 2` +
+ +
+How to perform arithmetic operations on numbers?
+
+
-Write a script to remove all the empty files in a given directory (also nested directories)
+How to check if a given number has 4 as a factor?
+ +`if [ $(($1 % 4)) -eq 0 ]; then` +
+ +#### Shell Scripting - Loops + +
+What is a loop? What types of loops are you familiar with?
+
+ +
+Demonstrate how to use loops
+
+ +#### Shell Scripting - Troubleshooting + +
+How do you debug shell scripts?
+ +Answer depends on the language you are using for writing your scripts. If Bash is used for example then: + + * Adding -x to the script I'm running in Bash + * Old good way of adding echo statements + +If Python, then using pdb is very useful. +
+ +
+Running the following bash script, we don't get 2 as a result, why? -**EXAMPLE ONE** ``` -#! /bin/bash -for x in * -do - if [ -s $x ] - then - continue - else - rm -rf $x - fi -done +x = 2 +echo $x ``` +
+ +Should be `x=2` +
+ +#### Shell Scripting - Substring + +
+How to extract everything after the last dot in a string?
+ +`${var//*.}` +
+ +
+How to extract everything before the last dot in a string?
+ +${var%.*} +
+ +#### Shell Scripting - Misc + +
+Generate 8 digit random number
+ +shuf -i 9999999-99999999 -n 1 +
+ +
+Can you give an example to some Bash best practices?
+
+ +
+What is the ternary operator? How do you use it in bash?
+ +A short way of using if/else. An example: + +[[ $a = 1 ]] && b="yes, equal" || b="nope" +
+ +
+What does the following code do and when would you use it? + +diff <(ls /tmp) <(ls /var/tmp) + +
+It is called 'process substitution'. It provides a way to pass the output of a command to another command when using a pipe | is not possible. It can be used when a command does not support STDIN or you need the output of multiple commands. +https://superuser.com/a/1060002/167769 +
+ +
+What are you using for testing shell scripts?
+ +bats
## SQL @@ -12566,15 +12840,30 @@ A list of services and their endpoints
-What security techniques are you familiar with? (or what security techniques have you used in the past?)
+What the "Zero Trust" concept means? How Organizations deal with it?
+ +[Codefresh definition](https://codefresh.io/security-testing/codefresh-runner-overview): "Zero trust is a security concept that is centered around the idea that organizations should never trust anyone or anything that does not originate from their domains. Organizations seeking zero trust automatically assume that any external services it commissions have security breaches and may leak sensitive information"
-What the "Zero Trust" concept means? How Organizations deal with it?
+What it means to be "FIPS compliant"?
+
+ +
+What is a Certificate Authority?
+
+ +
+Explain RBAC (Role-based Access Control)
+ +Access control based on user roles (i.e., a collection of access authorizations a user receives based on an explicit or implicit assumption of a given role). Role permissions may be inherited through a role hierarchy and typically reflect the permissions needed to perform defined functions within an organization. A given role may apply to a single individual or to several individuals. + +- RBAC mapped to job function, assumes that a person will take on different roles, overtime, within an organization and different responsibilities in relation to IT systems. -[Codefresh definition](https://codefresh.io/security-testing/codefresh-runner-overview): "Zero trust is a security concept that is centered around the idea that organizations should never trust anyone or anything that does not originate from their domains. Organizations seeking zero trust automatically assume that any external services it commissions have security breaches and may leak sensitive information"
+#### Security - Authentication and Authorization +
Explain Authentication and Authorization
@@ -12583,15 +12872,21 @@ Authorization is the process of identifying what level of access the service or
-What it means to be "FIPS compliant"?
+What authentication methods are there?
-What is a Certificate Authority?
+Give an example of basic authentication process
+ +A user uses the browser to authenticate to some server. It does so by using the authorization field which is constructed from the username and the password combined with a single colon. The result string is encoded using a certain character set which is compatible with US-ASCII. The authorization method + a space is prepended to the encoded string.
-How do you manage sensitive information (like passwords) in different tools and platforms?
+Explain Token-based authentication
+
+ +
+Explain Risk-based authentication
@@ -12609,27 +12904,57 @@ Multi-Factor Authentication (Also known as 2FA). Allows the user to present two
+#### Security - Passwords +
-Explain RBAC (Role-based Access Control)
+How do you manage sensitive information (like passwords) in different tools and platforms?
+
-Access control based on user roles (i.e., a collection of access authorizations a user receives based on an explicit or implicit assumption of a given role). Role permissions may be inherited through a role hierarchy and typically reflect the permissions needed to perform defined functions within an organization. A given role may apply to a single individual or to several individuals. +
+What password attacks are you familiar with?
-- RBAC mapped to job function, assumes that a person will take on different roles, overtime, within an organization and different responsibilities in relation to IT systems. + * Dictionary + * Brute force + * Password Spraying + * Social Engineering + * Whaling + * Vishing + * Phising + * Whaling +
+ +
+How to mitigate password attacks?
+ * Strong password policy + * Do not reuse passwords + * ReCaptcha + * Training personnel against Social Engineering + * Risk Based Authentication + * Rate limiting + * MFA
-#### Security - Web +#### Security - Cookies
-What is Nonce?
+What are cookies? Explain cookie-based authentication
-What is SSRF?
+True or False? Cookie-based authentication is stateful
-SSRF (Server-side request forgery) it's a vulnerability where you can make a server make arbitrary requests to anywhere you want. +True. Cookie-based authentication session must be kept on both server and client-side. +
-Read more about it at [portswigger.net](https://portswigger.net/web-security/ssrf) +
+Explain the flow of using cookies
+ +1. User enters credentials +2. The server verifies the credentials -> a sessions is created and stored in the database +3. A cookie with the session ID is set in the browser of that user +4. On every request, the session ID is verified against the database +5. The session is destroyed (both on client-side and server-side) when the user logs out
#### Security - SSH @@ -12776,10 +13101,6 @@ You can test by using a stored procedure, so the application must be sanitize th Describe how do you secure public repositories
-
-How do cookies work?
-
-
What is DNS Spoofing? How to prevent it?
@@ -12868,14 +13189,16 @@ HTTP Header Injection vulnerabilities occur when user input is insecurely includ A buffer overflow (or buffer overrun) occurs when the volume of data exceeds the storage capacity of the memory buffer. As a result, the program attempting to write the data to the buffer overwrites adjacent memory locations.
-#### Security - Containers -
-What security measures are you taking when dealing with containers?
+What is Nonce?
-Explain what is Docker Bench
+What is SSRF?
+ +SSRF (Server-side request forgery) it's a vulnerability where you can make a server make arbitrary requests to anywhere you want. + +Read more about it at [portswigger.net](https://portswigger.net/web-security/ssrf)
@@ -13656,6 +13979,14 @@ document_number: 2 ```
+#### Firmware + +
+Explain what is a firmware
+ +[Wikipedia](https://en.wikipedia.org/wiki/Firmware): "In computing, firmware is a specific class of computer software that provides the low-level control for a device's specific hardware. Firmware, such as the BIOS of a personal computer, may contain basic functions of a device, and may provide hardware abstraction services to higher-level software such as operating systems." +
+ #### Customers and Service Providers
@@ -14825,6 +15156,7 @@ If you are looking for a way to prepare for a certain exam this is the section f #### AWS * [Cloud Practitioner](certificates/cloud-practitioner.md) (Latest update: 2020) +* [Solutions Architect Associate](certificates/aws-solutions-architect-associate.md) (Latest update: 2021) #### Azure diff --git a/certificates/aws-cloud-practitioner.md b/certificates/aws-cloud-practitioner.md index 9c2897eb5..75c273098 100644 --- a/certificates/aws-cloud-practitioner.md +++ b/certificates/aws-cloud-practitioner.md @@ -399,11 +399,21 @@ True
-Given an example of IAM best practices?
+True or False? When creating an AWS account, root account is created by default. This is the recommended account to use and share in your organization
-* Set up MFA -* Delete root account access keys -* Create IAM users instead of using root for daily management +False. Instead of using the root account, you should be creating users and use them. +
+ +
+True or False? Groups in AWS IAM, can contain only users and not other groups
+ +True +
+ +
+True or False? Users in AWS IAM, can belong only to a single group
+ +False. Users can belong to multiple groups.
diff --git a/certificates/aws-solutions-architect-associate.md b/certificates/aws-solutions-architect-associate.md new file mode 100644 index 000000000..7a9413d7b --- /dev/null +++ b/certificates/aws-solutions-architect-associate.md @@ -0,0 +1,1202 @@ +## AWS - Solutions Architect Associate + +Last update: 2021 + +#### AWS Global Infrastructure + +
+Explain the following + + * Availability zone + * Region + * Edge location
+ +AWS regions are data centers hosted across different geographical locations worldwide, each region is completely independent of one another.
+ +Within each region, there are multiple isolated locations known as Availability Zones. Multiple availability zones ensure high availability in case one of them goes down.
+ +Edge locations are basically content delivery network which caches data and insures lower latency and faster delivery to the users in any location. They are located in major cities in the world. +
+ +#### AWS - IAM + +
+What is IAM? What are some of its features?
+ +Full explanation is [here](https://aws.amazon.com/iam) +In short: it's used for managing users, groups, access policies & roles +
+ +
+True or False? IAM configuration is defined globally and not per region
+ +True +
+ +
+True or False? When creating an AWS account, root account is created by default. This is the recommended account to use and share in your organization
+ +False. Instead of using the root account, you should be creating users and use them. +
+ +
+True or False? Groups in AWS IAM, can contain only users and not other groups
+ +True +
+ +
+True or False? Users in AWS IAM, can belong only to a single group
+ +False. Users can belong to multiple groups. +
+ +
+What are Roles?
+ +A way for allowing a service of AWS to use another service of AWS. You assign roles to AWS resources. +For example, you can make use of a role which allows EC2 service to acesses s3 buckets (read and write). +
+ +
+What are Policies?
+ +Policies documents used to give permissions as to what a user, group or role are able to do. Their format is JSON. +
+ +
+A user is unable to access an s3 bucket. What might be the problem?
+ +There can be several reasons for that. One of them is lack of policy. To solve that, the admin has to attach the user with a policy what allows him to access the s3 bucket. +
+ +
+What should you use to: + + * Grant access between two services/resources? + * Grant user access to resources/services?
+ + * Role + * Policy +
+ +
+What permissions does a new user have?
+ +Only a login access. +
+ + +#### AWS Networking + +
+What is VPC?
+ +"A logically isolated section of the AWS cloud where you can launch AWS resources in a virtual network that you define" +Read more about it [here](https://aws.amazon.com/vpc). +
+ +
+True or False? VPC spans multiple regions
+ +False +
+ +
+True or False? Subnets belong to the same VPC, can be in different availability zones
+ +True. Just to clarify, a subnet must reside entirely in one AZ. +
+ +
+What is an Internet Gateway?
+ +"component that allows communication between instances in your VPC and the internet" (AWS docs). +Read more about it [here](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html) +
+ +
+True or False? NACL allow or deny traffic on the subnet level
+ +True +
+ +
+True or False? Multiple Internet Gateways can be attached to one VPC
+ +False. Only one internet gateway can be attached to a single VPC. +
+ +
+True or False? Route Tables used to allow or deny traffic from the internet to AWS instances
+ +False. +
+ +
+Explain Security Groups and Network ACLs
+ +* NACL - security layer on the subnet level. +* Security Group - security layer on the instance level. + +Read more about it [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security-groups.html) and [here](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html) +
+ +
+What is AWS Direct Connect?
+ +Allows you to connect your corporate network to AWS network. +
+ +#### AWS Compute + +
+What is EC2?
+ +"a web service that provides secure, resizable compute capacity in the cloud". +Read more [here](https://aws.amazon.com/ec2) +
+ +
+True or False? EC2 is a regional service
+ +True. As opposed to IAM for example, which is a global service, EC2 is a regional service. +
+ +
+What is AMI?
+ +Amazon Machine Images is "An Amazon Machine Image (AMI) provides the information required to launch an instance". +Read more [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html) +
+ +
+What are the different source for AMIs?
+ +* Personal AMIs - AMIs you create +* AWS Marketplace for AMIs - Paid AMIs usually with bundled with licensed software +* Community AMIs - Free +
+ +
+What is instance type?
+ +"the instance type that you specify determines the hardware of the host computer used for your instance" +Read more about instance types [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html) +
+ +
+True or False? The following are instance types available for a user in AWS: + + * Compute optimizied + * Network optimizied + * Web optimized
+ +False. From the above list only compute optimized is available. +
+ +
+What is EBS?
+ +"provides block level storage volumes for use with EC2 instances. EBS volumes behave like raw, unformatted block devices." +More on EBS [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html) +
+ +
+What EC2 pricing models are there?
+ +On Demand - pay a fixed rate by the hour/second with no commitment. You can provision and terminate it at any given time. +Reserved - you get capacity reservation, basically purchase an instance for a fixed time of period. The longer, the cheaper. +Spot - Enables you to bid whatever price you want for instances or pay the spot price. +Dedicated Hosts - physical EC2 server dedicated for your use. +
+ +
+What are Security Groups?
+ +"A security group acts as a virtual firewall that controls the traffic for one or more instances" +More on this subject [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security-groups.html) +
+ +
+What can you attach to an EC2 instance in order to store data?
+ +EBS +
+ +
+What EC2 RI types are there?
+ +Standard RI - most significant discount + suited for steady-state usage +Convertible RI - discount + change attribute of RI + suited for steady-state usage +Scheduled RI - launch within time windows you reserve + +Learn more about EC2 RI [here](https://aws.amazon.com/ec2/pricing/reserved-instances) +
+ +#### AWS Containers + +
+What is Amazon ECS?
+ +Amazon definition: "Amazon Elastic Container Service (Amazon ECS) is a fully managed container orchestration service. Customers such as Duolingo, Samsung, GE, and Cook Pad use ECS to run their most sensitive and mission critical applications because of its security, reliability, and scalability." + +Learn more [here](https://aws.amazon.com/ecs) +
+ +
+What is Amazon ECR?
+ +Amazon definition: "Amazon Elastic Container Registry (ECR) is a fully-managed Docker container registry that makes it easy for developers to store, manage, and deploy Docker container images." + +Learn more [here](https://aws.amazon.com/ecr) +
+ +
+What is AWS Fargate?
+ +Amazon definition: "AWS Fargate is a serverless compute engine for containers that works with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS)." + +Learn more [here](https://aws.amazon.com/fargate) +
+ +#### AWS Storage + +
+Explain what is AWS S3?
+ +S3 stands for 3 S, Simple Storage Service. +S3 is a object storage service which is fast, scalable and durable. S3 enables customers to upload, download or store any file or object that is up to 5 TB in size. + +More on S3 [here](https://aws.amazon.com/s3) +
+ +
+What is a bucket?
+ +An S3 bucket is a resource which is similar to folders in a file system and allows storing objects, which consist of data. +
+ +
+True or False? A bucket name must be globally unique
+ +True +
+ +
+Explain folders and objects in regards to buckets
+ +* Folder - any sub folder in an s3 bucket +* Object - The files which are stored in a bucket +
+ +
+Explain the following: + + * Object Lifecycles + * Object Sharing + * Object Versioning
+ + * Object Lifecycles - Transfer objects between storage classes based on defined rules of time periods + * Object Sharing - Share objects via a URL link + * Object Versioning - Manage multiple versions of an object +
+ +
+Explain Object Durability and Object Availability
+ +Object Durability: The percent over a one-year time period that a file will not be lost +Object Availability: The percent over a one-year time period that a file will be accessible +
+ +
+What is a storage class? What storage classes are there?
+ +Each object has a storage class assigned to, affecting its availability and durability. This also has effect on costs. +Storage classes offered today: + * Standard: + * Used for general, all-purpose storage (mostly storage that needs to be accessed frequently) + * The most expensive storage class + * 11x9% durability + * 2x9% availability + * Default storage class + + * Standard-IA (Infrequent Access) + * Long lived, infrequently accessed data but must be available the moment it's being accessed + * 11x9% durability + * 99.90% availability + + * One Zone-IA (Infrequent Access): + * Long-lived, infrequently accessed, non-critical data + * Less expensive than Standard and Standard-IA storage classes + * 2x9% durability + * 99.50% availability + + * Intelligent-Tiering: + * Long-lived data with changing or unknown access patterns. Basically, In this class the data automatically moves to the class most suitable for you based on usage patterns + * Price depends on the used class + * 11x9% durability + * 99.90% availability + + * Glacier: Archive data with retrieval time ranging from minutes to hours + * Glacier Deep Archive: Archive data that rarely, if ever, needs to be accessed with retrieval times in hours + * Both Glacier and Glacier Deep Archive are: + * The most cheap storage classes + * have 9x9% durability + +More on storage classes [here](https://aws.amazon.com/s3/storage-classes) + +
+ +
+A customer would like to move data which is rarely accessed from standard storage class to the most cheapest class there is. Which storage class should be used? + + * One Zone-IA + * Glacier Deep Archive + * Intelligent-Tiering
+ +Glacier Deep Archive +
+ +
+What Glacier retrieval options are available for the user?
+ +Expedited, Standard and Bulk +
+ +
+True or False? Each AWS account can store up to 500 PetaByte of data. Any additional storage will cost double
+ +False. Unlimited capacity. +
+ +
+Explain what is Storage Gateway
+ +"AWS Storage Gateway is a hybrid cloud storage service that gives you on-premises access to virtually unlimited cloud storage". +More on Storage Gateway [here](https://aws.amazon.com/storagegateway) +
+ +
+Explain the following Storage Gateway deployments types + + * File Gateway + * Volume Gateway + * Tape Gateway
+ +Explained in detail [here](https://aws.amazon.com/storagegateway/faqs) +
+ +
+What is the difference between stored volumes and cached volumes?
+ +Stored Volumes - Data is located at customer's data center and periodically backed up to AWS +Cached Volumes - Data is stored in AWS cloud and cached at customer's data center for quick access +
+ +
+What is "Amazon S3 Transfer Acceleration"?
+ +AWS definition: "Amazon S3 Transfer Acceleration enables fast, easy, and secure transfers of files over long distances between your client and an S3 bucket" + +Learn more [here](https://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html) +
+ +
+What is Amazon EFS?
+ +Amazon definition: "Amazon Elastic File System (Amazon EFS) provides a simple, scalable, fully managed elastic NFS file system for use with AWS Cloud services and on-premises resources." + +Learn more [here](https://aws.amazon.com/efs) +
+ +
+What is AWS Snowmobile?
+ +"AWS Snowmobile is an Exabyte-scale data transfer service used to move extremely large amounts of data to AWS." + +Learn more [here](https://aws.amazon.com/snowmobile) +
+ +##### AWS ELB + +
+What is ELB (Elastic Load Balancing)?
+ +AWS definition: "Elastic Load Balancing automatically distributes incoming application traffic across multiple targets, such as Amazon EC2 instances, containers, IP addresses, and Lambda functions." + +More on ELB [here](https://aws.amazon.com/elasticloadbalancing) +
+ +
+What is auto scaling?
+ +AWS definition: "AWS Auto Scaling monitors your applications and automatically adjusts capacity to maintain steady, predictable performance at the lowest possible cost" + +Read more about auto scaling [here](https://aws.amazon.com/autoscaling) +
+ +
+True or False? Auto Scaling is about adding resources (such as instances) and not about removing resource
+ +False. Auto scaling adjusts capacity and this can mean removing some resources based on usage and performances. +
+ +
+What types of load balancers are supported in EC2 and what are they used for?
+ + * Application LB - layer 7 traffic + * Network LB - ultra-high performances or static IP address + * Classic LB - low costs, good for test or dev environments +
+ +#### AWS DNS + +
+What is Route 53?
+ +"Amazon Route 53 is a highly available and scalable cloud Domain Name System (DNS) web service" +Some of Route 53 features: + * Register domain + * DNS service - domain name translations + * Health checks - verify your app is available + +More on Route 53 [here](https://aws.amazon.com/route53) +
+ +#### AWS CloudFront + +
+Explain what is CloudFront
+ +AWS definition: "Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with low latency, high transfer speeds, all within a developer-friendly environment." + +More on CloudFront [here](https://aws.amazon.com/cloudfront) +
+ +
+Explain the following + + * Origin + * Edge location + * Distribution
+
+ +#### AWS Monitoring & Logging + +
+What is AWS CloudWatch?
+ +AWS definition: "Amazon CloudWatch is a monitoring and observability service..." + +More on CloudWatch [here](https://aws.amazon.com/cloudwatch) +
+ +
+What is AWS CloudTrail?
+ +AWS definition: "AWS CloudTrail is a service that enables governance, compliance, operational auditing, and risk auditing of your AWS account." + +Read more on CloudTrail [here](https://aws.amazon.com/cloudtrail) +
+ +
+What is Simply Notification Service?
+ +AWS definition: "a highly available, durable, secure, fully managed pub/sub messaging service that enables you to decouple microservices, distributed systems, and serverless applications." + +Read more about it [here](https://aws.amazon.com/sns) +
+ +
+Explain the following in regards to SNS: + + * Topics + * Subscribers + * Publishers
+ + * Topics - used for grouping multiple endpoints + * Subscribers - the endpoints where topics send messages to + * Publishers - the provider of the message (event, person, ...) +
+ +#### AWS Security + +
+What is the shared responsibility model? What AWS is responsible for and what the user is responsible for based on the shared responsibility model?
+ +The shared responsibility model defines what the customer is responsible for and what AWS is responsible for. + +More on the shared responsibility model [here](https://aws.amazon.com/compliance/shared-responsibility-model) +
+ +
+True or False? Based on the shared responsibility model, Amazon is responsible for physical CPUs and security groups on instances
+ +False. It is responsible for Hardware in its sites but not for security groups which created and managed by the users. +
+ +
+Explain "Shared Controls" in regards to the shared responsibility model
+ +AWS definition: "apply to both the infrastructure layer and customer layers, but in completely separate contexts or perspectives. In a shared control, AWS provides the requirements for the infrastructure and the customer must provide their own control implementation within their use of AWS services" + +Learn more about it [here](https://aws.amazon.com/compliance/shared-responsibility-model) +
+ +
+What is the AWS compliance program?
+
+ +
+What is AWS Artifact?
+ +AWS definition: "AWS Artifact is your go-to, central resource for compliance-related information that matters to you. It provides on-demand access to AWS’ security and compliance reports and select online agreements." + +Read more about it [here](https://aws.amazon.com/artifact) +
+ +
+What is AWS Inspector?
+ +AWS definition: "Amazon Inspector is an automated security assessment service that helps improve the security and compliance of applications deployed on AWS. Amazon Inspector automatically assesses applications for exposure, vulnerabilities, and deviations from best practices."" + +Learn more [here](https://aws.amazon.com/inspector) +
+ +
+What is AWS Guarduty?
+
+ +
+What is AWS Shield?
+ +AWS definition: "AWS Shield is a managed Distributed Denial of Service (DDoS) protection service that safeguards applications running on AWS." +
+ +
+What is AWS WAF? Give an example of how it can used and describe what resources or services you can use it with
+
+ +
+What AWS VPN is used for?
+
+ +
+What is the difference between Site-to-Site VPN and Client VPN?
+
+ +
+What is AWS CloudHSM?
+ +Amazon definition: "AWS CloudHSM is a cloud-based hardware security module (HSM) that enables you to easily generate and use your own encryption keys on the AWS Cloud." + +Learn more [here](https://aws.amazon.com/cloudhsm) +
+ +
+True or False? AWS Inspector can perform both network and host assessments
+ +True +
+ +
+What is AWS Acceptable Use Policy?
+ +It describes prohibited uses of the web services offered by AWS. +More on AWS Acceptable Use Policy [here](https://aws.amazon.com/aup) +
+ +
+What is AWS Key Management Service (KMS)?
+ +AWS definition: "KMS makes it easy for you to create and manage cryptographic keys and control their use across a wide range of AWS services and in your applications." +More on KMS [here](https://aws.amazon.com/kms) +
+ +
+True or False? A user is not allowed to perform penetration testing on any of the AWS services
+ +False. On some services, like EC2, CloudFront and RDS, penetration testing is allowed. +
+ +
+True or False? DDoS attack is an example of allowed penetration testing activity
+ +False. +
+ +
+True or False? AWS Access Key is a type of MFA device used for AWS resources protection
+ +False. Security key is an example of an MFA device. +
+ +
+What is Amazon Cognito?
+ +Amazon definition: "Amazon Cognito handles user authentication and authorization for your web and mobile apps." + +Learn more [here](https://docs.aws.amazon.com/cognito/index.html) +
+ +
+What is AWS ACM?
+ +Amazon definition: "AWS Certificate Manager is a service that lets you easily provision, manage, and deploy public and private Secure Sockets Layer/Transport Layer Security (SSL/TLS) certificates for use with AWS services and your internal connected resources." + +Learn more [here](https://aws.amazon.com/certificate-manager) +
+ +#### AWS Databases + +
+What is AWS RDS?
+
+ +
+What is AWS DynamoDB?
+
+ +
+Explain "Point-in-Time Recovery" feature in DynamoDB
+ +Amazon definition: "You can create on-demand backups of your Amazon DynamoDB tables, or you can enable continuous backups using point-in-time recovery. For more information about on-demand backups, see On-Demand Backup and Restore for DynamoDB." + +Learn more [here](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/PointInTimeRecovery.html) +
+ +
+Explain "Global Tables" in DynamoDB
+ +Amazon definition: "A global table is a collection of one or more replica tables, all owned by a single AWS account." + +Learn more [here](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/V2globaltables_HowItWorks.html) +
+ +
+What is DynamoDB Accelerator?
+ +Amazon definition: "Amazon DynamoDB Accelerator (DAX) is a fully managed, highly available, in-memory cache for DynamoDB that delivers up to a 10x performance improvement – from milliseconds to microseconds..." + +Learn more [here](https://aws.amazon.com/dynamodb/dax) +
+ +
+What is AWS Redshift and how is it different than RDS?
+ +cloud data warehouse +
+ +
+What is AWS ElastiCache? For what cases is it used?
+ +Amazon Elasticache is a fully managed Redis or Memcached in-memory data store. +It's great for use cases like two-tier web applications where the most frequently accesses data is stored in ElastiCache so response time is optimal. +
+ +
+What is Amazon Aurora
+ +A MySQL & Postgresql based relational database. Also, the default database proposed for the user when using RDS for creating a database. +Great for use cases like two-tier web applications that has a MySQL or Postgresql database layer and you need automated backups for your application. +
+ +
+What is Amazon DocumentDB?
+ +Amazon definition: "Amazon DocumentDB (with MongoDB compatibility) is a fast, scalable, highly available, and fully managed document database service that supports MongoDB workloads. As a document database, Amazon DocumentDB makes it easy to store, query, and index JSON data." + +Learn more [here](https://aws.amazon.com/documentdb) +
+ +
+What "AWS Database Migration Service" is used for?
+
+ +
+What type of storage is used by Amazon RDS?
+ +EBS +
+ +
+Explain Amazon RDS Read Replicas
+ +AWS definition: "Amazon RDS Read Replicas provide enhanced performance and durability for RDS database (DB) instances. They make it easy to elastically scale out beyond the capacity constraints of a single DB instance for read-heavy database workloads." +Read more about [here](https://aws.amazon.com/rds/features/read-replicas) +
+ +#### AWS Serverless Compute + +
+Explain what is AWS Lambda
+ +AWS definition: "AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume." + +Read more on it [here](https://aws.amazon.com/lambda) +
+ +
+True or False? In AWS Lambda, you are charged as long as a function exists, regardless of whether it's running or not
+ +False. Charges are being made when the code is executed. +
+ +
+Which of the following set of languages Lambda supports? + + * R, Swift, Rust, Kotlin + * Python, Ruby, Go + * Python, Ruby, PHP
+ + * Python, Ruby, Go +
+ +#### Identify the service or tool + +
+What would you use for automating code/software deployments?
+ +AWS CodeDeploy +
+ +
+What would you use for easily creating similar AWS environments/resources for different customers?
+ +CloudFormation +
+ +
+Which service would you use for building a website or web application?
+ +Lightsail +
+ +
+Which tool would you use for choosing between Reserved instances or On-Demand instances?
+ +Cost Explorer +
+ +
+What would you use to check how many unassociated Elastic IP address you have?
+ +Trusted Advisor +
+ +
+What service allows you to transfer large amounts (Petabytes) of data in and out of the AWS cloud?
+ +AWS Snowball +
+ +
+What provides a virtual network dedicated to your AWS account?
+ +VPC +
+ +
+What you would use for having automated backups for an application that has MySQL database layer?
+ +Amazon Aurora +
+ +
+What would you use to migrate on-premise database to AWS?
+ +AWS Database Migration Service (DMS) +
+ +
+What would you use to check why certain EC2 instances were terminated?
+ +AWS CloudTrail +
+ +
+What would you use for SQL database?
+ +AWS RDS +
+ +
+What would you use for NoSQL database?
+ +AWS DynamoDB +
+ +
+What would you use for running SQL queries interactively on S3?
+ +AWS Athena +
+ +
+What would you use for adding image and video analysis to your application?
+ +AWS Rekognition +
+ +
+Which service would you use for debugging and improving performances issues with your applications?
+ +AWS X-Ray +
+ +
+Which service is used for sending notifications?
+ +SNS +
+ +
+Which service would you use for monitoring malicious activity and unauthorized behavior in regards to AWS accounts and workloads?
+ +Amazon GuardDuty +
+ +
+Which service would you use for centrally manage billing, control access, compliance, and security across multiple AWS accounts?
+ +AWS Organizations +
+ +
+Which service would you use for web application protection?
+ +AWS WAF +
+ +
+You would like to monitor some of your resources in the different services. Which service would you use for that?
+ +CloudWatch +
+ +
+Which service would you use for performing security assessment?
+ +AWS Inspector +
+ +
+Which service would you use for creating DNS record?
+ +Route 53 +
+ +
+What would you use if you need a fully managed document database?
+ +Amazon DocumentDB +
+ +
+Which service would you use to add access control (or sign-up, sign-in forms) to your web/mobile apps?
+ +AWS Cognito +
+ +
+Which service would you use if you need messaging queue?
+ +Simple Queue Service (SQS) +
+ +
+Which service would you use if you need managed DDOS protection?
+ +AWS Shield +
+ +
+Which service would you use if you need store frequently used data for low latency access?
+ +ElastiCache +
+ +
+What would you use to transfer files over long distances between a client and an S3 bucket?
+ +Amazon S3 Transfer Acceleration +
+ +#### AWS Billing & Support + +
+What is AWS Organizations?
+ +AWS definition: "AWS Organizations helps you centrally govern your environment as you grow and scale your workloads on AWS." +More on Organizations [here](https://aws.amazon.com/organizations) +
+ +
+Explain AWS pricing model
+ +It mainly works on "pay-as-you-go" meaning you pay only for what are using and when you are using it. +In s3 you pay for 1. How much data you are storing 2. Making requests (PUT, POST, ...) +In EC2 it's based on the purchasing option (on-demand, spot, ...), instance type, AMI type and the region used. + +More on AWS pricing model [here](https://aws.amazon.com/pricing) +
+ +
+How one should estimate AWS costs when for example comparing to on-premise solutions?
+ +* TCO calculator +* AWS simple calculator +* Cost Explorer +
+ +
+What basic support in AWS includes?
+ +* 24x7 customer service +* Trusted Advisor +* AWS personal Health Dashoard +
+ +
+How are EC2 instances billed?
+
+ +
+What AWS Pricing Calculator is used for?
+
+ +
+What is Amazon Connect?
+ +Amazon definition: "Amazon Connect is an easy to use omnichannel cloud contact center that helps companies provide superior customer service at a lower cost." + +Learn more [here](https://aws.amazon.com/connect) +
+ +
+What are "APN Consulting Partners"?
+ +Amazon definition: "APN Consulting Partners are professional services firms that help customers of all types and sizes design, architect, build, migrate, and manage their workloads and applications on AWS, accelerating their journey to the cloud." + +Learn more [here](https://aws.amazon.com/partners/consulting) +
+ +
+Which of the following are AWS accounts types (and are sorted by order)? + + * Basic, Developer, Business, Enterprise + * Newbie, Intermediate, Pro, Enterprise + * Developer, Basic, Business, Enterprise + * Beginner, Pro, Intermediate Enterprise
+ + * Basic, Developer, Business, Enterprise +
+ +
+True or False? Region is a factor when it comes to EC2 costs/pricing
+ +True. You pay differently based on the chosen region. +
+ +
+What is "AWS Infrastructure Event Management"?
+ +AWS Definition: "AWS Infrastructure Event Management is a structured program available to Enterprise Support customers (and Business Support customers for an additional fee) that helps you plan for large-scale events such as product or application launches, infrastructure migrations, and marketing events." +
+ +#### AWS Automation + +
+What is AWS CodeDeploy?
+ +Amazon definition: "AWS CodeDeploy is a fully managed deployment service that automates software deployments to a variety of compute services such as Amazon EC2, AWS Fargate, AWS Lambda, and your on-premises servers." + +Learn more [here](https://aws.amazon.com/codedeploy) +
+ +
+Explain what is CloudFormation
+
+ +#### AWS Misc + +
+What is AWS Lightsail?
+ +AWS definition: "Lightsail is an easy-to-use cloud platform that offers you everything needed to build an application or website, plus a cost-effective, monthly plan." +
+ +
+What is AWS Rekognition?
+ +AWS definition: "Amazon Rekognition makes it easy to add image and video analysis to your applications using proven, highly scalable, deep learning technology that requires no machine learning expertise to use." + +Learn more [here](https://aws.amazon.com/rekognition) +
+ +
+What AWS Resource Groups used for?
+ +Amazon definition: "You can use resource groups to organize your AWS resources. Resource groups make it easier to manage and automate tasks on large numbers of resources at one time. " + +Learn more [here](https://docs.aws.amazon.com/ARG/latest/userguide/welcome.html) +
+ +
+What is AWS Global Accelerator?
+ +Amazon definition: "AWS Global Accelerator is a service that improves the availability and performance of your applications with local or global users..." + +Learn more [here](https://aws.amazon.com/global-accelerator) +
+ +
+What is AWS Config?
+ +Amazon definition: "AWS Config is a service that enables you to assess, audit, and evaluate the configurations of your AWS resources." + +Learn more [here](https://aws.amazon.com/config) +
+ +
+What is AWS X-Ray?
+ +AWS definition: "AWS X-Ray helps developers analyze and debug production, distributed applications, such as those built using a microservices architecture." +Learn more [here](https://aws.amazon.com/xray) +
+ +
+What is AWS OpsWorks?
+ +Amazon definition: "AWS OpsWorks is a configuration management service that provides managed instances of Chef and Puppet." + +Learn more about it [here](https://aws.amazon.com/opsworks) +
+ +
+What is AWS Service Catalog?
+ +Amazon definition: "AWS Service Catalog allows organizations to create and manage catalogs of IT services that are approved for use on AWS." + +Learn more [here](https://aws.amazon.com/servicecatalog) +
+ +
+What is AWS CAF?
+ +Amazon definition: "AWS Professional Services created the AWS Cloud Adoption Framework (AWS CAF) to help organizations design and travel an accelerated path to successful cloud adoption. " + +Learn more [here](https://aws.amazon.com/professional-services/CAF) +
+ +
+What is AWS Cloud9?
+ +AWS definition: "AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you write, run, and debug your code with just a browser" +
+ +
+What is AWS Application Discovery Service?
+ +Amazon definition: "AWS Application Discovery Service helps enterprise customers plan migration projects by gathering information about their on-premises data centers." + +Learn more [here](https://aws.amazon.com/application-discovery) +
+ +
+What is the Trusted Advisor?
+
+ +
+What is the AWS well-architected framework and what pillars it's based on?
+ +AWS definition: "The Well-Architected Framework has been developed to help cloud architects build secure, high-performing, resilient, and efficient infrastructure for their applications. Based on five pillars — operational excellence, security, reliability, performance efficiency, and cost optimization" + +Learn more [here](https://aws.amazon.com/architecture/well-architected) +
+ +
+What AWS services are serverless (or have the option to be serverless)?
+ +AWS Lambda +AWS Athena +
+ +
+What is AWS EMR?
+ +AWS definition: "big data platform for processing vast amounts of data using open source tools such as Apache Spark, Apache Hive, Apache HBase, Apache Flink, Apache Hudi, and Presto." + +Learn more [here](https://aws.amazon.com/emr) +
+ +
+What is AWS Athena?
+ +"Amazon Athena is an interactive query service that makes it easy to analyze data in Amazon S3 using standard SQL." + +Learn more about AWS Athena [here](https://aws.amazon.com/athena) +
+ +
+What is Amazon Cloud Directory?
+ +Amazon definition: "Amazon Cloud Directory is a highly available multi-tenant directory-based store in AWS. These directories scale automatically to hundreds of millions of objects as needed for applications." + +Learn more [here](https://docs.aws.amazon.com/clouddirectory/latest/developerguide/what_is_cloud_directory.html) +
+ +
+What is AWS Elastic Beanstalk?
+ +AWS definition: "AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services...You can simply upload your code and Elastic Beanstalk automatically handles the deployment" + +Learn more about it [here](https://aws.amazon.com/elasticbeanstalk) +
+ +
+What is AWS SWF?
+ +Amazon definition: "Amazon SWF helps developers build, run, and scale background jobs that have parallel or sequential steps. You can think of Amazon SWF as a fully-managed state tracker and task coordinator in the Cloud." + +Learn more on Amazon Simple Workflow Service [here](https://aws.amazon.com/swf) +
+ +
+What is Simple Queue Service (SQS)?
+ +AWS definition: "Amazon Simple Queue Service (SQS) is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications". + +Learn more about it [here](https://aws.amazon.com/sqs) +
+ +#### AWS Disaster Recovery + +
+In regards to disaster recovery, what is RTO and RPO?
+ +RTO - The maximum acceptable length of time that your application can be offline. + +RPO - The maximum acceptable length of time during which data might be lost from your application due to an incident. +
+ +
+What types of disaster recovery techniques AWS supports?
+ +* The Cold Method - Periodically backups and sending the backups off-site
+* Pilot Light - Data is mirrored to an environment which is always running +* Warm Standby - Running scaled down version of production environment +* Multi-site - Duplicated environment that is always running +
+ +
+Which disaster recovery option has the highest downtime and which has the lowest?
+ +Lowest - Multi-site +Highest - The cold method +
+ +### Final Note + +Good luck! You can do it :) diff --git a/exercises/aws/create_user.md b/exercises/aws/create_user.md new file mode 100644 index 000000000..00ca542db --- /dev/null +++ b/exercises/aws/create_user.md @@ -0,0 +1,9 @@ +## IAM AWS - Create a User + +### Objectives + +As you probably know at this point, it's not recommended to work with the root account in AWS. For this reason you are going to create a new account which you'll use regularly as the admin account. + +1. Create a user with password credentials +2. Add the newly created user to a group called "admin" and attach to it the policy called "Administrator Access" +3. Make sure the user has a tag called with the key `Role` and the value `DevOps` diff --git a/exercises/aws/solutions/create_user.md b/exercises/aws/solutions/create_user.md new file mode 100644 index 000000000..34958af63 --- /dev/null +++ b/exercises/aws/solutions/create_user.md @@ -0,0 +1,25 @@ +## IAM AWS - Create a User + +### Objectives + +As you probably know at this point, it's not recommended to work with the root account in AWS. For this reason you are going to create a new account which you'll use regularly as the admin account. + +1. Create a user with password credentials +2. Add the newly created user to a group called "admin" and attach to it the policy called "Administrator Access" +3. Make sure the user has a tag called with the key `Role` and the value `DevOps` + + +### Solution + +1. Go to the AWS IAM service +2. Click on "Users" in the right side menu (right under "Access Management") +3. Click on the button "Add users" +4. Insert the user name (e.g. mario) +5. Select the credential type: "Password" +6. Set console password to custom and click on "Next" +7. Click on "Add user to group" +8. Insert "admin" as group name +9. Check the "AdministratorAccess" policy and click on "Create group" +10. Click on "Next: Tags" +11. Add a tag with the key `Role` and the value `DevOps` +12. Click on "Review" and then create on "Create user" diff --git a/exercises/aws/solutions/password_policy.md b/exercises/aws/solutions/password_policy.md new file mode 100644 index 000000000..1be698812 --- /dev/null +++ b/exercises/aws/solutions/password_policy.md @@ -0,0 +1,13 @@ +## AWS IAM - Password Policy + +### Objectives + +Create password policy with the following settings: + +1. + +### Solution + +1. Go to IAM service in AWS +2. Click on "Account settings" under "Access management" +3. Click on "Change password policy" diff --git a/exercises/shell/argument_check.md b/exercises/shell/argument_check.md new file mode 100644 index 000000000..73ddd12a2 --- /dev/null +++ b/exercises/shell/argument_check.md @@ -0,0 +1,23 @@ +## Argument Check + +### Objectives + +Note: assume the script is executed with an argument + +1. Write a script that will check if a given argument is the string "pizza" + 1. If it's the string "pizza" print "with pineapple?" + 2. If it's not the string "pizza" print "I want pizza!" + +### Solution + +``` +/usr/bin/env bash + +arg_value=${1:-default} + +if [ $arg_value = "pizza" ]; then + echo "with pineapple?" +else + echo "I want pizza!" +fi +``` diff --git a/exercises/shell/basic_date.md b/exercises/shell/basic_date.md new file mode 100644 index 000000000..963872da6 --- /dev/null +++ b/exercises/shell/basic_date.md @@ -0,0 +1,5 @@ +## Basic Date + +### Objectives + +1. Write a script that will put the current date in a file called "the_date.txt" diff --git a/exercises/shell/count_chars.md b/exercises/shell/count_chars.md new file mode 100644 index 000000000..14a4a5da5 --- /dev/null +++ b/exercises/shell/count_chars.md @@ -0,0 +1,11 @@ +## Count Chars + +### Objectives + +1. Read input from the user until you get empty string +2. For each of the lines you read, count the number of characters and print it + +### Constraints + +1. You must use a while loop +2. Assume at least three lines of input diff --git a/exercises/shell/directories_comparison.md b/exercises/shell/directories_comparison.md new file mode 100644 index 000000000..ade0272a1 --- /dev/null +++ b/exercises/shell/directories_comparison.md @@ -0,0 +1,5 @@ +## Directories Comparison + +### Objectives + +1. You are given two directories as arguments and the output should be any difference between the two directories diff --git a/exercises/shell/empty_files.md b/exercises/shell/empty_files.md new file mode 100644 index 000000000..b01daed7e --- /dev/null +++ b/exercises/shell/empty_files.md @@ -0,0 +1,5 @@ +## Empty Files + +### Objectives + +1. Write a script to remove all the empty files in a given directory (including nested directories) diff --git a/exercises/shell/factors.md b/exercises/shell/factors.md new file mode 100644 index 000000000..a7bc5a63f --- /dev/null +++ b/exercises/shell/factors.md @@ -0,0 +1,9 @@ +## Shell Scripting - Factors + +### Objectives + +Write a script that when given a number, will: + +* Check if the number has 2 as factor, if yes it will print "one factor" +* Check if the number has 3 as factor, if yes it will print "one factor...actually two!" +* If none of them (2 and 3) is a factor, print the number itself diff --git a/exercises/shell/files_size.md b/exercises/shell/files_size.md new file mode 100644 index 000000000..5f3e1849f --- /dev/null +++ b/exercises/shell/files_size.md @@ -0,0 +1,7 @@ +## Files Size + +### Objectives + +1. Print the name and size of every file and directory in current path + +Note: use at least one for loop! diff --git a/exercises/shell/great_day.md b/exercises/shell/great_day.md new file mode 100644 index 000000000..3ec64dfc7 --- /dev/null +++ b/exercises/shell/great_day.md @@ -0,0 +1,7 @@ +## Great Day + +### Objectives + +1. Write a script that will print "Today is a great day!" unless it's given a day name and then it should print "Today is " + +Note: no need to check whether the given argument is actually a valid day diff --git a/exercises/shell/hello_world.md b/exercises/shell/hello_world.md new file mode 100644 index 000000000..9c4bca919 --- /dev/null +++ b/exercises/shell/hello_world.md @@ -0,0 +1,6 @@ +## Shell Scripting - Hello World + +### Objectives + +1. Define a variable with the string 'Hello World' +2. Print the value of the variable you've defined and redirect the output to the file "amazing_output.txt" diff --git a/exercises/shell/host_status.md b/exercises/shell/host_status.md new file mode 100644 index 000000000..ae96c969f --- /dev/null +++ b/exercises/shell/host_status.md @@ -0,0 +1,5 @@ +## It's Alive! + +### Objectives + +1. Write a script to determine whether a given host is down or up diff --git a/exercises/shell/num_of_args.md b/exercises/shell/num_of_args.md new file mode 100644 index 000000000..fb07f653f --- /dev/null +++ b/exercises/shell/num_of_args.md @@ -0,0 +1,7 @@ +## Number of Arguments + +### Objectives + +* Write a script that will print "Got it: " in case of one argument +* In case no arguments were provided, it will print "Usage: ./ " +* In case of more than one argument, print "hey hey...too many!" diff --git a/exercises/shell/print_arguments.md b/exercises/shell/print_arguments.md new file mode 100644 index 000000000..b41aa85e0 --- /dev/null +++ b/exercises/shell/print_arguments.md @@ -0,0 +1,9 @@ +## Shell Scripting - Print Arguments + +### Objectives + +You should include everything mentioned here in one shell script + +1. Print the first argument passed to the script +2. Print the number of arguments passed to the script +3. diff --git a/exercises/shell/solutions/basic_date.md b/exercises/shell/solutions/basic_date.md new file mode 100644 index 000000000..8dce8f4f8 --- /dev/null +++ b/exercises/shell/solutions/basic_date.md @@ -0,0 +1,13 @@ +## Basic Date + +### Objectives + +1. Write a script that will put the current date in a file called "the_date.txt" + +### Solution + +``` +#!/usr/bin/env bash + +echo $(date) > the_date.txt +``` diff --git a/exercises/shell/solutions/count_chars.md b/exercises/shell/solutions/count_chars.md new file mode 100644 index 000000000..5e4b85a15 --- /dev/null +++ b/exercises/shell/solutions/count_chars.md @@ -0,0 +1,24 @@ +## Count Chars + +### Objectives + +1. Read input from the user until you get empty string +2. For each of the lines you read, count the number of characters and print it + +### Constraints + +1. You must use a while loop +2. Assume at least three lines of input + +### Solution + +``` +#!/usr/bin/env bash + +echo -n "Please insert your input: " + +while read line; do + echo -n "$line" | wc -c + echo -n "Please insert your input: " +done +``` diff --git a/exercises/shell/solutions/empty_files.md b/exercises/shell/solutions/empty_files.md new file mode 100644 index 000000000..e4858a548 --- /dev/null +++ b/exercises/shell/solutions/empty_files.md @@ -0,0 +1,20 @@ +## Empty Files + +### Objectives + +1. Write a script to remove all the empty files in a given directory (including nested directories) + +### Solution + +``` +#! /bin/bash +for x in * +do + if [ -s $x ] + then + continue + else + rm -rf $x + fi +done +``` diff --git a/exercises/shell/solutions/factors.md b/exercises/shell/solutions/factors.md new file mode 100644 index 000000000..0ffc2857f --- /dev/null +++ b/exercises/shell/solutions/factors.md @@ -0,0 +1,20 @@ +## Shell Scripting - Factors + +### Objectives + +Write a script that when given a number, will: + +* Check if the number has 2 as factor, if yes it will print "one factor" +* Check if the number has 3 as factor, if yes it will print "one factor...actually two!" +* If none of them (2 and 3) is a factor, print the number itself + +### Solution + +``` +#!/usr/bin/env bash + +(( $1 % 2 )) || res="one factor" +(( $1 % 3 )) || res+="...actually two!" + +echo ${res:-$1} +``` diff --git a/exercises/shell/solutions/files_size.md b/exercises/shell/solutions/files_size.md new file mode 100644 index 000000000..df5d1edde --- /dev/null +++ b/exercises/shell/solutions/files_size.md @@ -0,0 +1,17 @@ +## Files Size + +### Objectives + +1. Print the name and size of every file and directory in current path + +Note: use at least one for loop! + +### Solution + +``` +#!/usr/bin/env bash + +for i in $(ls -S1); do + echo $i: $(du -sh "$i" | cut -f1) +done +``` diff --git a/exercises/shell/solutions/great_day.md b/exercises/shell/solutions/great_day.md new file mode 100644 index 000000000..f7fa4e408 --- /dev/null +++ b/exercises/shell/solutions/great_day.md @@ -0,0 +1,15 @@ +## Great Day + +### Objectives + +1. Write a script that will print "Today is a great day!" unless it's given a day name and then it should print "Today is " + +Note: no need to check whether the given argument is actually a valid day + +### Solution + +``` +#!/usr/bin/env bash + +echo "Today is ${1:-a great day!}" +``` diff --git a/exercises/shell/solutions/hello_world.md b/exercises/shell/solutions/hello_world.md new file mode 100644 index 000000000..51c9dce4b --- /dev/null +++ b/exercises/shell/solutions/hello_world.md @@ -0,0 +1,15 @@ +## Shell Scripting - Hello World + +### Objectives + +1. Define a variable with the string 'Hello World' +2. Print the value of the variable you've defined and redirect the output to the file "amazing_output.txt" + +### Solution + +``` +#!/usr/bin/env bash + +HW_STR="Hello World" +echo $HW_STR > amazing_output.txt +``` diff --git a/exercises/shell/solutions/host_status.md b/exercises/shell/solutions/host_status.md new file mode 100644 index 000000000..a526d6e43 --- /dev/null +++ b/exercises/shell/solutions/host_status.md @@ -0,0 +1,20 @@ +## It's Alive! + +### Objectives + +1. Write a script to determine whether a given host is down or up + +### Solution + +``` +#!/usr/bin/env bash +SERVERIP= +NOTIFYEMAIL=test@example.com + +ping -c 3 $SERVERIP > /dev/null 2>&1 +if [ $? -ne 0 ] +then + # Use mailer here: + mailx -s "Server $SERVERIP is down" -t "$NOTIFYEMAIL" < /dev/null +fi +``` diff --git a/exercises/shell/solutions/num_of_args.md b/exercises/shell/solutions/num_of_args.md new file mode 100644 index 000000000..cc9ade6c0 --- /dev/null +++ b/exercises/shell/solutions/num_of_args.md @@ -0,0 +1,26 @@ +## Number of Arguments + +### Objectives + +* Write a script that will print "Got it: " in case of one argument +* In case no arguments were provided, it will print "Usage: ./ " +* In case of more than one argument, print "hey hey...too many!" + +### Solution + +``` +#!/usr/bin/env bash + +set -eu + +main() { + case $# in + 0) printf "%s" "Usage: ./ "; return 1 ;; + 1) printf "%s" "Got it: $1"; return 0 ;; + *) return 1 ;; + esac +} + +main "$@" +``` + diff --git a/exercises/shell/solutions/sum.md b/exercises/shell/solutions/sum.md new file mode 100644 index 000000000..148f8bcf7 --- /dev/null +++ b/exercises/shell/solutions/sum.md @@ -0,0 +1,30 @@ +## Sum + +### Objectives + +1. Write a script that gets two numbers and prints their sum +3. Make sure the input is valid (= you got two numbers from the user) +2. Test the script by running and passing it two numbers as arguments + +### Constraints + +1. Use functions + +### Solution + +``` +#!/usr/bin/env bash + +re='^[0-9]+$' + +if ! [[ $1 =~ $re && $2 =~ $re ]]; then + echo "Oh no...I need two numbers" + exit 2 +fi + +function sum { + echo $(( $1 + $2 )) +} + +sum $1 $2 +``` diff --git a/exercises/shell/sum.md b/exercises/shell/sum.md new file mode 100644 index 000000000..ca416bda9 --- /dev/null +++ b/exercises/shell/sum.md @@ -0,0 +1,11 @@ +## Sum + +### Objectives + +1. Write a script that gets two numbers and prints their sum +3. Make sure the input is valid (= you got two numbers from the user) +2. Test the script by running and passing it two numbers as arguments + +### Constraints + +1. Use functions