devHọc Dev
EN
Bài học

Tuần 2 - Ngày 1: AWS Organizations, Multi-Account Patterns và IAM Identity Center

Tuần 2 – Ngày 1

Bài này gộp 3 chủ đề: AWS Organizations, Multi-Account Patterns, IAM Identity Center (AWS SSO).

Mục tiêu học tập

  • Hiểu cách hoạt động của AWS Organizations
  • Nắm vững cấu trúc OU và account hierarchy
  • Biết cách sử dụng Service Control Policies (SCPs)
  • Hiểu các multi-account patterns phổ biến
  • Nắm vững cách thiết kế account structure
  • Biết cross-account access patterns
  • Hiểu cách hoạt động của IAM Identity Center
  • Nắm vững Permission Sets và Account Assignments
  • Biết cách integrate với external identity providers

Phần 1: AWS Organizations

1. Tổng quan AWS Organizations

Định nghĩa

AWS Organizations cho phép quản lý tập trung nhiều AWS accounts, bao gồm:

  • Consolidated billing
  • Hierarchical grouping (OUs)
  • Policy-based management
  • Automated account provisioning

Cấu trúc cơ bản

┌─────────────────────────────────────────────────────────┐│AWSOrganization││┌─────────────────────────────────────────────────┐│││ManagementAccount││││(Root/PayerAccount)│││└───────────────────────┬─────────────────────────┘│││││┌─────────────┴─────────────┐││││││┌────┴────┐┌────┴────┐│││OU││OU││││(Prod)││(Dev)│││└────┬────┘└────┬────┘││││││┌──────┼──────┐┌──────┼──────┐││││││││││┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐│││Acc││Acc││Acc││Acc││Acc││Acc││││1││2││3││4││5││6│││└───┘└───┘└───┘└───┘└───┘└───┘│└─────────────────────────────────────────────────────────┘

2. Organizational Units (OUs)

Best Practice OU Structure

Root├──SecurityOU│├──LogArchiveAccount│└──SecurityToolingAccount├──InfrastructureOU│├──NetworkAccount│└──SharedServicesAccount├──SandboxOU│└──DeveloperSandboxAccounts├──WorkloadsOU│├──ProductionOU││├──App1Production││└──App2Production│└──Non-ProductionOU│├──Development│├──Staging│└──Testing└──SuspendedOU└──DecommissionedAccounts

OU Design Principles

  1. Flat structure: Tránh quá nhiều levels (max 5)
  2. Purpose-based: Nhóm theo mục đích sử dụng
  3. Policy inheritance: SCPs inherit từ parent
  4. Separation of duties: Tách biệt responsibilities

3. Service Control Policies (SCPs)

Cách hoạt động

SCPsđịnhnghĩaMAXIMUMpermissionsavailablechoaccountstrongOU┌─────────────────────────────────────────────┐│PermissionEvaluation││││SCP∩IAMPolicy=EffectivePermissions││││┌─────────────┐┌─────────────┐│││SCP│∩│IAMPolicy││││Allow:A,B,C││Allow:B,C,D│││└─────────────┘└─────────────┘││││││└────────┬────────┘││▼││┌─────────────────┐│││Effective:││││B,C│││└─────────────────┘│└─────────────────────────────────────────────┘

SCP Inheritance

Root(FullAccessSCP)│┌─────────┴─────────┐▼▼ProductionOUDevOU(DenyRiskyActions)(AllowAll)││▼▼AppAccountSandboxAccount(InheritsDeny)(FullAccess)

SCP Strategies

Strategy 1: Deny List (Recommended)

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyLeaveOrg",
      "Effect": "Deny",
      "Action": "organizations:LeaveOrganization",
      "Resource": "*"
    },
    {
      "Sid": "DenyRootUser",
      "Effect": "Deny",
      "Action": "*",
      "Resource": "*",
      "Condition": {
        "StringLike": {
          "aws:PrincipalArn": "arn:aws:iam::*:root"
        }
      }
    }
  ]
}

Strategy 2: Allow List

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ec2:*",
        "s3:*",
        "rds:*"
      ],
      "Resource": "*"
    }
  ]
}

Common SCP Use Cases

Use CaseSCP Action
Prevent leaving organizationDeny organizations:LeaveOrganization
Restrict regionsDeny all actions in non-approved regions
Prevent root user usageDeny * with root principal
Require encryptionDeny if encryption disabled
Prevent public S3Deny s3:PutBucketPublicAccessBlock

Example: Region Restriction SCP

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyNonApprovedRegions",
      "Effect": "Deny",
      "NotAction": [
        "cloudfront:*",
        "iam:*",
        "route53:*",
        "support:*"
      ],
      "Resource": "*",
      "Condition": {
        "StringNotEquals": {
          "aws:RequestedRegion": [
            "ap-southeast-1",
            "us-east-1"
          ]
        }
      }
    }
  ]
}

