IAM (Identity and Access Management)
- IAM ์ด๋ AWS Resources ์ ๊ทผ ๊ถํ์ ๊ด๋ฆฌํ๋
Global Service
- Root Account ๋ AWS ๊ณ์ ์์ฑ ์์ ๊ธฐ๋ณธ์ผ๋ก ์์ฑ๋๊ณ AWS ๊ณ์ ์์ฑ์๋ง ์ฌ์ฉ
IAM Users & User Groups
- User ๋ ํ๋์ ์กฐ์ง ๋ด ์ฌ์ฉ์์ ํด๋นํ๋ฉฐ ํ์ํ๋ค๋ฉด Group ์ผ๋ก ๋ฌถ์ ์ ์์
- User ๋ 0~10๊ฐ์ Group ์ ์ํ ์ ์์
- Group ์ User ๋ง์ ํฌํจํ ์ ์์ผ๋ฉฐ Group ์ ํฌํจํ๋ ๊ฒ์ ๋ถ๊ฐ๋ฅ
์ต์ ๊ถํ ์์น
์ ๋ฐํ์ผ๋ก AWS ๋ฅผ ์ฌ์ฉํ๊ฒ๋ ํ๊ธฐ ์ํด์ IAM User ์ Group ์ ์ฌ์ฉ- User ๋๋ Group ์ JSON ํ์์ผ๋ก ์ด๋ฃจ์ด์ง IAM Policy ๋ฅผ ํ ๋น ๋ฐ์ ์ ์์
IAM User ์์ฑ
- AWS Management Console ์์ IAM โ Users โ Create user
Provide user access to the AWS Management Console
ํ์ฑํ๋ฅผ ํตํด User ์๊ฒ AWS Management Console ์ด์ฉ ๊ถํ ๋ถ์ฌConsole password
๋ฅผ Custom password ๋ก ์ค์ ํด์ User ์์ฑ- ํ์ธ์ ์ํ IAM User ์์ฑ ์
Autogenerated password
+User must create a new password at next sign-in
์ผ๋ก ๋น๋ฐ๋ฒํธ ์ฌ์ค์ ์๋ฌดํ
- ํ์ธ์ ์ํ IAM User ์์ฑ ์
- Create group ์ผ๋ก User ๊ฐ ์ํ Group ์ ๋ง๋ค๋ฉด์ ๋์์ Permission policies ๊น์ง ํ ๋น
- ๋ง์ง๋ง Review ํ Create user ํด๋ฆญ ์ User ์์ฑ ์๋ฃ
- Users ๋ก ๋ค์ ๋์์๋ณด๋ฉด User ๊ฐ ์ฑ๊ณต์ ์ผ๋ก ์์ฑ๋์ด์๋ ๊ฒ์ ํ์ธ ๊ฐ๋ฅ
IAM User Access Key for AWS CLI
- AWS Management Console ์์ IAM โ Users โ User ์ ํ โ Security credentials ํญ โ Access keys ์์
Create access key
- CLI ์ ํํ ๋ง์ง๋ง ํ๋ฉด์ด Access Key ์ Secret Access Key ๋ฅผ ์ ์ฅํ ์ ์๋ ์ ์ผํ ์๊ฐ
$ aws configure
AWS Access Key ID [None]: ACCESS_KEY
AWS Secret Access Key [None]: SECRET_ACCESS_KEY
Default region name [None]: ap-east-1
Default output format [None]:
aws configure
๋ช ๋ น์ด ์ ๋ ฅ ํ ์์ ๊ฐ์ด ์ค์ ํ๋ฉด CLI ๋ก AWS API ๋ฅผ ์ฌ์ฉ ๊ฐ๋ฅ- ๋จ, EC2 ์ธ์คํด์ค์ ๊ฐ์ด ํ์ธ์ด ์ ์ํ ์ ์๋ ๋จธ์ ์์ ์ด ๋ฐฉ๋ฒ์ ์ฐ๋ฉด ํ์ธ์ด ์ธ์คํด์ค์ ์ ๋ ฅ๋ ์๊ฒฉ ์ฆ๋ช ์ ๋ณด๋ฅผ ํ์ํ ์ ์๊ธฐ ๋๋ฌธ์ best practice ๊ฐ ์๋
- ๋ฐ๋ผ์ EC2 ์์ AWS API ๋ฅผ ์ฌ์ฉํ๊ธธ ์ํ ๊ฒฝ์ฐ IAM Role ์ ์ง์ ํ๋๊ฒ best practice
IAM Policies
- IAM Policy is a JSON document that allows or denies permissions to AWS resources
- Follow the security
principle of least privilege
when granting permissions - IAM Policy can be assigned to User Groups or User itself with inline-policy
- Follow the security
IAM Policies Structure
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:GenerateCredentialReport",
"iam:GenerateServiceLastAccessedDetails",
"iam:Get*",
"iam:List*",
"iam:SimulateCustomPolicy",
"iam:SimulatePrincipalPolicy"
],
"Resource": "*"
}
]
}
Version
: Policy language version, mostly โ2012-10-17โId
: Identifier for the policy (Optional)Statement
: One or more individual statementsSid
: Identifier for the statement (Optional)Effect
:Allow
orDeny
Principal
: Account/User/Role to which this policy applied toAction
: List of actions this policy allows or deniesResource
: List of resources to which the action applied toCondition
: Conditions for when this policy is in effect (Optional)
IAM Policies ์ข ๋ฅ
- Identity-based policies: IAM Users, IAM User Groups, IAM Roles ์ ์ ์ฉํ๋ Policy
- AWS Managed Policy: AWS ์์ ๊ธฐ๋ณธ์ผ๋ก ์ ๊ณตํ๋ Policy, ์ฌ๋ฌ ๊ณ์ ์์ ๋์ผํ Policy ์ฌ์ฉ ๊ฐ๋ฅ
- AWS Customer Managed Policy: ์ฌ์ฉ์๊ฐ ์์ฑํ Custom Policy, ํด๋น Policy ๊ฐ ์์ฑ๋ ๊ณ์ ๋ง ์ฌ์ฉ ๊ฐ๋ฅ
- AWS Inline Policy: ๋ช ์์ ์ผ๋ก ํ ๋นํ๋ 1๋1 Policy, ๋ณดํต Managed ๋ฅผ ์ฌ์ฉํ๊ธธ ๊ถ์ฅ, ๋ช ์์ ์ผ๋ก ํน์ ์ฌ์ฉ์์๊ฒ ํน์ ๊ถํ์ ๋ถ์ฌํ๊ณ ์ถ์ ๊ฒฝ์ฐ์ ์ฌ์ฉํ๋ฉด ์ ์ฉ
- Resource-based policies: AWS Resource ์ ์ ์ฉํ๋ Policy, ๋ํ์ ์ผ๋ก S3 Bucket Policy ๊ฐ ์์
- Permissions boundaries
- Organizations SCPs
- Access control lists - ACLs
- Session policies
IAM Roles
- IAM Role ์ AWS Services ๋ฅผ ์ํ IAM User ๋ผ๊ณ ์๊ฐํ ์ ์์
- An identity that you can assume to gain
temporary access
to permissions - Ideal for situations in which access to services or resources needs to be granted
temporarily
, instead of long-term - To grant users in one AWS account access to resources in another AWS account
- IAM Users ์ ๊ถํ์ ์ฝ๊ฒ ๊ด๋ฆฌํ๊ธฐ ์ํด IAM User Groups ๋ฅผ ์ฌ์ฉํ๋๋ฐ, ๊ถํ์ด ๋ค์ํด์ง๋ฉด ๊ด๋ฆฌ๊ฐ ๋ณต์กํด์ง๊ณ ์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด IAM Roles ๋ฅผ ์ฌ์ฉ
- User Group ์ ๊ถํ์ ๋ฐ๋ก ๋ถ์ฌํ๋ ๋์ , Role ์ ๋ง๋ค๊ณ User ๋๋ User Group ์ ํ ๋น
- ์์ ์ธ์ ํ ํฐ์ ๋ฐ๊ธํ์ฌ ์ผ์์ ์ธ ๊ถํ์ ์์
IAM Security Tools
IAM Credential Reports (account-level)
- AWS Management Console ์์ IAM โ Credential report โ Download Report
- A report that lists all accountโs users and the status of their various credentials
IAM Access Advisor (user-level)
- AWS Management Console ์์ IAM โ Users โ User ์ ํ โ Access Advisor ํญ
- ์ด๋ค AWS Services ์ ๋ง์ง๋ง์ผ๋ก ์ ๊ทผํ๋์ง ํ์ธ ๊ฐ๋ฅ
- ์ ๊ทผํ์ง ์๋ Resources ๋ ์ ํํ์ฌ
principle of least privilege
๋ฅผ ์งํฌ ์ ์์
- ์ ๊ทผํ์ง ์๋ Resources ๋ ์ ํํ์ฌ
IAM ๊ถํ ๊ฒ์ฆ ์ ์ฐจ
IAM User ๊ฐ S3 ๋ฅผ ์ฌ์ฉํ๊ณ ์ถ์ ๊ฒฝ์ฐ
- IAM User ์๊ฒ S3 ์ฌ์ฉ Policy ๊ฐ ๋ถ์ฌ๋์๋๊ฐ?
- IAM User ๊ฐ ์ํ IAM User Group ์ S3 ์ฌ์ฉ Policy ๊ฐ ๋ถ์ฌ๋์๋๊ฐ?
- IAM User ์๊ฒ ์์๋ Role ์ S3 ์ฌ์ฉ Policy ๊ฐ ๋ถ์ฌ๋์๋๊ฐ?
- OK ๋๋ Fail
Lambda ๊ฐ S3 ๋ฅผ ์ด์ฉํ๊ณ ์ถ์ ๊ฒฝ์ฐ
- Lambda ์ S3 ์ฌ์ฉ Role ์ด ๋ถ์ฌ๋์๋๊ฐ?
- OK ๋๋ Fail
- IAM Access Analyzer
Identifies
whether an Amazon S3 bucket or an IAM role has beenshared
with anexternal entity
such asanother AWS account
- Checks access policies and offers actionable recommendations to help users set secure and functional policies
- IAM Credential Report
- To
audit
its password and access key rotation details forcompliance
purposes
- To
- AWS Security Token Service (STS)
- To request
temporary
,limited-privilege
credentials for users
- To request
IAM Conditions
aws:SourceIp
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"NotIpAddress": {
"aws:SourceIp": [
"192.0.2.0/24",
"203.0.113.0/24"
]
}
}
}
]
}
- Restrict the client IP from which the API calls are being made
aws:RequestedRegion
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:RequestedRegion": [
"eu-central-1",
"eu-west-1"
]
}
}
}
]
}
- Restrict the Region the API calls are made to
ec2:ResourceTag
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/Project": "DataAnalytics"
}
}
}
]
}
- Restrict based on tags
aws:MultiFactorAuthPresent
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"BoolIfExists": {
"aws:MultiFactorAuthPresent": false
}
}
}
]
}
- To force MFA
IAM for S3
s3:ListBucket
permission applies toarn:aws:s3:::test
- Bucket level permission
s3:GetObject
permission applies toarn:aws:s3:::test/*
- Object level permission
Resource Policies & aws:PrincipalOrgID
aws:PrincipalOrgID
can be used in any resource policies to restrict access to accounts that are members of an AWS Organization
IAM Role vs Resource-Based Policies
- In Cross-Account situation
- Resource-Based Policy can be attached to a resource (e.g. S3 bucket policy)
- OR use a Role as a proxy
- When using Assume Role, original permissions will not work
- When using Resource-Based Policy, resource allows given permissions
Amazon EventBridge - Security
- When a rule runs, it needs permissions on the target
- Resource-Based Policy: Lambda, SNS, SQS, CloudWatch Logs, API Gateway, โฆ
- IAM Role: Kinesis Stream, Systems Manager Run Command, ECS task, โฆ
IAM Permission Boundaries
- IAM Permission Boundaries are supported for users and roles (not group)
- Advanced feature to use a managed policy to set the maximum permissions an IAM entity can get
- Can be used in combinations of AWS Org SCP