devHọc Dev
EN
Bài học

Tuần 2 - Ngày 2: AWS Resource Access Manager và Control Tower

Tuần 2 – Ngày 2

Bài này gộp 2 chủ đề: AWS Resource Access Manager (RAM), AWS Control Tower.

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

  • Hiểu cách hoạt động của AWS RAM
  • Nắm vững các resource types có thể share
  • Biết patterns để share resources across accounts
  • Hiểu cách hoạt động của AWS Control Tower
  • Nắm vững Controls (tên cũ: guardrails) — preventive, detective, proactive
  • Biết cách setup và customize Landing Zone

Phần 1: AWS Resource Access Manager (RAM)

1. Tổng quan AWS RAM

Định nghĩa

AWS Resource Access Manager cho phép share AWS resources giữa các accounts mà không cần duplicate resources.

Benefits

WithoutRAM:WithRAM:┌──────────┐┌──────────┐┌─────────────────────┐│Account││Account││AccountA││A││B││(Owner)││┌──────┐││┌──────┐││┌──────┐│││VPC││││VPC││││VPC││││Subnet││││Subnet││││Subnet│─────────┤│└──────┘││└──────┘││└──────┘││Duplicate│││└─────────────────────┘└──────────┘└──────────┘││SharedCost:2x▼┌─────────────────────┐│AccountB││(Participant)││Usesshared││subnet│└─────────────────────┘Cost:1x

2. Shareable Resource Types

Networking

ResourceShare WithUse Case
VPC SubnetsOrg/AccountsCentralized VPC
Transit GatewayOrg/AccountsNetwork hub
Prefix ListsOrg/AccountsIP management
Route 53 Resolver RulesOrg/AccountsDNS forwarding
Traffic Mirror TargetsAccountsNetwork monitoring

Compute & Storage

ResourceShare WithUse Case
EC2 Capacity ReservationsOrg/AccountsReserved capacity
EC2 Dedicated HostsOrg/AccountsLicense compliance
License ManagerOrg/AccountsLicense tracking
Aurora DB ClustersAccountsShared database

Other Services

ResourceShare WithUse Case
AWS OutpostsOrg/AccountsEdge computing
CodeBuild ProjectsOrg/AccountsShared builds
Glue CatalogsOrg/AccountsData lake
App MeshOrg/AccountsService mesh

3. Sharing Patterns

Pattern 1: VPC Subnet Sharing

┌─────────────────────────────────────────────────────────┐│NetworkAccount││(ResourceOwner)││││┌──────────────────────────────────────────────────┐│││SharedVPC││││┌───────────────┐┌───────────────┐│││││SubnetA││SubnetB││││││(Shared)││(Shared)│││││└───────────────┘└───────────────┘│││└──────────────────────────────────────────────────┘│└────────────────────────────┬────────────────────────────┘│┌─────────────────┴─────────────────┐││▼▼┌─────────────────────┐┌─────────────────────┐│AccountA││AccountB││(Participant)││(Participant)││││││Candeploy:││Candeploy:││-EC2instances││-Lambda││-RDSinstances││-ECStasks││-ELB││-ElastiCache│└─────────────────────┘└─────────────────────┘

Pattern 2: Transit Gateway Sharing

┌─────────────────────────────────────────────────────────┐│NetworkAccount││┌──────────────────────────────────────────────────┐│││TransitGateway││││(Shared)│││└──────────────────────────────────────────────────┘│└────────────────────────────┬────────────────────────────┘│┌───────────────────────┼───────────────────────┐│││▼▼▼┌─────────┐┌─────────┐┌─────────┐│Prod││Dev││Test││Account││Account││Account││VPC-Prod│───────────│VPC-Dev│───────────│VPC-Test│└─────────┘Attachment└─────────┘Attachment└─────────┘

Pattern 3: Aurora Sharing (Cross-Account Clone)

AccountA(Owner)AccountB(Participant)┌─────────────────┐┌─────────────────┐│AuroraCluster││AuroraClone││Primary│───────────│(Read-only│││Share│initially)│└─────────────────┘└─────────────────┘

4. Resource Share Configuration

Creating a Resource Share