Resource Control Policies (RCPs) — ra mắt 11/2024

SCP trả lời câu hỏi "principal trong org được làm gì?". RCP trả lời câu hỏi ngược lại: "resource trong org được phép cấp quyền cho ai?". RCP là công cụ chính để dựng data perimeter ở quy mô org — ví dụ chặn mọi S3 bucket trong tất cả member account bị chia sẻ cho principal ngoài org, dù bucket policy do team nào viết.

SCPRCP
Boundary choPrincipal (IAM user/role) trong member accountResource (bucket, key, queue...) trong member account
Tác động lên principal ngoài orgKhôngCó — áp dụng khi principal ngoài org gọi vào resource trong org
Grant quyền?KhôngKhông
Mặc địnhFullAWSAccessRCPFullAWSAccess
Ảnh hưởng Management AccountKhôngKhông
Giới hạn10 SCP/entity, 10,240 ký tự (nâng từ 5 / 5,120 vào 05/2026)5 RCP/entity, 5,120 ký tự (RCPFullAWSAccess tính vào quota, không detach được)
Service hỗ trợTất cảDanh sách giới hạn, mở rộng dần: S3, STS, KMS, SQS, Secrets Manager (lúc ra mắt), sau đó thêm dịch vụ khác

Mẫu RCP kinh điển — chỉ cho principal trong org (hoặc AWS service) truy cập resource:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "EnforceOrgIdentities",
      "Effect": "Deny",
      "Principal": "*",
      "Action": ["s3:*", "sqs:*", "kms:*", "secretsmanager:*", "sts:AssumeRole"],
      "Resource": "*",
      "Condition": {
        "StringNotEqualsIfExists": {
          "aws:PrincipalOrgID": "o-xxxxxxxxxx"
        },
        "BoolIfExists": {
          "aws:PrincipalIsAWSService": "false"
        }
      }
    }
  ]
}

Điểm thi hay gặp:

  • "Prevent resources from being shared with identities outside the organization" → RCP (không phải SCP, vì SCP không áp cho principal ngoài org).
  • "Prevent identities in the organization from accessing resources outside the organization" → SCP với aws:ResourceOrgID.
  • RCP + SCP + VPC endpoint policy = ba cạnh của data perimeter (identity, resource, network).
  • RCP có Principal trong statement (giống resource policy); SCP thì không.
  • RCP do bạn tạo chỉ được dùng Effect: Deny; Allow chỉ tồn tại trong RCPFullAWSAccess mặc định. Action phải ghi rõ theo service (s3:*, kms:*...), không dùng "*" cho toàn bộ.
  • RCP không áp cho service-linked role và AWS managed KMS key — đề hỏi "why does the service-linked role still work" thì đây là lý do.

Declarative Policies — ra mắt 12/2024

Declarative policy khai báo cấu hình mặc định của service cho toàn org/OU và được service enforce ở tầng API, không cần viết IAM/SCP deny phức tạp. Hiện hỗ trợ EC2 và các service liên quan:

Thuộc tínhÝ nghĩa
ec2_attributes.allowed_images_settingsChỉ cho launch từ AMI của tài khoản/đối tác được phép (Allowed AMIs)
ec2_attributes.image_block_public_accessChặn AMI public
ec2_attributes.snapshot_block_public_accessChặn EBS snapshot public
ec2_attributes.instance_metadata_defaultsMặc định IMDSv2 required
ec2_attributes.serial_console_accessTắt serial console
ec2_attributes.vpc_block_public_accessChặn internet gateway ingress/egress cho toàn VPC

Khác SCP: SCP chặn API call, declarative policy đặt trạng thái cấu hình và có account status report để xem account nào chưa tuân thủ. Keyword đề: "enforce IMDSv2 / block public AMI across all accounts with least operational overhead" → declarative policy.

4. Consolidated Billing

How it works

┌─────────────────────────────────────────────────────────┐│ManagementAccount(Payer)││││Receivesconsolidatedbillforallmemberaccounts││││┌─────────┐┌─────────┐┌─────────┐┌─────────┐│││AccA││AccB││AccC││AccD││││$100││$200││$150││$50│││└─────────┘└─────────┘└─────────┘└─────────┘││││TotalBill:$500││+Volumediscountsappliedacrossallaccounts│└─────────────────────────────────────────────────────────┘

Benefits

  1. Volume discounts: Usage aggregated across accounts
  2. Reserved Instance sharing: RIs apply across organization
  3. Savings Plans sharing: SPs apply across organization
  4. Single payment method: One bill, one payment

5. Organization Features

All Features vs Consolidated Billing Only

FeatureAll FeaturesBilling Only
Consolidated billing✓✓
SCPs✓✗
Resource control policies (RCPs)✓✗
Declarative policies✓✗
Tag policies✓✗
Backup policies✓✗
AI services opt-out✓✗
Service access✓✗

