Skip to content

Commit b2b0a60

Browse files
authored
Update solution.md (#398)
* Update solution.md I have added a solution to the exercise using Terraform * Update solution.md fixed some indentations * Update solution.md * Update solution.md Added a solution using Terraform
1 parent 88f7244 commit b2b0a60

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

topics/aws/exercises/create_user/solution.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,37 @@ As you probably know at this point, it's not recommended to work with the root a
2323
10. Click on "Next: Tags"
2424
11. Add a tag with the key `Role` and the value `DevOps`
2525
12. Click on "Review" and then create on "Create user"
26+
27+
13. ### Solution using Terraform
28+
29+
```
30+
31+
resource "aws_iam_group_membership" "team" {
32+
name = "tf-testing-group-membership"
33+
34+
users = [
35+
aws_iam_user.newuser.name,
36+
37+
]
38+
39+
group = aws_iam_group.admin.name
40+
}
41+
42+
resource "aws_iam_group_policy_attachment" "test-attach" {
43+
group = aws_iam_group.admin.name
44+
policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
45+
}
46+
resource "aws_iam_group" "admin" {
47+
name = "admin"
48+
}
49+
50+
resource "aws_iam_user" "newuser" {
51+
name = "newuser"
52+
path = "/system/"
53+
54+
tags = {
55+
Role = "DevOps"
56+
}
57+
}
58+
```
59+

topics/aws/exercises/password_policy_and_mfa/solution.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,17 @@ MFA:
3030
3. Expand "Multi-factor authentication (MFA)" and click on "Activate MFA"
3131
4. Choose one of the devices
3232
5. Follow the instructions to set it up and click on "Assign MFA"
33+
34+
6. ### Solution using Terraform:
35+
36+
```
37+
resource "aws_iam_account_password_policy" "strict" {
38+
minimum_password_length = 8
39+
require_numbers = true
40+
allow_users_to_change_password = true
41+
password_reuse_prevention = 1
42+
}
43+
```
44+
45+
**Note:** You cannot add MFA through terraform, you have to do it in the GUI.
46+

0 commit comments

Comments
 (0)