Step1:CreateResourceShare┌─────────────────────────────────────────────┐│ResourceShare:"Shared-Network-Resources"││││Resources:││-subnet-aaaa(Production)││-subnet-bbbb(Development)││││Principals:││-arn:aws:organizations::123:ou/ou-xxx││-444455556666(specificaccount)│└─────────────────────────────────────────────┘

Sharing Options

WithinOrganization:┌─────────────────────────────────────────────┐│EnablesharingwithinOrganization││││☑Automaticallyacceptinvitations││(Nomanualacceptanceneeded)│└─────────────────────────────────────────────┘OutsideOrganization:┌─────────────────────────────────────────────┐│Sharewithexternalaccount││││AccountID:999988887777││││⚠Requiresmanualacceptance│└─────────────────────────────────────────────┘

5. Permissions & Ownership

Resource Ownership

Resource Owner (Account A):
- Full control over resource
- Can modify, delete resource
- Can update resource share
- Pays for resource

Participant (Account B):
- Can use/reference resource
- Cannot modify shared resource
- Can create resources in shared subnet
- Pays for own resources

VPC Subnet Sharing Specifics

Owner Account:
- Manages VPC, subnets, route tables
- Manages NACL
- Manages VPC endpoints
- Manages Flow logs

Participant Account:
- Can launch EC2, RDS, ELB, etc. in shared subnet
- Manages Security Groups (own resources)
- Cannot see other participant's resources
- Cannot modify network configuration

6. Best Practices

1. Use Organizations for Sharing

Benefits:
- Automatic acceptance
- Centralized management
- Easy auditing

Configuration:
Organizations → Services → RAM → Enable

2. Tag Resources

{
  "Tags": [
    {"Key": "SharedWith", "Value": "prod-ou"},
    {"Key": "Owner", "Value": "network-team"},
    {"Key": "Purpose", "Value": "centralized-networking"}
  ]
}

3. Use Separate Resource Shares

Good:┌────────────────────┐┌────────────────────┐│NetworkResources││ComputeResources││-Subnets││-CapacityRes.││-TransitGW││-DedicatedHosts│└────────────────────┘└────────────────────┘Bad:┌─────────────────────────────────────────────┐│AllSharedResources││-Subnets,TransitGW,CapacityReservations││(Hardtomanage,audit)│└─────────────────────────────────────────────┘

7. Common Use Cases

Use Case 1: Centralized VPC for Compliance

Requirement: All production resources in compliant network

Solution:
- Network Account owns VPC with compliance controls
- Share subnets to production accounts
- All resources inherit network controls

Use Case 2: Shared Transit Gateway

Requirement: Connect 50 VPCs across accounts

Solution:
- Create Transit Gateway in Network Account
- Share via RAM to Organization
- Each account attaches their VPC
- Centralized routing management

Use Case 3: License Management

Requirement: Track software licenses across accounts

Solution:
- Create license configurations in central account
- Share via RAM
- Accounts consume licenses
- Centralized tracking and compliance

Phần 2: AWS Control Tower

1. Tổng quan AWS Control Tower

Định nghĩa

AWS Control Tower cung cấp cách dễ nhất để setup và govern multi-account AWS environment, được gọi là Landing Zone.

Core Components

┌─────────────────────────────────────────────────────────┐│AWSControlTower││││┌─────────────────┐┌─────────────────────────────┐│││LandingZone││Controls││││(Foundation)││(GovernanceRules)│││└─────────────────┘└─────────────────────────────┘││││┌─────────────────┐┌─────────────────────────────┐│││AccountFactory││Dashboard││││(Provisioning)││(ComplianceVisibility)│││└─────────────────┘└─────────────────────────────┘│└─────────────────────────────────────────────────────────┘

Underlying Services

ControlTowerorchestrates:┌─────────────────────────────────────────────────────────┐│┌───────────────┐┌───────────────┐┌────────────┐│││Organizations││Service││CloudForm││││││Catalog││StackSets│││└───────────────┘└───────────────┘└────────────┘││││┌───────────────┐┌───────────────┐┌────────────┐│││Config││CloudTrail││IAM││││Rules││││Identity││││││││Center│││└───────────────┘└───────────────┘└────────────┘│└─────────────────────────────────────────────────────────┘