Delegated Administrator

ManagementAccount││Delegate▼┌─────────────────────────────────────┐│SecurityAccount││(DelegatedAdminfor)││-GuardDuty││-SecurityHub││-Config││-FirewallManager│└─────────────────────────────────────┘→ReduceaccesstoManagementAccount→Securityteammanagessecurityservices

6. AWS Control Tower

Relationship with Organizations

┌─────────────────────────────────────────────────────────┐│AWSControlTower││(OrchestrationLayer)││││┌─────────────────────────────────────────────────┐│││AWSOrganizations││││(Foundation)│││└─────────────────────────────────────────────────┘││││Features:││-LandingZonesetup││-Controls(preventive+detective+proactive)││-AccountFactory││-Dashboard│└─────────────────────────────────────────────────────────┘

7. CloudTrail Organizational Trail

Khái niệm

Organizational trail là CloudTrail trail được tạo từ management account (hoặc từ delegated administrator cho CloudTrail) và tự động áp dụng cho MỌI member account trong Organization — kể cả account được tạo/join sau này.

Đặc điểm quan trọng (hay ra thi)

  • Tạo 1 lần, phủ toàn org: không cần vào từng account tạo trail riêng — giảm operational overhead.
  • Member account KHÔNG thể can thiệp: member account thấy organizational trail (read-only) trong console/API của mình nhưng không thể tắt (StopLogging), sửa, hay xoá trail đó. Đây chính là cơ chế chống tampering — kể cả admin của member account cũng không tắt được audit log.
  • Log tập trung 1 nơi: toàn bộ events từ mọi account ghi về một S3 bucket duy nhất ở account trung tâm, phân theo prefix AWSLogs/<org-id>/<account-id>/....
  • New account tự động được cover: account mới join org → trail apply ngay, không cần thao tác thêm.

Kiến trúc log tập trung

