AWS IAM
Users and Groups
- IAM: Identity and Access Management, Global service
- Root account: created by default, shouldn't be used or shared
- Users: are people within your organization and can be grouped
- users don't have to belong to a group
- users can belong to multiple groups
- Groups: only contains users, not other groups
IAM permissions
- Users and groups can be assigned JSON documents called policies
- The policies define the permissions of the users
- Least privilege principle: don't give more permissions than a user needs
IAM policy
{
"Version": "2012-10-17",
"Id": "ecs-tag-permissions",
"Statement": [
{
"Sid": "AllowECSTagResource",
"Effect": "Allow",
"Principal": {
"AWS": ["arn:aws:iam::123456789:root"]
}
"Action": [
"ecs:TagResource"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"ecs:CreateAction": [
"CreateCluster",
"RegisterTaskDefinition"
]
}
}
}
]
}
Version
: policy language versionId
: an identifier of the policy (optional)Statement
: one or more individual statements (required)Sid
: an identifier of the statement (optional)Effect
: whether the statement allows or denies access (Allow/Deny)Principal
: the account/user/role to which the policy applied toAction
: list of actions the policy allows or deniesResource
: list of resources to which the actions applied toCondition
: conditions for when the policy is in effect (optional)
IAM Password Policy
-
Account settings => Password Policy
- Password minimum length
- Password strength
- Password expiration
- Allow users to change their own password
- Prevent password reuse
-
MFA: Multi Factor Authentication
- Virtual MFA device: Google Authenticator, Authy
- Universal 2nd Factor (U2F) Security Key: YubiKey by Yubico
- Hardware Key Fob MFA Device: by Gemalto
- Hardware Key Fob MFA Device for AWS GovCloud (US): by SurePassID
How users access AWS
- AWS console
- AWS CLI: protected by access key
- AWS SDK: protected by access key
- CloudShell
IAM roles for services
- Some AWS services will need to perform actions on our behalf, so we will assign permissions to AWS services with IAM Roles.
- Common roles:
- EC2 instance roles
- Lambda function roles
- Roles for CloudFormation
Create a role for EC2 to access IAM (readonly), the trust policy
(Trusted entities) is:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
And the permission is:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:GenerateCredentialReport",
"iam:GenerateServiceLastAccessedDetails",
"iam:Get*",
"iam:List*",
"iam:SimulateCustomPolicy",
"iam:SimulatePrincipalPolicy"
],
"Resource": "*"
}
]
}