2. Landing Zone

Default Structure

Root│├──SecurityOU│├──LogArchiveAccount││-Centralizedlogging││-S3bucketsforCloudTrail,Config│││└──AuditAccount│-Security&compliancetools│-Cross-accountaccessforauditors│├──SandboxOU│└──Developersandboxaccounts│└──[CustomOUs]└──Yourworkloadaccounts

Shared Accounts

┌─────────────────────────────────────────────────────────┐│ManagementAccount││-ControlTowerconfiguration││-Organizationsmanagement││-Billingandcostmanagement││⚠Shouldhaveminimalworkloads│└─────────────────────────────────────────────────────────┘│┌────────────────┴────────────────┐▼▼┌─────────────────────┐┌─────────────────────┐│LogArchiveAccount││AuditAccount││││││Contains:││Contains:││-CloudTraillogs││-Cross-account││-Configlogs││auditrole││-VPCFlowlogs││-Securitytools││-Accesslogs││-Configaggregator││││││⚠Highlyprotected││⚠Read-onlyaccess│└─────────────────────┘└─────────────────────┘

3. Controls (tên cũ: Guardrails)

AWS đã đổi tên guardrails thành controls (docs ghi rõ hai thuật ngữ là đồng nghĩa). Đề thi và tài liệu cũ vẫn có thể dùng "guardrail" — hiểu là cùng một khái niệm. Catalog control hiện được quản lý qua AWS Control Tower Control Catalog.

Types of Controls

┌─────────────────────────────────────────────────────────┐│CONTROLS││││┌─────────────────────────────────────────────────┐│││PREVENTIVE(SCP-based)││││││││Blockactionsbeforetheyhappen││││Examples:││││-DisallowchangestoCloudTrailconfig││││-Disallowdeletionoflogarchive││││-DisallowchangestoIAMIdentityCenter│││└─────────────────────────────────────────────────┘││││┌─────────────────────────────────────────────────┐│││DETECTIVE(ConfigRules)││││││││Detectnon-compliantresources││││Examples:││││-DetectpublicS3buckets││││-DetectunencryptedEBSvolumes││││-Detectrootuseraccess│││└─────────────────────────────────────────────────┘││││┌─────────────────────────────────────────────────┐│││PROACTIVE(CFNHooks)││││││││CheckCloudFormationbeforedeployment││││Examples:││││-ValidateS3bucketencryption││││-ValidateRDSencryption│││└─────────────────────────────────────────────────┘│└─────────────────────────────────────────────────────────┘

Control Behaviors (guidance)

BehaviorDescription
MandatoryAlways enabled, cannot be disabled
Strongly RecommendedBest practices, can be disabled
ElectiveOptional, enable as needed

Common Controls

Mandatory Preventive:

  • Disallow changes to CloudTrail
  • Disallow changes to AWS Config rules
  • Disallow deletion of Log Archive

Strongly Recommended:

  • Disallow public read access to S3 buckets
  • Disallow public write access to S3 buckets
  • Enable encryption for EBS volumes
  • Enable encryption for RDS databases

Detective Examples:

┌─────────────────────────────────────────────────────────┐│Control:DetectpublicS3buckets││││Status:☑Enabled││││Findings:││┌─────────────────────────────────────────────────┐│││Account:111122223333││││Resource:my-public-bucket││││Status:NON_COMPLIANT││││Reason:BlockPublicAccessisdisabled│││└─────────────────────────────────────────────────┘│└─────────────────────────────────────────────────────────┘

4. Account Factory

Purpose

Standardized, automated account provisioning với pre-configured:

  • Network configuration
  • IAM roles
  • Control compliance
  • Organizational unit placement

Account Factory Workflow