┌──────────────────────────────────────────────────────────────┐│AWSOrganization││││ManagementAccount────tạoOrganizationalTrail││(hoặcDelegatedAdmin)││││applytựđộng││┌──────────────┬───────┴──────┬──────────────┐││▼▼▼▼││┌─────────┐┌─────────┐┌─────────┐┌────────┐│││AccA││AccB││AccC││AccN││││(trail││(trail││(trail││(trail││││visible,││read-││KHÔNG││KHÔNG││││noedit)││only)││tắtđược││xoáđược│││└────┬────┘└────┬────┘└────┬────┘└───┬────┘││││││││└──────────────┴──────┬───────┴─────────────┘││▼││┌───────────────────────────┐│││LogArchiveAccount││││S3bucket(central)││││AWSLogs/o-xxxx/<acct>/│││└───────────────────────────┘│└──────────────────────────────────────────────────────────────┘

Bucket policy cho central S3 bucket

S3 bucket ở account trung tâm phải có bucket policy cho phép service principal cloudtrail.amazonaws.com ghi log, giới hạn theo ARN của org trail bằng aws:SourceArn (chống confused deputy):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AWSCloudTrailWrite",
      "Effect": "Allow",
      "Principal": {"Service": "cloudtrail.amazonaws.com"},
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::central-audit-logs/AWSLogs/*",
      "Condition": {
        "StringEquals": {
          "s3:x-amz-acl": "bucket-owner-full-control",
          "aws:SourceArn": "arn:aws:cloudtrail:ap-southeast-1:111111111111:trail/org-trail"
        }
      }
    }
  ]
}

Best practice

  • Log về S3 bucket trong Log Archive account riêng (không phải management account) — tách quyền truy cập log khỏi quyền quản trị org. AWS Control Tower làm chính xác điều này khi setup landing zone: tự tạo organizational trail ghi vào Log Archive account.
  • Bật log file validation + S3 Object Lock/versioning để tăng tính bất biến của audit trail.
  • Delegate quản trị CloudTrail cho security account (delegated administrator) để giảm việc dùng management account.

Exam keyword: "centralize audit logs across all accounts in the organization" + "prevent member accounts from tampering/disabling logging" → CloudTrail organizational trail (không phải tạo trail từng account + SCP thủ công).

8. aws:PrincipalOrgID trong Resource Policy

Vấn đề

Muốn cho tất cả accounts trong Organization truy cập một resource (S3 bucket, SQS queue, SNS topic, KMS key, Secrets Manager secret, Lambda, VPC endpoint policy...) — nếu liệt kê từng account ID trong resource policy thì policy phình to, và phải cập nhật mỗi khi thêm/bớt account.

Giải pháp: condition key aws:PrincipalOrgID

Global condition key so sánh Organization ID của principal đang gọi với giá trị chỉ định. Chỉ cần một condition, mọi principal (IAM user/role) thuộc bất kỳ account nào trong org đều match — account mới join org tự động có quyền, account rời org tự động mất quyền.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowOrgWideAccess",
      "Effect": "Allow",
      "Principal": "*",
      "Action": ["s3:GetObject", "s3:ListBucket"],
      "Resource": [
        "arn:aws:s3:::shared-artifacts",
        "arn:aws:s3:::shared-artifacts/*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:PrincipalOrgID": "o-a1b2c3d4e5"
        }
      }
    }
  ]
}

Lưu ý: "Principal": "*" kết hợp condition aws:PrincipalOrgID không phải là public — chỉ principals đã authenticated thuộc org mới thoả condition (anonymous access không có org ID nên bị loại).

aws:PrincipalOrgPaths — giới hạn theo OU

Khi chỉ muốn cho phép accounts trong một OU cụ thể (không phải cả org), dùng aws:PrincipalOrgPaths với đường dẫn OU:

{
  "Condition": {
    "ForAnyValue:StringLike": {
      "aws:PrincipalOrgPaths": "o-a1b2c3d4e5/r-ab12/ou-ab12-11111111/*"
    }
  }
}
  • Path có dạng <org-id>/<root-id>/<ou-id>/...; wildcard * ở cuối bao gồm cả sub-OU bên dưới.
  • Là multivalued key → phải dùng set operator ForAnyValue/ForAllValues.

So sánh nhanh

Condition keyPhạm viUse case
aws:PrincipalOrgIDToàn bộ organizationShare resource cho mọi account trong org
aws:PrincipalOrgPathsMột OU (và sub-OU) cụ thểChỉ Production OU được truy cập
aws:PrincipalAccountMột accountGrant cho account đơn lẻ

Exam keyword: "grant access to all accounts in the organization" / "without listing/maintaining individual account IDs" → resource policy với aws:PrincipalOrgID. Nếu đề bài giới hạn "only accounts in the Production OU" → aws:PrincipalOrgPaths.

Phần 2: Multi-Account Patterns

1. Tại sao cần Multi-Account?

Single Account Problems

SingleAccount:┌─────────────────────────────────────────────┐│Account││┌─────────┐┌─────────┐┌─────────┐│││Dev││Test││Prod│││└─────────┘└─────────┘└─────────┘││││Problems:││-Blastradius(mistakeaffectsall)││-Permissioncomplexity││-Resourcelimitsshared││-Billingnotseparated││-Compliancechallenges│└─────────────────────────────────────────────┘

Benefits of Multi-Account

Multi-Account:┌───────────┐┌───────────┐┌───────────┐│Dev││Test││Prod││Account││Account││Account│└───────────┘└───────────┘└───────────┘│││└─────────────┴─────────────┘│┌──────────────┴──────────────┐│SecurityAccount││(Centralizedlogging)│└─────────────────────────────┘Benefits:✓Workloadisolation✓Clearsecurityboundaries✓Separatebilling✓Independentservicelimits✓Simplifiedcompliance

2. Common Account Patterns

Pattern 1: Environment-based

┌─────────────────────────────────────────────┐│Organization││││┌─────────────────────────────────────┐│││WorkloadsOU││││┌─────────┐┌─────────┐┌───────┐│││││Dev││Stage││Prod││││││Account││Account││Account│││││└─────────┘└─────────┘└───────┘│││└─────────────────────────────────────┘│└─────────────────────────────────────────────┘Usecase:Simpleapplications,smallteams

Pattern 2: Team-based

┌─────────────────────────────────────────────┐│Organization││││┌──────────────┐┌──────────────┐│││TeamAOU││TeamBOU││││┌───┐┌───┐││┌───┐┌───┐│││││Dev││Prd││││Dev││Prd│││││└───┘└───┘││└───┘└───┘│││└──────────────┘└──────────────┘│└─────────────────────────────────────────────┘Usecase:Autonomousteams,microservices

Pattern 3: Application-based

┌─────────────────────────────────────────────┐│Organization││││┌────────────┐┌────────────┐│││App1OU││App2OU││││┌────────┐││┌────────┐│││││Dev│Prd││││Dev│Prd│││││└────────┘││└────────┘│││└────────────┘└────────────┘│└─────────────────────────────────────────────┘Usecase:Multipleproducts,differentcompliance

3. AWS Landing Zone Pattern

Root│├──ManagementAccount(root/payer—luônnằmởRoot,│khôngthểmovevàoOU)│├──CoreOU│├──LogArchiveAccount││└──Centralizedlogs(CloudTrail,Config,etc.)│├──SecurityAccount││└──Securitytools(GuardDuty,SecurityHub)│└──AuditAccount│└──Read-onlyaccessforauditors│├──InfrastructureOU│├──NetworkAccount││└──TransitGateway,DirectConnect│└──SharedServicesAccount│└──AD,DNS,CI/CDtools│├──SandboxOU│└──Developerexperimentationaccounts│├──WorkloadsOU│├──ProductionOU││└──Productionaccounts│└──Non-ProductionOU│└──Dev,Test,Stagingaccounts│└──SuspendedOU└──Accountspendingdeletion

4. Cross-Account Access

┌─────────────────┐┌─────────────────┐│AccountA││AccountB││(Source)││(Target)││││││┌───────────┐│Assume│┌───────────┐│││IAMUser││──────────►││IAMRole││││orRole││Role│││││└───────────┘││└───────────┘││││││Needs:││Needs:││sts:AssumeRole││TrustPolicy││permission││allowingAccA│└─────────────────┘└─────────────────┘

Trust Policy (Account B):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::111111111111:root"
      },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": {
          "sts:ExternalId": "unique-external-id"
        }
      }
    }
  ]
}

Method 2: Resource-based Policies

┌─────────────────┐┌─────────────────┐│AccountA││AccountB││││││┌───────────┐│Direct│┌───────────┐│││IAMUser││──────────►││S3Bucket││││││Access│││││└───────────┘││└───────────┘││││││Needs:││Needs:││s3:GetObject││BucketPolicy││permission││allowingAccA│└─────────────────┘└─────────────────┘

Bucket Policy (Account B):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::111111111111:user/username"
      },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::bucket-name/*"
    }
  ]
}

When to use which?

ScenarioMethod
Access multiple resourcesIAM Role
Temporary accessIAM Role
Single resource accessResource Policy
S3, SQS, SNS, KMSEither
Audit requirementsIAM Role (better audit)

5. Centralized Services Pattern

Centralized Logging

┌─────────────────────────────────────────────────────────┐│LogArchiveAccount││││┌─────────────────────────────────────────────────┐│││S3Bucket(Logs)││││││││CloudTrail←Allaccounts││││Config←Allaccounts││││VPCFlows←Allaccounts││││CloudWatch←Allaccounts│││└─────────────────────────────────────────────────┘││││Features:││-Bucketpolicypreventsdeletion││-S3ObjectLockforcompliance││-Lifecyclepoliciesforcostoptimization│└─────────────────────────────────────────────────────────┘

Centralized Security

┌─────────────────────────────────────────────────────────┐│SecurityAccount││(DelegatedAdmin)││││┌──────────┐┌──────────┐┌──────────┐┌──────────┐│││GuardDuty││Security││Config││Inspector││││Admin││Hub││Aggregator││Admin│││└──────────┘└──────────┘└──────────┘└──────────┘││││││││└────────────┴────────────┴────────────┘│││││Aggregatesfindingsfrom││allmemberaccounts│└─────────────────────────────────────────────────────────┘

Centralized Network

┌─────────────────────────────────────────────────────────┐│NetworkAccount││││┌─────────────────────────────────────────────────┐│││TransitGateway│││││││││┌──────────────┼──────────────┐│││││││││││▼▼▼││││VPCAVPCBVPCC││││(Acc1)(Acc2)(Acc3)│││└─────────────────────────────────────────────────┘││││Alsocontains:││-DirectConnectGateway││-VPNconnections││-DNS(Route53Resolver)│└─────────────────────────────────────────────────────────┘

6. Account Vending

AWS Service Catalog

AccountRequest→ServiceCatalog→CloudFormation│▼┌─────────────────────┐│NewAccount││││-StandardVPC││-IAMRoles││-SecurityConfig││-Loggingenabled│└─────────────────────┘

AWS Control Tower Account Factory

┌─────────────────┐│ControlTower││AccountFactory│└────────┬────────┘│┌──────────────┼──────────────┐│││▼▼▼┌──────────┐┌──────────┐┌──────────┐│Apply││Create││Apply││Controls││Account││Baseline│└──────────┘└──────────┘└──────────┘

Phần 3: IAM Identity Center (AWS SSO)

1. Tổng quan IAM Identity Center

Định nghĩa

IAM Identity Center (trước đây là AWS SSO) cung cấp:

  • Single sign-on cho nhiều AWS accounts
  • Centralized access management
  • Integration với external IdPs
  • Temporary credentials (không có long-term keys)

Architecture

┌─────────────────────────────────────────────────────────┐│IAMIdentityCenter││││┌─────────────────┐┌─────────────────────────────┐│││IdentitySource││PermissionSets││││││││││-Built-in││┌──────────────────────┐││││-ADConnector│││AdminAccess│││││-AWSManagedAD│││ViewOnlyAccess│││││-ExternalIdP│││DatabaseAdmin│││││(Okta,Azure)│││CustomPermissions││││└─────────────────┘│└──────────────────────┘│││└─────────────────────────────┘│││││┌──────────────┴──────────────┐││▼▼▼││┌──────────┐┌──────────┐┌──────────┐│││Account1││Account2││Account3│││└──────────┘└──────────┘└──────────┘│└─────────────────────────────────────────────────────────┘

2. Identity Sources

Option 1: Built-in Identity Store

Pros:
- Simplest setup
- No additional cost
- Built-in MFA

Cons:
- Separate user management
- No sync with corporate directory

Use case: Small organizations without existing IdP

Option 2: AWS Managed Microsoft AD

┌─────────────────────────────────────────────┐│AWSManagedAD││││┌─────────────┐┌─────────────┐│││Domain││Domain││││Controller││Controller││││(AZ1)││(AZ2)│││└─────────────┘└─────────────┘││││││└────────┬─────────┘│││││ADTrustwithon-prem│└─────────────────────────────────────────────┘Usecase:ExistingADenvironment,needADfeatures

Option 3: External Identity Provider (SAML 2.0)

┌─────────────────┐┌─────────────────┐│ExternalIdP│SAML│IAMIdentity││(Okta,Azure│───────►│Center││AD,Ping)│││└─────────────────┘└─────────────────┘Benefits:-Singlesourceoftruth-LeverageexistingIdPinvestment-ConsistentuserexperienceUsecase:EnterprisewithexistingIdP

Comparison

FeatureBuilt-inManaged ADExternal IdP
Setup complexityLowMediumMedium
User managementManualAD toolsIdP tools
Corporate syncNoYes (trust)Yes (SCIM)
MFABuilt-inAD MFAIdP MFA
CostFreeAD costIdP cost

3. Permission Sets

Định nghĩa

Permission Sets là collection of policies định nghĩa quyền access vào AWS accounts.

Types

1. AWS Managed Policies
   - AdministratorAccess
   - ViewOnlyAccess
   - Billing
   - PowerUserAccess

2. Customer Managed Policies
   - Custom policies bạn tạo

3. Inline Policies
   - Policies attached trực tiếp vào permission set

Permission Set Structure

{
  "PermissionSet": {
    "Name": "DatabaseAdmin",
    "Description": "Full access to RDS and DynamoDB",
    "SessionDuration": "PT4H",
    "ManagedPolicies": [
      "arn:aws:iam::aws:policy/AmazonRDSFullAccess",
      "arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess"
    ],
    "InlinePolicy": {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Deny",
          "Action": "rds:DeleteDBInstance",
          "Resource": "*",
          "Condition": {
            "StringNotEquals": {
              "aws:ResourceTag/Environment": "dev"
            }
          }
        }
      ]
    },
    "PermissionsBoundary": {
      "ManagedPolicyArn": "arn:aws:iam::aws:policy/boundary-policy"
    }
  }
}

Permission Set Best Practices

  1. Least privilege: Chỉ cấp quyền cần thiết
  2. Separation of duties: Tách biệt responsibilities
  3. Use managed policies: Dễ maintain
  4. Permission boundaries: Giới hạn maximum permissions
  5. Session duration: Set appropriate timeout

4. Account Assignments

How it works

┌──────────────────────────────────────────────────────┐│AccountAssignment││││User/Group+PermissionSet+Account=Access││││┌─────────┐┌──────────────┐┌─────────┐│││John│+│AdminAccess│+│Prod│=✓│││Doe││││Account│││└─────────┘└──────────────┘└─────────┘││││┌─────────┐┌──────────────┐┌─────────┐│││DevTeam│+│PowerUser│+│Dev│=✓│││Group││Access││Account│││└─────────┘└──────────────┘└─────────┘│└──────────────────────────────────────────────────────┘

Assignment Matrix Example

PermissionSetsAdmin│PowerUser│ReadOnlyAccount─────────────────────────────Production✓✓(SecurityTeam)✓(AuditTeam)Staging✓✓(PlatformTeam)✓(DevTeam)Development✓✓(Everyone)

5. Temporary Credentials Flow

User Login Flow

1.UseraccessesSSOportal│▼2.AuthenticatewithIdP(username/password+MFA)│▼3.SelectAWSaccount│▼4.SelectPermissionSet│▼5.Gettemporarycredentials(viaSTSAssumeRole)│▼6.AccessAWSConsoleorCLI

CLI Access

# Configure SSO
aws configure sso
# → Enter SSO start URL
# → Enter SSO Region
# → Browser opens for authentication
# → Select account and role

# Use profile
aws s3 ls --profile my-sso-profile

# Or set default
export AWS_PROFILE=my-sso-profile
aws s3 ls

6. ABAC with IAM Identity Center

Attribute-Based Access Control

UserAttributes(fromIdP):-Department:Engineering-CostCenter:CC-123-Project:ProjectASessionTags:┌───────────────────────────────────────────┐│aws:PrincipalTag/Department=Engineering││aws:PrincipalTag/CostCenter=CC-123││aws:PrincipalTag/Project=ProjectA│└───────────────────────────────────────────┘Policyusingtags:{"Effect":"Allow","Action":"ec2:*","Resource":"*","Condition":{"StringEquals":{"ec2:ResourceTag/Project":"${aws:PrincipalTag/Project}"}}}

7. Multi-Account Permissions

Delegated Administration

ManagementAccount││Delegateto▼┌─────────────────────────────────────┐│IAMIdentityCenterAdmin││(DelegatedAdministrator)││││Canmanage:││-UsersandGroups││-PermissionSets││-AccountAssignments│└─────────────────────────────────────┘Benefit:ReduceaccesstoManagementAccount

8. Integration Patterns

Pattern 1: Okta Integration

Okta(IdP)││SAML2.0│SCIM(UserProvisioning)│▼IAMIdentityCenter││AssumeRole│▼AWSAccounts

Pattern 2: Azure AD Integration

AzureAD(IdP)││SAML2.0│SCIM│▼IAMIdentityCenter│▼AWSAccounts+AzureADConditionalAccess+AzureMFA

Câu hỏi ôn tập

  1. Management Account có bị ảnh hưởng bởi SCPs không?

    Xem đáp án

    Không — Management account không bị SCPs apply, kể cả SCP ở root OU. Best practice: không deploy workloads trong management account. Chỉ dùng management account cho organization management, billing, Control Tower. Tất cả workloads nên ở member accounts — chịu SCP governance.

  2. SCP inheritance hoạt động như thế nào?

    Xem đáp án

    SCPs áp dụng hierarchically: Root → OU → Sub-OU → Account. Account phải có SCP allow ở tất cả các level cha để action được phép. Ví dụ: Root SCP deny us-west-2 → tất cả accounts kể cả trong OU con đều không dùng us-west-2 được. OU SCP restrict thêm trong phạm vi Root SCP đã cho phép. Không thể dùng OU SCP để "unblock" những gì Root SCP đã block.

  3. Deny List vs Allow List SCP strategy, cái nào được recommend?

    Xem đáp án

    AWS recommend Deny List (default allow all, explicitly deny specific). Lý do: easier to start — mặc định tất cả permissions available, chỉ thêm Deny khi cần restrict (ví dụ: deny region access, deny specific services). Allow List (default deny all, explicitly allow everything needed) phức tạp hơn, rủi ro block unexpected services, maintenance overhead cao. Deny List phổ biến hơn trong production Organizations.

  4. Reserved Instances có thể share across organization không?

    Xem đáp án

    Có — với consolidated billing, RI và Savings Plans của một account trong Organization tự động apply (discount) sang accounts khác nếu account đó có matching usage và RI không được dùng hết. Có thể disable sharing per account nếu muốn (RI credit sharing settings trong Billing). Đây là lý do consolidated billing tiết kiệm: unused RIs không "wasted" mà benefit entire org.

  5. Delegated Administrator dùng để làm gì?

    Xem đáp án

    Cho phép một member account quản lý một AWS service cho toàn bộ Organization (thay vì phải làm từ management account). Ví dụ: delegate GuardDuty admin đến Security account, delegate Config admin đến Audit account, delegate IAM Identity Center admin đến dedicated SSO account. Giảm need access management account, tách concerns — security team manage từ security account riêng.

  6. Công ty cần centralize CloudTrail logs của 50 accounts và đảm bảo admin của member account không thể tắt logging. Giải pháp nào ít operational overhead nhất?

    Xem đáp án

    CloudTrail organizational trail tạo từ management account (hoặc delegated administrator), log về S3 bucket ở Log Archive account. Trail tự động apply cho mọi member account (kể cả account mới join); member account thấy trail nhưng không thể StopLogging/sửa/xoá. So với phương án tạo trail từng account + SCP deny cloudtrail:StopLogging: organizational trail ít overhead hơn (1 trail duy nhất, không phải maintain 50 trails + SCP), và chống tampering là built-in chứ không phụ thuộc SCP viết đúng.

  7. Làm sao cho phép tất cả accounts trong Organization đọc một S3 bucket mà không phải liệt kê từng account ID?

    Xem đáp án

    Dùng bucket policy với condition aws:PrincipalOrgID: "Condition": {"StringEquals": {"aws:PrincipalOrgID": "o-xxxx"}} kèm "Principal": "*". Chỉ principals authenticated thuộc org thoả condition (không phải public); account mới join org tự động có quyền, account rời org tự động mất — không cần maintain danh sách account IDs. Nếu chỉ muốn giới hạn theo một OU cụ thể → dùng aws:PrincipalOrgPaths (multivalued key, cần ForAnyValue:StringLike) với path o-xxxx/r-xxxx/ou-xxxx/*.

  8. 3 common multi-account patterns là gì?

    Xem đáp án

    (1) Environment separation: Prod, Dev, Test, Staging trong separate accounts — blast radius isolation, different IAM policies per environment. (2) Workload/team separation: mỗi team hay product trong account riêng — ownership clarity, independent billing, IAM isolation. (3) Security/Shared services: dedicated accounts cho Log Archive, Security/Audit, Network Hub, Shared Services (CI/CD, monitoring). Thường kết hợp cả 3 patterns.

  9. Cross-account access bằng IAM Role cần gì ở cả 2 phía?

    Xem đáp án

    Account A (có role được assume): Role trust policy allow principal từ Account B assume role (sts:AssumeRole). Account B (muốn assume role): Identity có IAM policy với sts:AssumeRole permission trên role ARN của Account A. Cả hai điều kiện phải thỏa mãn — không thể bypass. Optionally: External ID trong trust policy cho additional security với 3rd-party vendors.

  10. Log Archive Account nên chứa những gì?

Xem đáp án

Tất cả audit/compliance logs: CloudTrail (Organization Trail ghi logs của mọi account), CloudWatch Logs (centralized), Config snapshots, S3 Access Logs, ALB Access Logs. Policies: S3 bucket policy chỉ cho phép append (không delete), Vault Lock trên AWS Backup, MFA delete trên S3 bucket. Access: chỉ Security/Compliance team có read access. Member accounts chỉ có write, không có delete.

  1. Network Account thường manage những services nào?
Xem đáp án

Transit Gateway (hub routing giữa VPCs và on-premises), Direct Connect connections, AWS Network Firewall, Route 53 Resolver (central DNS), VPC Sharing (share subnets từ centralized VPC đến member accounts), NAT Gateways (centralized egress). Centralized networking giảm cost (không cần mỗi account có DX riêng), tăng visibility và control traffic flow.

  1. Account vending machine hoạt động như thế nào?
Xem đáp án

Account Factory (trong Control Tower) tự động tạo accounts với: pre-configured controls (tên cũ: guardrails), SSO access, baseline VPC, logging setup. Process: team fill form → Account Factory trigger Service Catalog → tạo AWS account mới → apply SCPs, baselines, SSO configuration → notify requester. Account ready to use trong phút thay vì days của manual process. Customizable với Account Factory Customization (hooks).

  1. Identity Source có những options nào?
Xem đáp án

3 options: (1) IAM Identity Center directory (built-in, tạo/manage users trong Identity Center), (2) Active Directory (AWS Managed Microsoft AD hoặc AD Connector cho on-premises AD), (3) External IdP (Okta, Azure AD, OneLogin, Google Workspace) qua SAML 2.0. Chỉ chọn được 1 identity source tại một thời điểm. Thay đổi identity source yêu cầu reassign account assignments.

  1. Permission Set là gì và chứa những gì?
Xem đáp án

Permission Set là template định nghĩa permissions sẽ được assign cho user/group khi access một account. Chứa: AWS managed policies (ví dụ ReadOnlyAccess, AdministratorAccess), Customer managed policies, Inline policy, và Permission Boundary. Khi user access account qua IAM Identity Center portal, Permission Set tạo ra IAM Role tạm thời trong account đó với permissions được define.

  1. Account Assignment hoạt động như thế nào?
Xem đáp án

Account Assignment là mapping: User/Group → Permission Set → AWS Account. Ví dụ: Group "Developers" có Permission Set "DevAccess" assigned vào Account "Dev-123". Khi Developer login vào Identity Center portal, họ thấy Dev-123 trong danh sách accounts và có thể assume DevAccess role. IAM Identity Center tạo và maintain IAM Roles trong target accounts tự động dựa trên assignments.

  1. ABAC với IAM Identity Center là gì?
Xem đáp án

Attribute-Based Access Control — dùng user attributes (từ Identity Source: department, title, team) như tags để control access. Ví dụ: user có attribute Department=Finance được assign vào accounts có tag Department=Finance. Ít phải manage individual assignments — thêm user vào đúng group với đúng attribute → access tự động granted. Đặc biệt mạnh khi user directory sync với AD/Okta (attributes tự populate).

  1. Delegated Administrator dùng để làm gì?
Xem đáp án

Cho phép delegate administration của IAM Identity Center từ management account sang một member account (thường là Security/Identity account). Administrators trong member account đó có thể manage users, groups, permission sets, và account assignments cho toàn Organization — không cần access management account. Best practice cho separation of duties: management account credentials minimal, Identity admin team work từ dedicated account.

Bài tập thực hành

Phần 1: AWS Organizations

  • Tạo AWS Organization với 2 OUs
  • Tạo SCP deny specific region
  • Setup consolidated billing view
  • Explore Control Tower landing zone

Phần 2: Multi-Account Patterns

  • Thiết kế multi-account structure cho công ty fictitious
  • Setup cross-account role
  • Configure centralized CloudTrail
  • Explore Control Tower Account Factory

Phần 3: IAM Identity Center (AWS SSO)

  • Enable IAM Identity Center
  • Create permission sets
  • Create user và assign to accounts
  • Test CLI access với SSO

Tài liệu tham khảo


Bài tiếp theo →