</>Học Dev
Bài học

Tuần 3 - Ngày 1: AWS Organizations

Tuần 3 – Ngày 1

Tuần 3 - Ngày 1: AWS Organizations

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)

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

AWSOrganizationManagementAccount(Root/PayerAccount)OUOU(Prod)(Dev)AccAccAccAccAccAcc123456

2. Organizational Units (OUs)

Best Practice OU Structure

RootSecurityOULogArchiveAccountSecurityToolingAccountInfrastructureOUNetworkAccountSharedServicesAccountSandboxOUDeveloperSandboxAccountsWorkloadsOUProductionOUApp1ProductionApp2ProductionNon-ProductionOUDevelopmentStagingTestingSuspendedOUDecommissionedAccounts

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ĩaMAXIMUMpermissionsavailablechoaccountstrongOUPermissionEvaluationSCPIAMPolicy=EffectivePermissionsSCPIAMPolicyAllow:A,B,CAllow:B,C,DEffective: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"
          ]
        }
      }
    }
  ]
}

4. Consolidated Billing

How it works

ManagementAccount(Payer)ReceivesconsolidatedbillforallmemberaccountsAccAAccBAccCAccD$100$200$150$50TotalBill:$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
Tag policies
Backup policies
AI services opt-out
Service access

Delegated Administrator

ManagementAccountDelegateSecurityAccount(DelegatedAdminfor)-GuardDuty-SecurityHub-Config-FirewallManagerReduceaccesstoManagementAccountSecurityteammanagessecurityservices

6. AWS Control Tower

Relationship with Organizations

AWSControlTower(OrchestrationLayer)AWSOrganizations(Foundation)Features:-LandingZonesetup-Guardrails(preventive+detective)-AccountFactory-Dashboard

7. 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

    — 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.

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

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

Tài liệu tham khảo chính thức


Ngày tiếp theo: Multi-Account Patterns