RequestNewAccount│▼┌─────────────────────────────────────────────────────────┐│AccountFactory(ServiceCatalog)││││AccountDetails:││-Accountname:dev-team-a││-Email:dev-team-a@company.com││-OU:Workloads/Development││-IAMIdentityCenteruser:john.doe││││NetworkConfiguration:││-VPCCIDR:10.1.0.0/16││-Region:ap-southeast-1│└─────────────────────────────────────────────────────────┘│▼┌─────────────────────────────────────────────────────────┐│AutomatedProvisioning││││1.CreateAWSaccount││2.MovetospecifiedOU││3.Applycontrols││4.DeploybaselineCloudFormation││5.ConfigureIAMIdentityCenteraccess││6.DeployVPC(ifconfigured)│└─────────────────────────────────────────────────────────┘│▼AccountReadytoUse

Customizations for Control Tower (CfCT)

CustomCustomizations:┌─────────────────────────────────────────────────────────┐│manifest.yaml││││-DeployadditionalIAMroles││-ConfigureVPCwithTransitGatewayattachment││-EnableadditionalAWSservices││-ApplycustomConfigrules││-Deploysecuritytools│└─────────────────────────────────────────────────────────┘

5. Dashboard & Compliance

Control Tower Dashboard

┌─────────────────────────────────────────────────────────┐│ControlTowerDashboard││││┌─────────────────────────────────────────────────┐│││OrganizationalUnits:5││││EnrolledAccounts:12││││ControlsEnabled:25│││└─────────────────────────────────────────────────┘││││┌─────────────────────────────────────────────────┐│││ComplianceStatus││││││││Compliant:█████████████████████95%││││Non-compliant:█5%││││││││Violations:││││-Account111:PublicS3bucket││││-Account222:UnencryptedEBSvolume│││└─────────────────────────────────────────────────┘│└─────────────────────────────────────────────────────────┘

6. Extending Control Tower

Account Factory for Terraform (AFT)

┌─────────────────────────────────────────────────────────┐│AccountFactoryforTerraform││││Benefits:││-Terraform-basedaccountprovisioning││-GitOpsworkflow││-Customaccountcustomizations││-Pipeline-baseddeployment││││Workflow:││GitRepo→CodePipeline→AccountProvisioning│└─────────────────────────────────────────────────────────┘

Integrations

Control Tower integrates with:
- AWS Security Hub (aggregate findings)
- AWS Config (conformance packs)
- AWS CloudFormation (StackSets)
- AWS Service Catalog (account vending)

7. Limitations & Considerations

Limitations

LimitationDetail
RegionsHầu hết commercial Region đã hỗ trợ; một số Region mới/opt-in và GovCloud có lịch hỗ trợ riêng — kiểm tra danh sách Region trước khi chọn home Region
Existing OrgsEnroll được Organization có sẵn, nhưng phải xử lý xung đột (SCP, AWS Config recorder, CloudTrail trail đã có) trước khi register OU/account
Nested OUsHỗ trợ từ 11/2022, tối đa 5 cấp dưới root; OU con phải register (hoặc re-register) riêng
CustomizationControl có sẵn trong Control Catalog; phần riêng dùng CfCT, AFT, hoặc custom SCP/Config rule/CloudFormation Hook

When NOT to use Control Tower

  • Very simple single-account setup
  • Highly customized requirements beyond CfCT
  • Need unsupported regions
  • Existing complex Organization structure

