Add a couple of questions
This commit is contained in:
parent
18e69a2baa
commit
5163a9a258
@ -399,11 +399,21 @@ True
|
||||
</b></details>
|
||||
|
||||
<details>
|
||||
<summary>Given an example of IAM best practices?</summary><br><b>
|
||||
<summary>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</summary><br><b>
|
||||
|
||||
* 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.
|
||||
</b></details>
|
||||
|
||||
<details>
|
||||
<summary>True or False? Groups in AWS IAM, can contain only users and not other groups</summary><br><b>
|
||||
|
||||
True
|
||||
</b></details>
|
||||
|
||||
<details>
|
||||
<summary>True or False? Users in AWS IAM, can belong only to a single group</summary><br><b>
|
||||
|
||||
False. Users can belong to multiple groups.
|
||||
</b></details>
|
||||
|
||||
<details>
|
||||
|
1202
certificates/aws-solutions-architect-associate.md
Normal file
1202
certificates/aws-solutions-architect-associate.md
Normal file
File diff suppressed because it is too large
Load Diff
9
exercises/aws/create_user.md
Normal file
9
exercises/aws/create_user.md
Normal file
@ -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`
|
25
exercises/aws/solutions/create_user.md
Normal file
25
exercises/aws/solutions/create_user.md
Normal file
@ -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"
|
13
exercises/aws/solutions/password_policy.md
Normal file
13
exercises/aws/solutions/password_policy.md
Normal file
@ -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"
|
23
exercises/shell/argument_check.md
Normal file
23
exercises/shell/argument_check.md
Normal file
@ -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
|
||||
```
|
5
exercises/shell/basic_date.md
Normal file
5
exercises/shell/basic_date.md
Normal file
@ -0,0 +1,5 @@
|
||||
## Basic Date
|
||||
|
||||
### Objectives
|
||||
|
||||
1. Write a script that will put the current date in a file called "the_date.txt"
|
11
exercises/shell/count_chars.md
Normal file
11
exercises/shell/count_chars.md
Normal file
@ -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
|
5
exercises/shell/directories_comparison.md
Normal file
5
exercises/shell/directories_comparison.md
Normal file
@ -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
|
5
exercises/shell/empty_files.md
Normal file
5
exercises/shell/empty_files.md
Normal file
@ -0,0 +1,5 @@
|
||||
## Empty Files
|
||||
|
||||
### Objectives
|
||||
|
||||
1. Write a script to remove all the empty files in a given directory (including nested directories)
|
9
exercises/shell/factors.md
Normal file
9
exercises/shell/factors.md
Normal file
@ -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
|
7
exercises/shell/files_size.md
Normal file
7
exercises/shell/files_size.md
Normal file
@ -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!
|
7
exercises/shell/great_day.md
Normal file
7
exercises/shell/great_day.md
Normal file
@ -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 <given day>"
|
||||
|
||||
Note: no need to check whether the given argument is actually a valid day
|
6
exercises/shell/hello_world.md
Normal file
6
exercises/shell/hello_world.md
Normal file
@ -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"
|
5
exercises/shell/host_status.md
Normal file
5
exercises/shell/host_status.md
Normal file
@ -0,0 +1,5 @@
|
||||
## It's Alive!
|
||||
|
||||
### Objectives
|
||||
|
||||
1. Write a script to determine whether a given host is down or up
|
7
exercises/shell/num_of_args.md
Normal file
7
exercises/shell/num_of_args.md
Normal file
@ -0,0 +1,7 @@
|
||||
## Number of Arguments
|
||||
|
||||
### Objectives
|
||||
|
||||
* Write a script that will print "Got it: <argument value>" in case of one argument
|
||||
* In case no arguments were provided, it will print "Usage: ./<program name> <argument>"
|
||||
* In case of more than one argument, print "hey hey...too many!"
|
9
exercises/shell/print_arguments.md
Normal file
9
exercises/shell/print_arguments.md
Normal file
@ -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.
|
13
exercises/shell/solutions/basic_date.md
Normal file
13
exercises/shell/solutions/basic_date.md
Normal file
@ -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
|
||||
```
|
24
exercises/shell/solutions/count_chars.md
Normal file
24
exercises/shell/solutions/count_chars.md
Normal file
@ -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
|
||||
```
|
20
exercises/shell/solutions/empty_files.md
Normal file
20
exercises/shell/solutions/empty_files.md
Normal file
@ -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
|
||||
```
|
20
exercises/shell/solutions/factors.md
Normal file
20
exercises/shell/solutions/factors.md
Normal file
@ -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}
|
||||
```
|
17
exercises/shell/solutions/files_size.md
Normal file
17
exercises/shell/solutions/files_size.md
Normal file
@ -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
|
||||
```
|
15
exercises/shell/solutions/great_day.md
Normal file
15
exercises/shell/solutions/great_day.md
Normal file
@ -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 <given day>"
|
||||
|
||||
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!}"
|
||||
```
|
15
exercises/shell/solutions/hello_world.md
Normal file
15
exercises/shell/solutions/hello_world.md
Normal file
@ -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
|
||||
```
|
20
exercises/shell/solutions/host_status.md
Normal file
20
exercises/shell/solutions/host_status.md
Normal file
@ -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=<IP Address>
|
||||
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
|
||||
```
|
26
exercises/shell/solutions/num_of_args.md
Normal file
26
exercises/shell/solutions/num_of_args.md
Normal file
@ -0,0 +1,26 @@
|
||||
## Number of Arguments
|
||||
|
||||
### Objectives
|
||||
|
||||
* Write a script that will print "Got it: <argument value>" in case of one argument
|
||||
* In case no arguments were provided, it will print "Usage: ./<program name> <argument>"
|
||||
* 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: ./<program name> <argument>"; return 1 ;;
|
||||
1) printf "%s" "Got it: $1"; return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
main "$@"
|
||||
```
|
||||
|
30
exercises/shell/solutions/sum.md
Normal file
30
exercises/shell/solutions/sum.md
Normal file
@ -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
|
||||
```
|
11
exercises/shell/sum.md
Normal file
11
exercises/shell/sum.md
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user