You are on page 1of 11

Module 8 ­ Security/IAM 

 
Introduction 
Simple user, group and policy setup 
Setup AWS Administrators group and user 
Enable MFA for Administrator group 
Setup Sysadmin group and user 
Setup Developer group and user 
Setup Manager group and user 
Switch roles: manager to developer 
Roles for EC2 instances 
Audit/Reporting 
 
 

Introduction 
 
IAM 
http://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html 
 
IAM roles 
http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html 
 
IAM roles for EC2 instances 
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam­roles­for­amazon­ec2.html 
 
IAM business use cases 
http://docs.aws.amazon.com/IAM/latest/UserGuide/IAM_UseCases.html 
 
Example IAM policies 
http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_examples.html 
 
IAM best practices 
http://docs.aws.amazon.com/IAM/latest/UserGuide/best­practices.html 
 
Video presentation on IAM 
https://www.youtube.com/watch?v=ZhvXW­ILyPs 
 

   
Simple user, group and policy setup 
Create IAM user 
 
● Create a user anyuser_1 and force user to change password on first login 
● Login to AWS console using this user (Cannot change password) 
● Create IAM policy to allow password change 
Allow password change 

  "Version": "2012­10­17", 
  "Statement": { 
    "Effect": "Allow", 
    "Action": [ 
      "iam:ChangePassword", 
      "iam:GetAccountPasswordPolicy" 
    ], 
    "Resource": "*" 
  } 

● Attach policy to user anyuser_1 
● Login to AWS console, change password on first login 
● Access S3 dashboard to test access 
 
Create IAM group 
 
● Create group allusers 
● Attach policy allow­password­change to group 
● Create new user anyuser_2 
● Attach user to group allusers 
● Login to AWS console, change password on first login 
● Access S3 dashboard to test access 
 
Set Password policy 
 
● Set policy to require: 
○ Min length 6 
○ Atleast 1 capital, 1 small, 1 number and 1 special character 
○ Password expires after 1 year 
○ Password reset every 3 months 
○ Last 3 password cannot be reused 
● Create new user anyuser_3 and test password change policy on first login 
 
 
 
 
 
 
Setup AWS Administrators group and user 
 
● Create group awsadmin 
● Attach policy AdministratorAccess 
● Create user admin_1 
● Attach user admin_1 to group awsadmin 
● Access AWS console and test access, e.g. create S3 bucket 
 

   
Enable MFA for Administrator group 
 
Activate MFA for Admin user 
● Active MFA for user admin_1 using Virtual MFA (Google Authenticator) 
● Test login using MFA 
 
Force MFA for EC2 actions 
● Create policy mfa­required­for­ec2 
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1449985374000",
"Effect": "Allow",
"Action": [
"ec2:*"
],
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": "true"
}
},
"Resource": [
"*"
]
}
]

● Attach policy inline to group awsadmin 
 

   
Setup Sysadmin group and user 
 
Create group 
● Create group sysadmin 
● Attach policy EC2FullAccess 
 
Create user 
● Create user sysadmin_1 
● Generate access key for the user, download credentials 
● Setup up password 
● Attach user to group sysadmin 
● Test EC2 access using AWS console 
● Test EC2 access using CLI 
 

   
Setup Developer group and user 
 
Create group 
● Create group developer 
● Create and attach policy (ec2­for­developers) for limited access to instances with tag environment=dev: 

    "Version": "2012­10­17", 
    "Statement": [ 
        { 
            "Sid": "Stmt1449988260000", 
            "Effect": "Allow", 
            "Action": [ 
                "ec2:DescribeInstances", 
                "ec2:RunInstances", 
                "ec2:StartInstances", 
                "ec2:StopInstances", 
                "ec2:TerminateInstances" 
            ], 
            "Condition": { 
                "StringEquals": { 
                    "ec2:ResourceTag/environment": "dev" 
                } 
            }, 
            "Resource": [ 
                "*" 
            ] 
        } 
    ] 

 
 
Create user 
● Create user developer_1 
● Generate access key for the user, download credentials 
● Setup up password 
● Attach user to group sysadmin 
● Test EC2 access using AWS console 
● Test EC2 access using CLI 
 

   
Setup Manager group and user 
 
Create group 
● Create group manager 
● Attach policy ReadOnlyAccess 
 
Create user 
● Create user manager_1 
● Setup up password 
● Attach user to group manager 
● Test EC2 access using AWS console 

   
Switch roles: manager to developer 
 
Create role 
● Create role developer_role 
● Attach policy ec2­access­for­developers 
 
Attach policy to allow switching roles 
● Create a policy manager­switch­to­developer­role 

    "Version": "2012­10­17", 
    "Statement": [ 
        { 
            "Sid": "Stmt1449989636000", 
            "Effect": "Allow", 
            "Action": [ 
                "sts:AssumeRole" 
            ], 
            "Resource": [ 
                "arn:aws:iam:: <12 digit AWS account>:role/developer_role" 
            ] 
        } 
    ] 

● Attach above policy to manager group 
 
Test switching role 
● Login as user manager_1 
● Test switching role to developer_role 
 
 

   
Roles for EC2 instances 
 
Create IAM role for EC2 instances 
● Create role ec2­cli 
● Assign full EC2 access to the role 
● Create EC2 instance and associate role ec2­cli 
● SSH to the EC2 instance 
 
Test EC2 role using CLI 
● aws ec2 help 
● aws ec2 describe­instances 
● aws configure 
● aws ec2 describe­instances 
● aws s3 ls 
ERROR: No permissions for S3 
 
Ruby SDK with EC2 role 
Create and run a sample ruby program using AWS SDK: 
● gem install aws­sdk 
● vi ec2­role­sdk.rb 
require 'rubygems' 
require 'aws­sdk' 
 
ec2 = Aws::EC2::Client.new(region:'us­west­2') 
resp = ec2.describe_instances() 
 
resp.reservations.each do |res| 
        res.instances.each do |inst| 
   iid = inst[:instance_id] 
  puts "#{iid}" 
        end 
end 
● ruby ec2­role­sdk.rb 
 
   
Audit/Reporting 
Review: 
● Credentials report  
● CloudTrail report 
 

   
Review/Assignments 
Questions 
● What are various types of MFA mechanisms that can be used with AWS? 
● What are the key benefits of roles in AWS? 
● What is the difference between roles and groups? 
● How will you use your existing identity database (e.g. Active Directory) with AWS? 
● What tools are available to perform IS audits? 
 
Assignments 
● Implement these business use­cases in your AWS account: 
http://docs.aws.amazon.com/IAM/latest/UserGuide/IAM_UseCases.html 
● Implement these example policies in your AWS account: 
http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_examples.html 
● Review your organization Identity and Access policies. Implement them in your AWS account. 
 
 
 

You might also like