Bài này gộp 4 chủ đề: Amazon CloudWatch, CloudTrail và AWS Config, AWS Systems Manager (SSM), AWS Organizations Basics.
Mục tiêu học tập
- Hiểu CloudWatch: metrics, logs, alarms, dashboards
- Nắm custom metrics, log groups, log insights
- Áp dụng CloudWatch Alarms cho monitoring
- Phân biệt CloudTrail vs Config vs CloudWatch
- Hiểu CloudTrail event types và trails
- Nắm AWS Config rules và remediation
- Hiểu SSM ecosystem
- Nắm Session Manager, Patch Manager, Run Command, Parameter Store
- Áp dụng SSM cho EC2 + on-prem management
- Hiểu AWS Organizations và multi-account setup
- Nắm OU (Organizational Unit) structure
- Hiểu Service Control Policies (SCP) cơ bản
- Phân biệt Consolidated Billing và Volume Discounts
Phần 1: Amazon CloudWatch
1. Tổng quan CloudWatch
CloudWatch = monitoring service tập trung cho AWS resources và applications.
4 main components
- Metrics: số liệu theo thời gian
- Logs: collect, store, analyze logs
- Alarms: cảnh báo khi metric vượt threshold
- Dashboards: visualize metrics
Use cases
- Monitor EC2 CPU, RDS connections, Lambda invocations
- Centralize application logs
- Alert on system anomalies
- Auto-scaling triggers
- Build operations dashboards
2. CloudWatch Metrics
Built-in metrics
- EC2: CPU, NetworkIn/Out, DiskReadOps (no memory by default — need agent)
- RDS: DatabaseConnections, FreeStorageSpace, CPUUtilization
- S3: BucketSizeBytes, NumberOfObjects (daily)
- Lambda: Invocations, Errors, Duration, Throttles
- ELB: RequestCount, TargetResponseTime, HTTPCode_Target_4XX_Count
Custom metrics
- Push custom metrics via API:
PutMetricData - Dimensions: extra context (e.g., instance ID, environment)
cloudwatch.put_metric_data(
Namespace='MyApp',
MetricData=[{
'MetricName': 'OrdersProcessed',
'Value': 100,
'Unit': 'Count',
'Dimensions': [
{'Name': 'Environment', 'Value': 'prod'}
]
}]
)
High-Resolution metrics
- Standard: 60-second granularity
- High-resolution: 1-second granularity (extra cost)
Retention
- 1-minute: retained 15 days
- 5-minute: 63 days
- 1-hour: 455 days (15 months)
3. CloudWatch Logs
Components
- Log Group: container (e.g.,
/aws/lambda/my-function) - Log Stream: source within group (e.g., per instance)
- Log Events: timestamped log lines
Sources
- Lambda (automatic)
- ECS, EKS (configurable)
- CloudWatch Agent on EC2
- VPC Flow Logs
- Route 53 query logs
- API Gateway access logs
- ALB access logs (to S3, then to CloudWatch)
- Custom: API or SDK
Retention
- Configurable per log group: 1 day - 10 years - Never expire
- Default: Never expire (cost grows!)
Logs Insights
- Query language for log analysis
- Example: count errors per minute
fields @timestamp, @message
| filter @message like /ERROR/
| stats count() by bin(1m)
4. CloudWatch Agent
Định nghĩa
CloudWatch Agent = installed on EC2/on-prem to collect:
- Memory utilization (not default in CloudWatch)
- Disk usage, I/O
- Network detailed metrics
- Custom logs (
/var/log/myapp.log)
Setup
- Install CloudWatch Agent
- Configure via JSON or SSM Parameter Store
- Start agent → metrics + logs flow
5. CloudWatch Alarms
States
- OK: metric within threshold
- ALARM: metric breached threshold
- INSUFFICIENT_DATA: not enough data
Configuration
- Metric: which to monitor
- Threshold: condition (>, <, =)
- Period: evaluation period (1 min, 5 min, etc.)
- Datapoints to alarm: 3 out of 5 periods (avoid false alarm)
- Actions: SNS, SSM auto-remediation, Auto Scaling, EC2 actions
Actions
- SNS notification (email, SMS)
- Auto Scaling (scale in/out)
- EC2 Action (stop, terminate, reboot, recover)
- Systems Manager (run automation document)
Composite Alarm
- Combine multiple alarms with AND/OR
- Reduce alarm fatigue
6. Dashboards
Features
- Drag-and-drop widgets
- Line, stacked area, number, gauge, text
- Multiple regions in 1 dashboard
- Shareable
- Auto-refresh
Cost
- $3/dashboard/month (3 dashboards free)
7. CloudWatch Synthetics
Định nghĩa
Synthetics = scheduled scripts (canaries) test endpoint availability + UX.
Use case
- Monitor website uptime
- Test transaction flow (login, search, purchase)
- API endpoint health
- Alert on regression
Type
- Heartbeat (URL ping)
- API canary (REST API workflow)
- Broken link checker
- Visual monitoring (screenshot diff)
- GUI workflow
8. CloudWatch RUM (Real User Monitoring)
Định nghĩa
RUM = monitor end-user experience (browser performance, errors).
Captures
- Page load time
- JavaScript errors
- User journey
- Geographic distribution
Use case
- Web app performance monitoring
- A/B testing analytics
- Frontend troubleshooting
9. CloudWatch Anomaly Detection
Định nghĩa
ML auto-detect anomalies in metrics, alarm on deviation từ baseline.
Use case
- Detect unusual API call spikes
- Identify cost anomalies
- Catch performance regressions
10. Cross-Account, Cross-Region Observability
Định nghĩa
View metrics + logs từ multiple accounts trong 1 dashboard.
Setup
- Monitoring Account: receive data
- Source Accounts: send data
- Sink + Link configuration
Use case
- Centralized ops dashboard for organization
- Compliance reporting
11. CloudWatch Metric Math
Định nghĩa
Compute derived metrics from existing metrics.
Examples
e1 = m1 / m2 * 100 (error rate %)
e2 = sum(m1) (total over time)
e3 = m1 + m2 + m3 (aggregate)
Use case
- Custom KPIs
- Rate calculations
- Aggregation across resources
12. Pricing
- Metrics: $0.30/metric/month (custom) + $0.01/1000 API requests
- Logs: $0.50/GB ingested + $0.03/GB stored
- Alarms: $0.10/alarm/month
- Dashboards: $3/dashboard/month
Free tier
- 10 custom metrics
- 10 alarms
- 5 GB logs ingested
- 1M API requests
Phần 2: CloudTrail và AWS Config
1. AWS CloudTrail
Định nghĩa
CloudTrail = audit log cho API calls trong AWS account.
Đặc điểm
- Enabled by default trong mọi AWS account
- 90 days history trong console (Event History)
- Cần tạo Trail để lưu lâu hơn (gửi đến S3, CloudWatch Logs)
- Global service nhưng trail có thể là regional hoặc multi-region
Event types
| Type | Description |
|---|---|
| Management Events (default) | API calls về tài nguyên (CreateBucket, RunInstances, ...) |
| Data Events (paid) | API về data trong resource (S3 GetObject, Lambda Invoke) |
| Insights Events | Unusual activity (ML detection) |
Use cases
- Security audit (who did what when)
- Compliance (SOC, PCI requires audit trail)
- Troubleshoot (what changed before incident)
- Investigation forensics
Trail Setup
- S3 bucket destination (encrypted recommended)
- Optional: send to CloudWatch Logs (for alarms on specific events)
- Optional: integrate với Amazon EventBridge (real-time response)
- Optional: integrate với Lake Formation for analysis
Multi-account / Organization Trail
- Single trail captures events from all accounts in Organization
- Storage in management account or dedicated logging account
- Use case: centralized audit log
2. CloudTrail Lake
Định nghĩa
CloudTrail Lake = managed data lake cho CloudTrail events, query via SQL.
Đặc điểm
- Up to 7-year retention
- SQL queries on event data
- No need to configure S3 + Athena yourself
Use case
- Long-term audit retention
- Compliance investigation
- Ad-hoc audit queries
3. CloudTrail vs CloudWatch Logs
| CloudTrail | CloudWatch Logs | |
|---|---|---|
| Tracks | API calls (who did what) | Application logs |
| Sources | AWS API endpoints | Apps, services |
| Format | JSON CloudTrail events | Free-form text/JSON |
| Use case | Audit, compliance | Debug, monitor |
Best practice: send CloudTrail events to CloudWatch Logs to alarm on critical events.
4. AWS Config
Định nghĩa
AWS Config = continuous configuration tracking và compliance evaluation.
Đặc điểm
- Records configuration changes of resources over time
- Configuration Items (CI): snapshot of resource state at point in time
- Configuration Timeline: visualize changes
- Configuration History: stored in S3
- Regional (enable per region)
What's tracked
- Configuration changes (EC2 SG modified, S3 bucket policy changed)
- Compliance status (resource meets rules?)
- Relationships (EC2 → EBS, EC2 → SG)
Config Rules
AWS Managed Rules
- 200+ pre-built rules
- Examples:
s3-bucket-public-read-prohibitediam-password-policyencrypted-volumesec2-instances-in-vpcrds-storage-encrypted
Custom Rules
- Lambda function evaluates resource
- Pass/fail logic
Compliance Status
- COMPLIANT: meets rule
- NON_COMPLIANT: violates rule
- Dashboard shows organization-wide compliance %
5. AWS Config Remediation
Manual remediation
- Engineer fixes non-compliant resource
Auto-remediation
- Trigger SSM Automation document on non-compliance
- Example: S3 bucket public → auto-disable public access
Use case
- Drift detection (resource changed outside IaC)
- Continuous compliance (auto-fix violations)
6. Config vs CloudTrail
| CloudTrail | Config | |
|---|---|---|
| What | API calls history | Resource configuration history |
| Question | "Who did X?" | "What is X's current state? How has it changed?" |
| Compliance | Detect actions | Detect state |
| Format | Events (chronological) | Configuration Items per resource |
Combined
- CloudTrail: "Bob disabled MFA at 3 PM"
- Config: "MFA was enabled, now disabled, configuration drift detected"
7. Multi-Account Config
Aggregator
- Aggregate compliance data from multiple accounts + regions
- View in 1 dashboard
- Setup via Organizations (auto-include new accounts)
8. Config Pricing
- $0.003 per configuration item recorded
- $0.001 per evaluation (rule check)
- Can be expensive in large org → use exclusion (don't record certain resources)
9. Common Patterns
Pattern 1: Track changes
- CloudTrail + Config
- Detect "who made change" + "what changed"
Pattern 2: Auto-remediate
Config rule "s3-bucket-public-read-prohibited" NON_COMPLIANT
→ SSM Automation
→ Block public access on bucket
→ Resource COMPLIANT
Pattern 3: Alert on critical IAM events
CloudTrail event "DeleteUser" or "CreateAccessKey"
→ CloudWatch Logs filter
→ Alarm → SNS to security team
Pattern 4: Compliance reporting (PCI, HIPAA)
- AWS Config rules per framework
- Aggregate across accounts
- Audit Manager → automated reports
10. Best Practices
CloudTrail
- Enable multi-region trail (catch all regions)
- Enable in management account of Organization (org-wide)
- Encrypt log files with KMS
- Validate file integrity (signed logs)
- Send to centralized account (security/log archive)
Config
- Enable in all regions
- Enable in all accounts (Organizations)
- Use Aggregator for centralized view
- Auto-remediation for known violations
- Monitor cost (configuration items can grow)
Phần 3: AWS Systems Manager (SSM)
1. Tổng quan Systems Manager
AWS Systems Manager (SSM) = unified interface to manage AWS + on-prem infrastructure.
Đặc điểm
- Manage EC2 + on-prem servers
- No SSH keys needed (Session Manager)
- Centralized patch management
- Configuration as data (Parameter Store)
- Compliance scanning
- Operational insights
Requirements
- SSM Agent installed (preinstalled on Amazon Linux, Windows Server AMIs)
- IAM role attached (
AmazonSSMManagedInstanceCorepolicy) - Network connectivity to SSM endpoints (VPC Endpoint optional)
2. Key Capabilities
Session Manager
- Browser-based shell to EC2 + on-prem
- No SSH, no bastion host, no open ports
- Audit log of sessions to S3/CloudWatch
- IAM-controlled access
Benefits
- Security: no port 22 open
- Audit: every session logged
- Cross-OS: Linux SSH + Windows RDP
Run Command
- Execute commands on multiple instances without SSH
- Pre-defined documents (e.g.,
AWS-RunShellScript) - Targets: instance IDs, tags, resource groups
- Audit log via CloudTrail
Use cases
- Install software across fleet
- Apply patches
- Run scripts on Auto Scaling groups
Patch Manager
- Automated patching of OS + applications
- Patch baselines: rules for which patches to apply
- Patch groups: target instances by tag
- Maintenance windows: when to patch (off-hours)
- Cross-OS support
State Manager
- Maintain desired state of instances
- E.g., always ensure CloudWatch Agent installed
- Run on schedule (cron)
Inventory
- Collect software + config inventory from instances
- Centralized view of installed software, network config, files
- Use case: license tracking, compliance
Maintenance Windows
- Schedule maintenance tasks (patching, runbook)
- Cron-based
- Avoid disrupting production
Parameter Store
- Store configuration + secrets
- Already covered in Tuần 3 Ngày 1, Phần 2
3. SSM Session Manager Setup
Basic setup
- Attach IAM role with
AmazonSSMManagedInstanceCoreto EC2 - SSM Agent running (default for AL2, Windows Server)
- Open AWS Console → SSM → Session Manager → Start session
Advantages over SSH
- No SSH key management
- No port 22 in Security Group
- No bastion host needed
- Audit trail
- Works with private subnet instances (no internet needed if VPC Endpoint configured)
Logging
- Configure to log session to CloudWatch Logs or S3
- Capture all commands + output
- Use case: compliance, forensics
4. Patch Manager
Patch Baselines
- AWS-managed baselines: per OS
- Custom baselines: customer-defined rules
- Approval rules: auto-approve critical patches after N days
Workflow
- Configure patch baseline
- Tag instances with
Patch Group - Define maintenance window (e.g., Sunday 2 AM)
- SSM applies patches during window
- Compliance report
Patch Compliance
- Compliance dashboard shows % patched
- Identify non-compliant instances
5. Run Command
Example: Install Apache on all EC2 with tag Role=web
aws ssm send-command \
--document-name "AWS-RunShellScript" \
--targets "Key=tag:Role,Values=web" \
--parameters 'commands=["yum install -y httpd","systemctl start httpd"]'
Built-in documents
AWS-RunShellScript(Linux)AWS-RunPowerShellScript(Windows)AWS-UpdateSSMAgentAWS-ConfigureAWSPackage(install AWS-distributed packages)
Custom documents
- YAML/JSON
- Reusable runbooks
6. Automation Documents
Định nghĩa
Automation documents = scripts orchestrate AWS actions (similar to Step Functions but simpler).
Use cases
- Patch + reboot fleet
- Snapshot all RDS at end of day
- Update AMI in Launch Templates
- Compliance remediation (via Config integration)
Trigger sources
- Manual execution
- Maintenance Windows
- EventBridge (event-driven automation)
- Config rules (remediation)
7. SSM Inventory
Collected data
- AWS components, applications, files, network config, services, Windows updates, Windows registry, Windows roles
Storage
- Aggregate to S3 via Resource Data Sync
- Query với Athena, visualize với QuickSight
Use case
- Software license tracking
- Vulnerability patching priority
- Compliance audit
8. AppConfig
Định nghĩa
AppConfig = manage application configuration changes (feature flags, gradual rollout).
Đặc điểm
- Validation before deploy
- Gradual rollout (10%, 50%, 100%)
- Rollback if errors
- A/B testing
- Integrate với Lambda, ECS, EC2
Use case
- Feature flags
- Configuration changes without redeploy
- Canary config rollout
9. OpsCenter
Định nghĩa
OpsCenter = central place to view + investigate operational issues.
Aggregates
- Config compliance violations
- CloudWatch alarms
- AWS Health events
- Trusted Advisor recommendations
Use case
- Single pane of glass for ops team
10. Common Patterns
Pattern 1: SSH-less infrastructure
- No bastion host
- All access via Session Manager
- IAM-controlled per user
Pattern 2: Automated patching
- Tag instances by environment
- Patch Manager applies based on tags + baseline
- Maintenance window during off-hours
- Compliance dashboard tracks
Pattern 3: Config drift detection + auto-fix
- AWS Config rule "ssm-agent-installed"
- Non-compliant → trigger SSM Automation document
- Document installs SSM Agent
Pattern 4: Centralized configuration
- Parameter Store hierarchy:
/myapp/{env}/{component}/... - Apps fetch at runtime
- Update without redeploy
11. Multi-Account, Hybrid
Hybrid (on-prem)
- Install SSM Agent on-prem
- Register as managed instance (with activation code)
- Treat on-prem servers like EC2 in SSM
Multi-account
- IAM cross-account roles
- Run Command from management account to member accounts
- Resource Groups for grouping
Phần 4: AWS Organizations Basics
1. Tổng quan Organizations
AWS Organizations = service quản lý multiple AWS accounts centrally.
Đặc điểm
- Free service
- Hierarchical: Root → OUs → Accounts
- Consolidated billing: 1 hóa đơn cho tất cả accounts
- Volume discounts: aggregate usage cho discount
- SCPs giới hạn permissions across accounts
- Service integration: CloudTrail, Config, SSO, Backup, etc.
Lý do dùng Organizations
- Isolation: separate dev, staging, prod
- Billing: aggregate cost, get volume discounts
- Security: limit blast radius (1 account compromised ≠ all compromised)
- Compliance: separate compliance scopes (PCI account)
- Team autonomy: each team owns account
2. Components
Management Account (formerly Master)
- Creates organization
- Pays bill for all member accounts
- Cannot have SCPs apply to it (always full permissions)
- Should be only used for org management (not workload)
Member Accounts
- Created within organization (or invited from existing)
- Receive consolidated billing
- SCPs apply
Organizational Unit (OU)
- Logical group of accounts
- Up to 5 levels nesting
- Apply policies (SCP, tag policies) at OU level
3. Account Lifecycle
Create new account
- Console: "Add account" → AWS creates new account in org
- Email + name required
- IAM role
OrganizationAccountAccessRolecreated (assumable from management)
Invite existing account
- Send invitation to existing account
- Account owner accepts
- Joins organization (still owned by original owner)
Remove account
- Account leaves organization
- Must have own payment method
- Some accounts created in console must wait 7 days before can be removed
Close account
- Suspend account, delete resources after 90 days
- Cannot reopen
4. Service Control Policies (SCPs)
Định nghĩa
SCP = policy that limits maximum permissions for IAM users/roles in accounts.
Đặc điểm
- Whitelist or blacklist style
- NOT grant permissions (just limit)
- Apply ở Root, OU, hoặc Account
- Inheritance: child OU inherit parent's SCPs
- NOT apply to management account
- NOT apply to service-linked roles
Default SCP
- FullAWSAccess: allow everything (default attached)
- Can detach and attach more restrictive
Effective permissions
Effective permission = IAM identity policy ∩ SCP
= What both allow
Common SCPs
Deny specific regions
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:RequestedRegion": ["us-east-1", "us-west-2"]
}
}
}]
}
Prevent IAM user creation (force IAM Identity Center)
{
"Effect": "Deny",
"Action": ["iam:CreateUser", "iam:CreateAccessKey"],
"Resource": "*"
}
Prevent leaving organization
{
"Effect": "Deny",
"Action": "organizations:LeaveOrganization",
"Resource": "*"
}
Force MFA
{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"BoolIfExists": { "aws:MultiFactorAuthPresent": "false" }
}
}
5. Consolidated Billing
Benefits
- 1 invoice for entire organization
- Volume discounts: aggregate usage across accounts
- Reserved Instance sharing: RIs in 1 account benefit other accounts (configurable)
- Savings Plans sharing: similar
Example
- Account A uses 100 EC2 hours, Account B uses 200 hours
- Together = 300 hours → may qualify for next pricing tier discount
6. AWS Account Best Practices
Standard account structure
- Management Account (root): only org management
- Log Archive Account: centralized CloudTrail + Config logs
- Security Account: GuardDuty, Security Hub delegated admin
- Shared Services Account: IAM Identity Center, DNS, central networking
- Production OU: production workloads
- Non-Production OU: dev/test
- Sandbox OU: experimentation
Landing Zone
- AWS-managed solution: Control Tower
- Auto-setup standard org structure
- Guardrails (preventive + detective)
- Account Vending (template-based new account creation)
7. AWS Control Tower
Định nghĩa
Control Tower = managed service implement landing zone best practices.
Features
- Account Factory: vending machine for new accounts
- Pre-built guardrails (SCPs + Config rules)
- CloudTrail + Config centralized
- Service Catalog for self-service
- Free (resources used charged normally)
Guardrails
- Preventive (SCP-based): "Don't allow public S3 buckets"
- Detective (Config-based): "Flag if RDS not encrypted"
Use case
- Multi-account setup with best practices
- Compliance baseline
- Standardize new account provisioning
8. AWS RAM (Resource Access Manager)
Định nghĩa
RAM = share AWS resources across accounts (or within Organization).
Shareable resources
- VPC subnets (VPC Sharing)
- Transit Gateway
- Route 53 Resolver Rules
- License Manager configurations
- AWS Glue Data Catalog
- ACM Private CA
- Aurora DB Cluster, Lake Formation databases, etc.
Use case
- Centralized networking (1 account owns VPC, other accounts use subnets)
- Share AMIs, software licenses
- Cross-account database access
Sharing models
- Within Organization: easier setup (auto-trust)
- Cross-account standalone: invitation-based
9. Cross-Account Access Patterns
Pattern 1: Centralized logging
Pattern 2: Centralized security
Security Account = GuardDuty delegated admin
Security Hub aggregator
Members ──► Findings flow to Security Account
Pattern 3: Shared networking
Network Account owns VPC + Transit Gateway
Other accounts share subnets via RAM
Single point of egress, route control
Pattern 4: Cross-account workload
10. SCPs Best Practices
Strategy: Default-Allow vs Default-Deny
- Default-Allow (most common): Start with FullAWSAccess, add specific deny rules
- Default-Deny: Start empty, add specific allow rules (more restrictive)
Common SCP rules
- Deny disabling CloudTrail
- Deny deleting Organizations Config
- Deny IAM user creation (use SSO)
- Deny root user access keys
- Restrict regions
- Force encryption on EBS, S3
- Prevent leaving organization
Test SCPs in sandbox
- Test in non-prod OU first
- Use COUNT mode? No, SCPs are immediate. Use test OU.
11. Tag Policies
Định nghĩa
Tag Policies = enforce tagging standards across accounts.
Đặc điểm
- Defines required tag keys + valid values
- Compliance check (not enforcement by default)
- Combined with SCPs to enforce (deny if not tagged)
Use case
- Cost allocation (require
CostCentertag) - Resource organization
- Compliance audit
Câu hỏi ôn tập
-
EC2 default metrics có bao gồm memory không?
Xem đáp án
Không — EC2 default metrics không có memory, disk utilization. Default metrics chỉ include: CPU Utilization, Network In/Out, Disk Read/Write (cho instance store), Status Check metrics. Memory và disk space cần CloudWatch Agent cài trên instance để gửi custom metrics. Đây là điểm hay nhầm trong kỳ thi — "EC2 memory metric" không có sẵn mà không cần agent.
-
CloudWatch Logs retention default là bao lâu?
Xem đáp án
Never expire (vô thời hạn) — mặc định logs không bao giờ tự xóa và sẽ tốn tiền tích lũy. Nên set retention policy ngay khi tạo log group: 1 ngày đến 10 năm. Best practice: set retention phù hợp với compliance requirements (HIPAA thường 7 năm, nhiều apps đủ 90 ngày). Có thể export logs cũ sang S3 trước khi delete.
-
Composite Alarm dùng để làm gì?
Xem đáp án
Kết hợp nhiều alarms dùng Boolean logic (AND/OR/NOT) thành một alarm duy nhất. Ví dụ:
ALARM if (CPUAlarm AND MemoryAlarm)— chỉ alert khi cả hai đều trong ALARM state, giảm noise. HoặcALARM if (HighCPU OR HighDisk)— alert khi một trong hai. Composite Alarm giảm alert fatigue — không cần nhận từng alert riêng biệt khi chúng có correlation. -
CloudWatch Synthetics monitor gì?
Xem đáp án
Synthetic monitoring — chạy canary scripts (Node.js/Python) để simulate user behavior và monitor endpoints: (1) API availability và latency, (2) Website navigation flows (login → checkout), (3) Broken links, screenshot diffs. Canaries chạy theo schedule (cron), alert khi responses sai hoặc latency cao. Phát hiện issues proactively trước users thực. Tích hợp với X-Ray cho distributed tracing.
-
Anomaly Detection hoạt động dựa trên gì?
Xem đáp án
Machine Learning model train trên metric history — học patterns (hourly, weekly, seasonal variations). Model tạo "expected band" cho metric. CloudWatch alert khi metric value nằm ngoài band. Ưu điểm: không cần set static thresholds (thích hợp cho metrics thay đổi theo thời gian). Cần ít nhất 2 tuần history để model accurate. Có thể exclude scheduled maintenance windows khỏi training.
-
CloudTrail Event History trong console giữ bao lâu?
Xem đáp án
90 ngày trong CloudTrail console Event History (miễn phí). Để giữ lâu hơn, cần tạo Trail và gửi logs đến S3 — có thể giữ vô thời hạn với S3 Lifecycle policies. Trail management events thêm miễn phí copy đầu tiên per region; data events có phí thêm. Best practice: tạo trail gửi đến S3 + enable CloudTrail Lake cho query.
-
Data Events trong CloudTrail có miễn phí không?
Xem đáp án
Không — Data Events tính phí thêm (~$0.10/100K events). Management Events (control plane: CreateBucket, RunInstances, IAM changes...) là miễn phí cho một trail đầu tiên per region. Data Events là high-volume events như S3 object-level operations (GetObject, PutObject), DynamoDB item-level operations, Lambda invocations. Cần cân nhắc cost trước khi enable data events trên S3 buckets/DynamoDB tables nhiều traffic.
-
CloudTrail vs Config khác nhau ở câu hỏi nào?
Xem đáp án
CloudTrail trả lời: "Ai đã làm gì, khi nào?" (WHO + WHAT + WHEN) — API calls, user activity. AWS Config trả lời: "Configuration của resource hiện tại là gì? Có compliance không?" (WHAT STATE). Config track resource configuration changes over time và evaluate compliance rules. CloudTrail = audit log; Config = configuration history và compliance assessment. Thường dùng cả hai cùng nhau.
-
Config rule có thể auto-remediate qua service nào?
Xem đáp án
AWS Systems Manager (SSM) Automation — Config Remediation Action trigger SSM Automation document để tự fix non-compliant resources. Ví dụ: rule phát hiện S3 bucket public → remediation action chạy SSM automation tắt public access. Cũng có thể dùng Lambda custom function. Remediation có thể manual (click button) hoặc automatic (trigger ngay khi non-compliant).
-
Centralized audit log cho Organization setup ở account nào?
Xem đáp án
Dedicated Security/Audit account (best practice theo AWS Organizations pattern). Tạo Organization Trail từ management account → ghi logs của tất cả member accounts vào S3 bucket trong audit account. Member accounts không thể disable trail (nếu dùng Organization Trail). Audit account chỉ dành cho security/compliance — không deploy workloads — tối thiểu quyền cho developers.
- SSM Session Manager khác SSH ở điểm gì?
Xem đáp án
Session Manager: (1) Không cần port 22 mở, không cần key pairs, (2) Không cần bastion host, (3) Toàn bộ session được log (CloudWatch, S3), (4) Access kiểm soát qua IAM (không phải SSH keys), (5) Hoạt động cho instances trong private subnet không có public IP (qua SSM endpoints). SSH truyền thống cần inbound port 22, key management phức tạp, ít audit. Session Manager là zero-trust access approach.
- Patch Manager dùng để làm gì?
Xem đáp án
Tự động patch OS và software trên EC2 instances (và on-premises servers). Define Patch Baseline (danh sách patches approved/rejected theo severity). Maintenance Window schedule khi patch được apply. Compliance report cho biết instances nào đã patch, còn thiếu patches gì. Hỗ trợ Windows, Amazon Linux, Ubuntu, RHEL, SUSE. Giảm manual effort patch management across fleet của instances.
- Run Command có thể target instances bằng cách nào?
Xem đáp án
Run Command target instances theo: (1) Instance IDs cụ thể, (2) Resource Group tags (ví dụ: Environment=Production), (3) Tag key-value (ví dụ: Patch=true), (4) All managed instances trong account. Chạy cùng command trên hàng nghìn instances song song (controlled by rate) mà không cần SSH từng cái. Output lưu vào S3 hoặc CloudWatch Logs.
- Parameter Store khác AppConfig ở điểm gì?
Xem đáp án
Parameter Store: key-value storage cho config và secrets, giá trị là strings, SecureString (KMS-encrypted), StringList. Simple retrieval. AWS AppConfig: designed cho feature flags và application configuration với deployment strategies (canary, linear rollout), validation (JSON schema, Lambda validator), rollback nếu CloudWatch alarm trigger. AppConfig không crash apps với bad config; Parameter Store là simple key-value without deployment safety.
- SSM Agent có preinstalled trên AMIs nào?
Xem đáp án
SSM Agent preinstalled trên: Amazon Linux 2, Amazon Linux 2023, Windows Server 2008-2022 AMIs from AWS. Cũng có trên Ubuntu 16.04+ và RHEL 7.4+ AWS AMIs từ 2017. Với AMIs khác hoặc on-premises servers cần cài thủ công. Instance cũng cần IAM role với AmazonSSMManagedInstanceCore policy và network access đến SSM endpoints (qua internet hoặc VPC Interface Endpoints).
- SCP có grant permissions không?
Xem đáp án
Không — SCP (Service Control Policy) chỉ giới hạn permissions tối đa (guardrails), không grant permissions. Member account vẫn cần IAM policies riêng để có quyền thực sự. SCP áp dụng cho tất cả principals trong account (kể cả root account của member) — nhưng management account không bị SCP áp dụng. SCP là "maximum permissions fence" không phải "grant permissions".
- Management account có bị SCP áp dụng không?
Xem đáp án
Không — Management account (root account của Organization) không bị SCP apply, kể cả SCP ở root OU. Đây là lý do best practice: không deploy workloads trong management account và minimize credentials cho management account. Chỉ dùng management account cho billing, organization management, và Control Tower. Workloads deploy trong member accounts — bị SCP govern.
- Consolidated billing có volume discount như thế nào?
Xem đáp án
AWS tính tổng usage của tất cả member accounts trong Organization cho volume pricing tiers. Ví dụ S3: pricing giảm khi dùng > 50 TB, > 500 TB — consolidated billing gộp usage của 10 accounts, có thể đạt tier thấp hơn nhanh hơn từng account riêng. Reserved Instance và Savings Plans cũng có thể share giữa accounts trong Organization — RI của 1 account có thể apply cho account khác nếu không dùng hết.
- Control Tower setup gì tự động?
Xem đáp án
AWS Control Tower tự động setup: (1) Landing Zone — multi-account structure với Log Archive account, Audit account, Security OU, Sandbox OU, (2) Guardrails (mandatory + optional SCPs + Config rules), (3) IAM Identity Center cho SSO, (4) CloudTrail organization trail, (5) Config organization rules. Giảm setup time từ weeks xuống hours. Ongoing governance qua Account Factory cho tạo accounts mới.
- RAM dùng để share resources nào?
Xem đáp án
AWS Resource Access Manager (RAM) share: 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. Sharing chỉ hoạt động trong cùng AWS Organization (cần bật Organizational sharing). Không tính phí RAM, chỉ tính phí resource được share. VPC Subnet sharing là pattern chính để centralize networking.
Bài tập thực hành
Phần 1: Amazon CloudWatch
- Tạo CloudWatch Alarm: EC2 CPU > 80% trong 5 phút → SNS email
- Install CloudWatch Agent trên EC2, configure memory metrics
- Tạo Log Group cho Lambda, query với Logs Insights
- Tạo dashboard với 4 widgets (CPU, Memory, Disk, Network)
- Setup Synthetics canary monitor website
- Push custom metric từ app, alarm khi vượt threshold
Phần 2: CloudTrail và AWS Config
- Tạo Trail multi-region, gửi đến S3 + CloudWatch Logs
- Search Event History cho action "RunInstances" gần đây
- Enable Config, add managed rule
s3-bucket-public-read-prohibited - Tạo public bucket, observe Config flag NON_COMPLIANT
- Setup auto-remediation: trigger SSM doc khi bucket public
- Setup CloudWatch alarm: CloudTrail event "ConsoleLogin without MFA" → SNS
Phần 3: AWS Systems Manager (SSM)
- Attach IAM role với SSM policy vào EC2
- Connect via Session Manager (no SSH key needed)
- Run Command: install package trên 3 instances
- Setup Patch Manager baseline + maintenance window
- Tạo Parameter Store hierarchy cho app config
- (Optional) Register on-prem server với SSM
Phần 4: AWS Organizations Basics
- Tạo AWS Organization (cần new account hoặc current account làm management)
- Tạo OU "Development", invite/create member account
- Apply SCP "DenyRegionsOutside_US"
- Test: user in member account không tạo được resource ở region khác US
- (Optional) Setup Control Tower trên Organization
Tài liệu tham khảo
- CloudWatch Documentation
- CloudWatch Agent
- Logs Insights
- Synthetics
- CloudTrail Documentation
- CloudTrail Lake
- AWS Config
- Config Rules
- Systems Manager Documentation
- Session Manager
- Patch Manager
- Run Command
- Parameter Store
- AWS Organizations
- SCPs
- Control Tower
- AWS RAM