diff --git a/topics/aws/exercises/create_user/solution.md b/topics/aws/exercises/create_user/solution.md index 34958af..8b81c8d 100644 --- a/topics/aws/exercises/create_user/solution.md +++ b/topics/aws/exercises/create_user/solution.md @@ -23,3 +23,37 @@ As you probably know at this point, it's not recommended to work with the root a 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. ### Solution using Terraform + +``` + +resource "aws_iam_group_membership" "team" { + name = "tf-testing-group-membership" + + users = [ + aws_iam_user.newuser.name, + + ] + + group = aws_iam_group.admin.name +} + +resource "aws_iam_group_policy_attachment" "test-attach" { + group = aws_iam_group.admin.name + policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess" +} +resource "aws_iam_group" "admin" { + name = "admin" +} + +resource "aws_iam_user" "newuser" { + name = "newuser" + path = "/system/" + + tags = { + Role = "DevOps" + } +} +``` + diff --git a/topics/aws/exercises/password_policy_and_mfa/solution.md b/topics/aws/exercises/password_policy_and_mfa/solution.md index 41ac52d..84585c1 100644 --- a/topics/aws/exercises/password_policy_and_mfa/solution.md +++ b/topics/aws/exercises/password_policy_and_mfa/solution.md @@ -30,3 +30,17 @@ MFA: 3. Expand "Multi-factor authentication (MFA)" and click on "Activate MFA" 4. Choose one of the devices 5. Follow the instructions to set it up and click on "Assign MFA" + +6. ### Solution using Terraform: + +``` +resource "aws_iam_account_password_policy" "strict" { + minimum_password_length = 8 + require_numbers = true + allow_users_to_change_password = true + password_reuse_prevention = 1 +} +``` + + **Note:** You cannot add MFA through terraform, you have to do it in the GUI. +