Câu hỏi ôn tập

  1. AWS RAM có thể share những resource types nào?

    Xem đáp án

    RAM hỗ trợ sharing nhiều resource types: VPC Subnets (phổ biến nhất), Transit Gateway, Route 53 Resolver Rules, Aurora DB Clusters, EC2 Capacity Reservations, License Manager configurations, AWS Network Firewall policies, CodeBuild Projects, Glue Data Catalog, và nhiều hơn (~100 resource types). Mỗi resource type có rules riêng về sharing scope (Organization-only vs external).

  2. Owner account và Participant account có quyền gì khác nhau?

    Xem đáp án

    Owner: tạo, modify, delete shared resource. Xem tất cả usage của resource kể cả từ participants. Participant: dùng resource nhưng không thể modify hoặc delete. Ví dụ VPC Subnet: participant deploy EC2, RDS vào subnet nhưng không thể modify subnet CIDR hay route table. Resource billing vẫn về owner account — participant không trả tiền cho shared resource (trả tiền resource họ deploy trong đó).

  3. Sharing within Organization có gì khác với outside?

    Xem đáp án

    Within Organization: không cần accept invitation — sharing tự động khi organizations sharing enabled. Outside Organization (account ngoài): phải gửi invitation, recipient phải accept trước khi có thể use shared resources. Cross-organization sharing có thể không được cho phép tùy organization policy. Một số resource types chỉ có thể share within Organization (như Route 53 Resolver Rules).

  4. Khi share VPC subnet, ai manage Security Groups?

    Xem đáp án

    Mỗi account tự manage Security Groups của mình. Owner manage Security Groups thuộc owner account; participant manage SGs trong participant account. Tuy nhiên: participant có thể reference SG của owner account trong rules (và ngược lại) bằng SG ID. Resources của participant và owner có thể giao tiếp qua private IP trong shared subnet nếu SG rules cho phép.

  5. Best practices khi dùng RAM là gì?

    Xem đáp án

    (1) Enable Organizational sharing để tránh manual invitations, (2) Audit resource shares thường xuyên — xem ai đang dùng shared resources, (3) Use tagging để track shared resources, (4) Prefer Organization-scoped sharing over individual account sharing để quản lý dễ hơn, (5) Network Account nên own shared subnets/Transit Gateway — centralized ownership, (6) Monitor shared resource usage qua CloudTrail và AWS Config.

  6. Control Tower sử dụng những AWS services nào underneath?

    Xem đáp án

    Control Tower orchestrate: AWS Organizations (account structure, OUs, SCPs), IAM Identity Center (SSO), AWS Config (compliance rules), CloudTrail (audit logging), Service Catalog (Account Factory), CloudFormation StackSets (deploy baselines to accounts), S3 + CloudWatch (logs). Control Tower là "orchestration layer" — không implement mới mà kết hợp existing services theo best practices.

  7. Sự khác biệt giữa Preventive và Detective controls (tên cũ: guardrails)?

    Xem đáp án

    Preventive controls: implemented via SCPs — block actions trước khi happen. Ví dụ: prevent disabling CloudTrail, prevent leaving Organization. Detective controls: implemented via AWS Config rules — detect non-compliance sau khi happen, generate findings. Ví dụ: detect unencrypted S3 buckets, detect EC2 without required tags. Preventive = hard block; Detective = notify and alert.

  8. Landing Zone mặc định tạo những accounts nào?

    Xem đáp án

    Control Tower setup tạo tự động: Management Account (đã có), Log Archive Account (tập trung CloudTrail logs, Config snapshots), Audit Account (security review, cross-account access cho security tools). Hai accounts này trong Security OU. Cũng tạo sẵn Sandbox OU cho dev/test accounts. Tổng cộng 2 accounts mới và 2 OUs baseline.

  9. Account Factory hoạt động như thế nào?

    Xem đáp án

    Account Factory dùng Service Catalog để provision accounts. Requester fill form (account email, OU, SSO user, VPC config) → Account Factory trigger Account Factory for Terraform (AFT) hoặc built-in provisioning → tạo AWS account → apply baseline StackSets (CloudTrail, Config, VPC, IAM Identity Center assignment) → register với Organizations. Account ready trong 30-60 phút với all governance baselines applied.

  10. Khi nào không nên dùng Control Tower?

Xem đáp án

Không phù hợp khi: (1) Organization đã có complex custom setup và Control Tower would conflict, (2) Cần custom networking phức tạp hơn Control Tower opinionated patterns, (3) Compliance requirements rất specific mà Control Tower controls không cover đúng, (4) Single account — Control Tower over-engineering cho small setups, (5) Khi team chưa sẵn sàng — Control Tower cần hiểu Organizations, IAM Identity Center, Config để maintain.

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

Phần 1: AWS Resource Access Manager (RAM)

  • Create resource share for subnet
  • Share Transit Gateway across accounts
  • Test launching EC2 in shared subnet
  • Review RAM quotas và limits

Phần 2: AWS Control Tower

  • Setup Control Tower Landing Zone (nếu có sandbox account)
  • Review available controls trong Control Catalog
  • Explore Account Factory options
  • Study Customizations for Control Tower (CfCT)

Tài liệu tham khảo


Bài tiếp theo →