001_IAM_01_Basics
## User& Groups
- Identity and Access Management,区域为 **Global**
- **Root account** 被默认创建,但是一般情况下绝不应该被使用和分享
- **Users** 是组织内的人,可以被分组
- 组仅包含 **Users**,不能包含组
- **Users** 可以属于多个组
* * *
* * *
## IAM:Permissions
- **Users or Groups** 可以为其分配**策略(policies)**,该策略为 **JSON** 文档
- 这些策略定义了 **Users** 的 **权限(permissions)**
- 在 AWS 中应遵循 **最小权限原则(least privilege principle)**:不要授予超过 Users 需求的权限
* * *
## IAM Policies Inheritance(IAM策略继承)
如果:
- Developers Team Policy:Alice,Bob,Charles
- Audit Team Policy:Charles,David
- Inline Policy:Fred(未被分组也可以授予policy)
那么:
- Charles 同时拥有 Developers Team Policy 和 Audit Team Policy 两个组的权限
* * *
## IAM Policies Structure
- Coinsists of
- Version:策略语言版本,总是包括“2023-01-14”(xxxx-xx-xx)
- ID:策略的标识符,名称(optional可选的)
- Statement(声明):一个或者多个 **个人声明(Individual Statement)**(required规定的)
- Statements consists of
- Sid:声明的标识符,名称(optional可选的)
- Effect:该声明为允许或者拒绝(Allow,Deny)
- Principal:规定此策略适用于何处(Account,Users,Role)
- Action:此策略允许或拒绝的行动清单
- Resource:上述行动清单应用于何处的资源清单
- Condition:此策略启用期间的条件(optional可选的)
```json
{
"Version": "2023-07-02",
"Id": "S3-Account-Permissions",
"Statement":[
{
"Sid": "1",
"Effect": "Allow",
"Principal": {
"AWS": ["arn:aws:iam::123456789012:root"]
},
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": ["arn:aws:s3:::mybucket/*"]
}
]
}
```
* * *
## IAM Password Policy
- **Strong passwords(强密码)** = 对帐户更高的安全性
- 在 AWS 中可以设置密码策略:
- 设置最小密码长度限制
- 规定特殊字符类型:
- 包括大写字母
- 小写字母
- 数字
- 非字母数字字符
- 允许所有 IAM Users 去更改为他们自己的密码
- 规定 Users 每隔一段时间去变更一次密码(Password Expiration密码过期)
- 防止密码重复使用(禁止使用曾经设定过的密码)
* * *
## Multi Factor Authentication - MFA
- Users 可以访问账户,并可能更改配置或删除账户中的资源
- 因此为了保护 Root 账户和 IAM Users,可以使用 **MFA设备(password + security device)**
- 最主要的作用:如果密码被偷或者被黑,账户无法被盗用
- 设备类型:
- 虚拟 MFA 设备:Google Authenticator(phone only),Authy(multi-device)
- Universal 2nd Factor(U2F)安全密钥(YubiKey by Yubico - 3rd party)
- Hardware Key Fob MFA Device(Provided by Gemalto - 3rd party)
- Hardware Key Fob MFA Device for AWS GovCloud(US)(Provided by SurePassID - 3rd party)
* * *
* * *
## Users access AWS
- 连接 AWS 有三种方式:
- AWS Management Console:通过 AWS 管理控制台登录(受password + MFA保护)
- AWS Command Line Interface(CLI):通过 CLI 控制台连接(受access keys保护)
- AWS Software Developer Kit(SDK):通过软件开发kit登录(受access keys保护)
- Access Keys 通过 AWS Console 生成
- Users 管理他们自己的access keys
- Access Keys 是保密的,像密码一样,永远不应该分享他们
- Access Key ID ~= username
- Secret Access Key ~= password
* * *
## AWS CLI
- 通过 CLI 工具可以与 AWS services 进行交互
- 直接连接 AWS services 的 Public APIs
- 可以开发脚本来管理资源
- CLI是开源的
- 可以作为 AWS Management Console 的替代品
* * *
## AWS SDK
- 特定语言APIs(库集)
- 可以通过编程的方式来管理和访问 AWS Services
- 嵌入到应用程序中
- Supports:
- SDKs(JS,Python,PHP,.NET,Ruby,Java,Go,Node.js,C++)
- Mobile SDKs(Android, IOS,...)
- IOT Device SDKs(Embedded C,Arduino,...)
- Example:CLI是由Python构建的
* * *
* * *
## AWS Roles
- 一些 AWS Service 需要代表管理者执行操作
- 因此,可以通过给予目标 IAM Roles 来分配执行AWS Service 的权限
- 常见 Roles:
- EC2 实例 Roles
- Lambda 函数 Roles
- CloudFormation 的 Roles
* * *
* * *
## IAM Security Tools
- **IAM Credentials Report**(account-level账户级别)
- 可以列出账户的所有 User 以及他们的各种凭据的状态
- **IAM Access Advisor**(user-level用户级别)
- Access advisor 可以展示用户已被授予的权限和上次访问这些权限的时间
- 可以使用这些信息来修改策略(policies)
* * *
* * *
## IAM Guidelines & Best Practices
- 除了用于账户设置以外,**不要**使用 **Root** 账户
- One physical user = One AWS user
- 尽量将用户分组(group),将权限分配给组(group)
- 创建**强密码**策略
- 使用并强制使用**MFA**
- 创建和使用 **Roles** 来授予执行 AWS Services 权限
- 使用 **Access Keys** 来进行编程式访问(CLI/SDK)
- 使用 **IAM Credentials Report** 来审计**账户权限**
- 永远**不要分享** IAM users 和 Access Keys
* * *
* * *
## IAM Section - Summary
- Users:映射到物理用户,拥有 AWS Console 的密码
- Groups:只包含 Users
- Policies:概述 Users 或 Groups 的权限的 JSON 文档
- Roles:适用于 EC2 实例或者 AWS Services
- Security:MFA + Password Policy(密码策略)
- Audit:IAM Credential Reports(account-level)& IAM Access Advisor(user-level)
* * *
* * *
* * *
Summarize From Stéphane Maarek, AWS Documention

