AWS Config
Configuration Recording, Compliance Rules, Remediation, Multi-Account Aggregation
Tổng quan
AWS Config là dịch vụ giúp bạn assess, audit, và evaluate cấu hình của AWS resources. AWS Config liên tục monitors và records resource configurations, cho phép bạn:
- Theo dõi configuration changes theo thời gian
- Evaluate compliance với internal policies
- Troubleshoot configuration issues
- Security analysis
[!TIP] AWS Config KHÔNG ngăn chặn changes - nó chỉ recording và evaluating. Để prevent changes, dùng kết hợp với SCPs, IAM policies.
Tại sao cần AWS Config?
Kiến trúc và Components
Core Components
| Component | Mô tả |
|---|---|
| Configuration Recorder | Captures configuration changes của resources |
| Configuration Item (CI) | Point-in-time view của resource configuration |
| Configuration History | Collection of CIs cho 1 resource theo thời gian |
| Configuration Snapshot | Collection of CIs cho tất cả resources tại 1 thời điểm |
| Config Rules | Desired configuration settings để evaluate |
| Conformance Packs | Collection of Config Rules deploy cùng nhau |
Configuration Items (CI)
CI Structure
Supported Resource Types
AWS Config hỗ trợ 300+ resource types, bao gồm:
| Category | Resource Types |
|---|---|
| Compute | EC2 Instance, Auto Scaling Group, Lambda Function |
| Storage | S3 Bucket, EBS Volume, EFS |
| Database | RDS Instance, DynamoDB Table, ElastiCache |
| Network | VPC, Subnet, Security Group, ACL, Route Table |
| Security | IAM User, Role, Policy, KMS Key |
| Management | CloudFormation Stack, CloudTrail Trail |
Config Rules
Rule Types
Trigger Types
| Trigger | Mô tả | Use Case |
|---|---|---|
| Configuration Changes | Evaluate khi resource thay đổi | Real-time compliance |
| Periodic | Evaluate theo schedule (1h, 3h, 6h, 12h, 24h) | Regular audits |
| Hybrid | Cả configuration changes và periodic | Best coverage |
Popular Managed Rules
| Rule | Mô tả |
|---|---|
s3-bucket-public-read-prohibited | S3 bucket không public read |
s3-bucket-ssl-requests-only | S3 bucket chỉ chấp nhận SSL |
ec2-instance-no-public-ip | EC2 không có public IP |
rds-storage-encrypted | RDS storage được encrypted |
rds-multi-az-support | RDS có Multi-AZ enabled |
encrypted-volumes | EBS volumes được encrypted |
iam-password-policy | IAM password policy đủ strong |
iam-user-mfa-enabled | IAM users có MFA enabled |
root-account-mfa-enabled | Root account có MFA |
vpc-flow-logs-enabled | VPC có Flow Logs enabled |
cloudtrail-enabled | CloudTrail enabled |
required-tags | Resources có required tags |
Config Rule Evaluation
Custom Rules
Lambda-based Custom Rule
Guard-based Custom Rule
Conformance Packs
Tổng quan
Conformance Pack là collection of Config Rules và Remediation Actions được deploy như một đơn vị, giúp:
- Đơn giản hóa compliance management
- Deploy consistent rules across accounts
- Audit compliance với frameworks (PCI-DSS, HIPAA, NIST)
Available Sample Templates
| Template | Use Case |
|---|---|
| Operational Best Practices for AWS Identity and Access Management | IAM security |
| Operational Best Practices for Amazon S3 | S3 security |
| Operational Best Practices for Amazon DynamoDB | DynamoDB |
| Operational Best Practices for Encryption and Keys | Encryption |
| Operational Best Practices for Logging | Logging |
| AWS Control Tower Detective Guardrails | Control Tower |
| PCI-DSS | Payment Card Industry |
| HIPAA Security | Healthcare |
| NIST 800-53 | Government |
| CIS AWS Foundations Benchmark | CIS |
Conformance Pack Template Example
Remediation
Automatic Remediation
Remediation Types
| Type | Mô tả | Use Case |
|---|---|---|
| Manual | Operator triggers remediation | Sensitive resources, cần review |
| Automatic | Remediation runs automatically | Non-critical resources |
| Automatic with retry | Retry nếu remediation fails | Reliable remediation |
Common SSM Automation Documents
| Document | Action |
|---|---|
AWS-EnableS3BucketEncryption | Enable S3 bucket encryption |
AWS-DisableS3BucketPublicReadWrite | Disable public access |
AWS-EnableEbsEncryptionByDefault | Enable EBS encryption |
AWS-EnableCloudTrailLogFileValidation | Enable CloudTrail validation |
AWS-ConfigureS3BucketLogging | Enable S3 access logging |
Multi-Account Multi-Region Aggregation
Aggregator
Aggregator Setup
Advanced Queries
SQL-like Queries
AWS Config hỗ trợ SQL-like queries để query configuration data:
Query via CLI
Notifications và Events
SNS Notifications
EventBridge Integration
AWS Config vs CloudTrail (Chi tiết)
Câu hỏi thường gặp: "CloudTrail làm được hết mà?"
[!IMPORTANT] KHÔNG! CloudTrail và AWS Config có overlap nhưng KHÁC NHAU về mục đích và coverage.
| Feature | AWS Config | CloudTrail |
|---|---|---|
| Focus | Resource configuration STATE | API activities |
| Records | What resources look like | Who did what, when |
| Question answered | S3 bucket hiện config thế nào? | Ai đã tạo S3 bucket này? |
| History | Configuration history | API call history |
| Compliance | ✅ Config Rules | ❌ No rules |
| Remediation | ✅ SSM Automation | ❌ No remediation |
| Use case | Compliance, auditing configuration | Security investigation, troubleshooting |
Chúng OVERLAP nhưng KHÔNG phải Superset
3 Scenarios cụ thể
Khi nào dùng gì?
| Use Case | AWS Config | CloudTrail |
|---|---|---|
| "SG nào đang mở port 22 ra 0.0.0.0/0?" | ✅ | |
| "S3 bucket nào đang public?" | ✅ | |
| "Tự động fix nếu resources violate rules" | ✅ | |
| "Check tất cả resources có comply không?" | ✅ | |
| "Ai đã xóa S3 bucket này?" | ✅ | |
| "Từ IP nào có người login lạ?" | ✅ | |
| "User nào thay đổi Security Group?" | ✅ |
Complementary Usage: Dùng CẢ HAI
[!TIP] Ví von để nhớ:
- CloudTrail = Camera an ninh ghi "AI vào cửa lúc nào"
- AWS Config = Bảo vệ check "cửa có khóa đúng cách không?"
Cả 2 đều trigger khi có người mở cửa, nhưng ghi lại thông tin khác nhau!
Pricing
CLI Examples
Best Practices
Setup
| Practice | Mô tả |
|---|---|
| Enable in all Regions | Config changes có thể xảy ra ở bất kỳ Region |
| Use Aggregator | Centralized view cho multi-account |
| Deploy via Organizations | Consistent setup across accounts |
| Enable all resource types | Đừng miss important resources |
Config Rules
| Practice | Mô tả |
|---|---|
| Start with managed rules | Quick wins, đã tested |
| Use Conformance Packs | Organized, versioned, deployable |
| Enable remediation | Auto-fix non-compliant resources |
| Set appropriate frequency | Balance between real-time và cost |
Monitoring
| Practice | Mô tả |
|---|---|
| Set up SNS notifications | Alert on non-compliance |
| Use EventBridge | Trigger workflows on changes |
| Regular compliance reports | Audit và review |
| Integrate with Security Hub | Centralized security view |
Integration với AWS Services
Tổng kết
| Feature | Mô tả |
|---|---|
| Configuration Recording | Liên tục record resource configurations |
| Configuration History | Timeline của configuration changes |
| Config Rules | Evaluate compliance với desired state |
| Conformance Packs | Deploy nhiều rules cùng lúc |
| Remediation | Auto-fix non-compliant resources |
| Aggregation | Multi-account, multi-region view |
| Advanced Queries | SQL-like queries trên configuration data |
[!IMPORTANT] AWS Config là essential service cho:
- Compliance auditing - Chứng minh compliance với regulations
- Security analysis - Detect misconfigurations
- Change management - Track và understand changes
- Troubleshooting - "What changed before the incident?"
[!TIP] Combine AWS Config với CloudTrail để có complete picture: WHO (CloudTrail) changed WHAT (Config) and WHEN (both).