AWS Config

A camera pointed at your resources' configuration. It records what a resource looks like every time it changes, keeps the history, judges it against rules, and can fix it. It is detective, never preventive — that distinction decides most questions it appears in.

Một cái camera chĩa vào cấu hình của tài nguyên. Nó ghi lại hình dạng resource mỗi lần thay đổi, giữ lịch sử, chấm điểm theo rule, và có thể tự sửa. Nó detective, không bao giờ preventive — phân biệt đó quyết định phần lớn câu hỏi có nó.

The loopVòng lặp

The AWS Config loop. A resource changes; the configuration recorder writes a configuration item. That item flows two ways: into configuration history stored in S3 for audit and timeline, and into Config rules which evaluate it and produce a compliance verdict. A non-compliant verdict can trigger an SSM Automation runbook to remediate the resource, and can also emit an EventBridge event for alerting. A note underneath says Config detects after the fact, so there is always a window where the bad configuration exists. resource SG · S3 · RDS · IAM change configuration recorder writes a CI configuration history timeline · S3 · audit Config rules evaluate the CI NON_COMPLIANT + EventBridge event SSM Automation runbook manual or automatic remediation fixes the resource detective: the bad config exists first, then gets caught

Every arrow here happens after the change lands. If a requirement says "must never exist, not even for a second", Config is the wrong tool — that is an SCP, a CloudFormation Hook, or a pipeline gate.

Mọi mũi tên ở đây xảy ra sau khi thay đổi đã vào. Nếu yêu cầu nói "không được tồn tại dù chỉ một giây", Config là công cụ sai — đó là SCP, CloudFormation Hook, hoặc cổng pipeline.

Config vs the services it gets confused withConfig vs những service hay bị nhầm

Question in the exam stemCâu hỏi trong đề ServiceService
"How is this resource configured / was it ever unencrypted?""Resource này cấu hình thế nào / đã từng không mã hoá chưa?"AWS Config
"Who called the API that changed it?""Ai gọi API làm nó đổi?"CloudTrail
"CPU / latency / logs""CPU / latency / log"CloudWatch
"React to the change in near-real-time""Phản ứng với thay đổi gần realtime"EventBridge
"Stop the API call from succeeding at all""Chặn hẳn không cho API call thành công"SCP / IAM
"Is there a CVE in this EC2 / container image?""EC2 / container image này có CVE không?"Inspector
"Manage & auto-fix security groups / WAF org-wide""Quản lý & tự sửa security group / WAF toàn org"Firewall Manager
"Generic best-practice recommendations""Khuyến nghị best practice chung chung"Trusted Advisor
Same incident, four servicesCùng một sự cố, bốn service A security group is opened to 0.0.0.0/0. Config marks it non-compliant and shows the before/after. CloudTrail names the principal who ran AuthorizeSecurityGroupIngress. EventBridge fires within seconds so a Lambda can revoke it. SCP could have blocked the call only if the condition were expressible — and for a source CIDR it isn't. Một security group bị mở 0.0.0.0/0. Config đánh dấu non-compliant và cho xem trước/sau. CloudTrail chỉ ra principal đã chạy AuthorizeSecurityGroupIngress. EventBridge bắn trong vài giây để Lambda revoke. SCP chỉ chặn được nếu điều kiện diễn đạt được — và với source CIDR thì không.

Rules — what they can and can't holdRule — chứa được và không chứa được gì

AWS managed ruleAWS managed rule Hundreds, ready to go. Parameters only — you tune a threshold or a list of allowed values, you don't write logic.
rds-storage-encrypted · encrypted-volumes · s3-bucket-public-read-prohibited · restricted-ssh · required-tags · vpc-sg-open-only-to-authorized-ports
Hàng trăm cái, dùng ngay. Chỉ có tham số — chỉnh ngưỡng hoặc danh sách giá trị, không viết logic.
rds-storage-encrypted · encrypted-volumes · s3-bucket-public-read-prohibited · restricted-ssh · required-tags · vpc-sg-open-only-to-authorized-ports
Custom Lambda ruleCustom Lambda rule Arbitrary logic in code. Costs a Lambda invocation per evaluation, and it's yours to maintain.Logic tuỳ ý bằng code. Tốn một Lambda invocation cho mỗi lần đánh giá, và bạn phải tự bảo trì.
Custom policy ruleCustom policy rule Declarative CloudFormation Guard DSL, no Lambda to run or pay for. Prefer this over a Lambda rule when the check is a plain property assertion.DSL CloudFormation Guard khai báo, không phải chạy/trả tiền Lambda. Ưu tiên cái này hơn Lambda rule khi phép kiểm tra chỉ là khẳng định về thuộc tính.
  • A managed rule is not a place to stash a company CIDR list. "Create a Config managed rule containing all our office IP ranges" is a distractor — a shared CIDR list is a customer-managed prefix list shared via RAM.Managed rule không phải chỗ để nhét danh sách CIDR của công ty. "Tạo Config managed rule chứa mọi dải IP văn phòng" là bẫy — danh sách CIDR dùng chung là customer-managed prefix list share qua RAM.
  • vpc-sg-open-only-to-authorized-ports checks which ports may be open to the world — it can still pass a 0.0.0.0/0 rule on an authorised port. It also only flags; it never revokes unless you attach remediation.vpc-sg-open-only-to-authorized-ports kiểm tra những port nào được mở ra ngoài — nó vẫn có thể cho qua rule 0.0.0.0/0 trên port hợp lệ. Nó cũng chỉ đánh dấu; không revoke trừ khi bạn gắn remediation.
  • Rules evaluate on change or on a periodic schedule. A periodic rule can lag by up to its period, so "near-real-time" wording points at EventBridge instead.Rule chạy khi có thay đổi hoặc theo lịch định kỳ. Rule định kỳ có thể trễ tới hết một chu kỳ, nên chữ "gần realtime" là trỏ sang EventBridge.

