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

Tuần 3 - Ngày 2: Multi-Account Patterns

Tuần 3 – Ngày 2

Tuần 3 - Ngày 2: Multi-Account Patterns

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

  • 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

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

Single Account Problems

SingleAccount:AccountDevTestProdProblems:-Blastradius(mistakeaffectsall)-Permissioncomplexity-Resourcelimitsshared-Billingnotseparated-Compliancechallenges

Benefits of Multi-Account

Multi-Account:DevTestProdAccountAccountAccountSecurityAccount(Centralizedlogging)Benefits:WorkloadisolationClearsecurityboundariesSeparatebillingIndependentservicelimitsSimplifiedcompliance

2. Common Account Patterns

Pattern 1: Environment-based

OrganizationWorkloadsOUDevStageProdAccountAccountAccountUsecase:Simpleapplications,smallteams

Pattern 2: Team-based

OrganizationTeamAOUTeamBOUDevPrdDevPrdUsecase:Autonomousteams,microservices

Pattern 3: Application-based

OrganizationApp1OUApp2OUDevPrdDevPrdUsecase:Multipleproducts,differentcompliance

3. AWS Landing Zone Pattern

RootCoreOUManagementAccount(root/payer)LogArchiveAccountCentralizedlogs(CloudTrail,Config,etc.)SecurityAccountSecuritytools(GuardDuty,SecurityHub)AuditAccountRead-onlyaccessforauditorsInfrastructureOUNetworkAccountTransitGateway,DirectConnectSharedServicesAccountAD,DNS,CI/CDtoolsSandboxOUDeveloperexperimentationaccountsWorkloadsOUProductionOUProductionaccountsNon-ProductionOUDev,Test,StagingaccountsSuspendedOUAccountspendingdeletion

4. Cross-Account Access

AccountAAccountB(Source)(Target)AssumeIAMUserIAMRoleorRoleRoleNeeds:Needs:sts:AssumeRoleTrustPolicypermissionallowingAccA

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

AccountAAccountBDirectIAMUserS3BucketAccessNeeds:Needs:s3:GetObjectBucketPolicypermissionallowingAccA

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

LogArchiveAccountS3Bucket(Logs)CloudTrailAllaccountsConfigAllaccountsVPCFlowsAllaccountsCloudWatchAllaccountsFeatures:-Bucketpolicypreventsdeletion-S3ObjectLockforcompliance-Lifecyclepoliciesforcostoptimization

Centralized Security

SecurityAccount(DelegatedAdmin)GuardDutySecurityConfigInspectorAdminHubAggregatorAdminAggregatesfindingsfromallmemberaccounts

Centralized Network

NetworkAccountTransitGatewayVPCAVPCBVPCC(Acc1)(Acc2)(Acc3)Alsocontains:-DirectConnectGateway-VPNconnections-DNS(Route53Resolver)

6. Account Vending

AWS Service Catalog

AccountRequestServiceCatalogCloudFormationNewAccount-StandardVPC-IAMRoles-SecurityConfig-Loggingenabled

AWS Control Tower Account Factory

ControlTowerAccountFactoryApplyCreateApplyGuardrailsAccountBaseline

7. Câu hỏi ôn tập

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

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

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

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

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

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

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

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


Ngày tiếp theo: IAM Identity Center (AWS SSO)