Detective vs proactive vs preventiveDetective vs proactive vs preventive

DetectiveDetective ProactiveProactive PreventivePreventive
WhenKhi nào after the resource existssau khi resource đã tồn tại on a proposed config, before deploytrên cấu hình dự kiến, trước deploy at the API callngay tại lời gọi API
Blocks?Có chặn? ✗ ✗ — returns a verdict only✗ — chỉ trả về kết quả ✓
Built withXây bằng Config rule · Control Tower detective controlConfig rule · detective control của Control Tower Config proactive rule, wired into a pipeline / CFN HookConfig proactive rule, nối vào pipeline / CFN Hook SCP · Control Tower preventive control · CFN Hook in fail modeSCP · preventive control của Control Tower · CFN Hook ở chế độ fail
"Detect" vs "prevent" is the single highest-yield keyword"Detect" vs "prevent" là từ khoá lời nhất "Must detect RDS instances that are not encrypted at rest" → Config rule / Control Tower detective control. "Must prevent anyone from launching an unencrypted RDS" → SCP or a preventive control. An SCP never scans existing resources, and a Config rule never blocks a call. "Phải detect RDS chưa mã hoá at rest" → Config rule / detective control của Control Tower. "Phải prevent không cho ai tạo RDS chưa mã hoá" → SCP hoặc preventive control. SCP không bao giờ quét resource đã có, và Config rule không bao giờ chặn một lời gọi.

Org-scale: conformance packs & aggregatorsQuy mô org: conformance pack & aggregator

Conformance packConformance pack A YAML bundle of rules + remediation actions, deployed as one immutable unit to an account/Region — or to the whole organization from the management/delegated-admin account. Sample packs exist for CIS, PCI-DSS, HIPAA, NIST.Một gói YAML gồm rule + remediation, deploy như một đơn vị bất biến vào account/Region — hoặc toàn organization từ management/delegated-admin account. Có sẵn pack mẫu cho CIS, PCI-DSS, HIPAA, NIST.
AggregatorAggregator Read-only roll-up of configuration + compliance from many accounts and Regions into one dashboard. Reads only — it does not deploy rules; the rules must already exist in each account.Gộp read-only cấu hình + compliance từ nhiều account và Region vào một dashboard. Chỉ đọc — nó không deploy rule; rule phải đã có sẵn trong từng account.
Advanced queryAdvanced query SQL-ish inventory over current state, and it works against an aggregator too — the fastest way to answer "how many X across the org".Truy vấn kiểu SQL trên trạng thái hiện tại, chạy được cả trên aggregator — cách nhanh nhất để trả lời "toàn org có bao nhiêu X".
SELECT resourceId, resourceType, awsRegion, accountId
WHERE resourceType = 'AWS::EC2::Instance'
  AND tags.key = 'Owner'  -- inventory / audit, current state only
  • Deploying rules to every account is a conformance pack or a StackSet job. An aggregator only views.Deploy rule vào mọi account là việc của conformance pack hoặc StackSet. Aggregator chỉ xem.
  • Config is per Region, per account — you turn on the recorder in each Region you care about. There is no global Config.Config là theo Region, theo account — phải bật recorder ở từng Region quan tâm. Không có Config global.
  • Cost control: set the recorder to selected resource types, or use a lower recording frequency for stable types. Recording everything in an ECS/Spot-heavy account gets expensive fast.Kiểm soát chi phí: đặt recorder ở selected resource types, hoặc dùng tần suất ghi thấp hơn cho loại ổn định. Record tất trong account nhiều ECS/Spot sẽ đắt rất nhanh.

Exam reflexesPhản xạ thi

  • "Detect resources that are not encrypted / not tagged / publicly readable" → Config rule (or the equivalent Control Tower detective control)."Detect resource chưa mã hoá / chưa tag / public" → Config rule (hoặc detective control tương ứng của Control Tower).
  • "What changed on this resource before the incident?" → Config configuration timeline, not CloudTrail (CloudTrail gives you the call, not the resulting shape)."Resource này đổi gì trước sự cố?" → configuration timeline của Config, không phải CloudTrail (CloudTrail cho lời gọi, không cho hình dạng kết quả).
  • "Detect and fix automatically, least ops" → Config rule + automatic remediation via SSM Automation. Writing your own Lambda per account is the higher-overhead answer."Detect và tự sửa, ít vận hành nhất" → Config rule + automatic remediation qua SSM Automation. Tự viết Lambda cho từng account là đáp án nhiều overhead hơn.
  • "Security team wants one dashboard across 50 accounts" → Config aggregator in the delegated security account (plus a conformance pack to place the rules)."Security muốn một dashboard cho 50 account" → Config aggregator ở security account uỷ quyền (kèm conformance pack để đặt rule).
  • Config mentioned in a question that's really about something else (a shared CIDR list, a cost report) is usually just scenery — read the actual requirement.Config xuất hiện trong câu thật ra hỏi chuyện khác (danh sách CIDR chung, báo cáo chi phí) thường chỉ là phông nền — đọc kỹ yêu cầu thật.