Ghi nhận API activity bằng CloudTrail, đánh giá compliance bằng AWS Config
Sau một sự cố, cần trả lời được ai đã làm gì, lúc nào, và cấu hình hiện tại có tuân thủ quy định hay không; mỗi câu hỏi có một dịch vụ cung cấp dữ liệu tương ứng.
Sau một sự cố, đội vận hành MFTECH cần trả lời nhiều câu hỏi; mỗi câu hỏi chỉ một dịch vụ cung cấp được câu trả lời. Chọn từng câu hỏi và gửi truy vấn:
Chọn một câu hỏi, sau đó chọn Hỏi để xác định dịch vụ cung cấp câu trả lời.
CloudTrail ghi lại hoạt động của user, role và dịch vụ AWS trong account: mỗi API call được ghi thành một event; theo mặc định, trail ghi management event, còn data event (ví dụ thao tác trên S3 object) phải được bật thêm. AWS Config lưu lịch sử cấu hình: mỗi khi tài nguyên thay đổi, Config ghi lại một configuration item, và Config rule đánh giá cấu hình đó tuân thủ hay không tuân thủ. Hai dịch vụ bổ trợ cho nhau. Chọn từng mốc thời gian trong tuần của security group sg-web:
AWS Config: trạng thái cấu hình
- + 443/tcp ← 0.0.0.0/0
Đang được gắn vào: i-web1, i-web2
CloudTrail: người thực hiện thay đổi
CreateSecurityGroup AuthorizeSecurityGroupIngress user: role/cloudformation
Security group được tạo, chỉ cho phép HTTPS. Config ghi configuration item đầu tiên.
Phát hiện vi phạm khác với ngăn chặn hoặc tự động khắc phục vi phạm. Ba lớp guardrail MFTECH áp dụng cho các account:
Chọn một tình huống, thay đổi cấu hình, sau đó chọn nút chạy.
Trail audit-trail trong tình huống trên là trail thông thường được tạo trong account dev-an. Trail bắt buộc cũng có thể được tạo dưới dạng organization trail. Organization trail chỉ được tạo từ management account hoặc account delegated administrator của CloudTrail; trail tự động áp dụng cho mọi account thành viên, kể cả account gia nhập organization sau này. User trong account thành viên nhìn thấy organization trail nhưng không xoá, không bật tắt ghi log và không sửa đổi được trail này. Ngược lại, một trail do developer tạo ngay trong account của mình chỉ là trail thông thường của account đó, và root user có thể xoá nó; vì vậy với trail thuộc account thành viên, SCP vẫn là lớp bảo vệ cần thiết.
Với chứng chỉ, ACM cung cấp thêm hai nguồn tín hiệu ngoài Config rule. Metric DaysToExpiry (namespace AWS/CertificateManager, dimension CertificateArn) được ACM gửi lên CloudWatch hai lần mỗi ngày cho mọi chứng chỉ cho tới khi hết hạn; vì metric gắn với từng ARN, mỗi chứng chỉ cần một alarm riêng, và mỗi chứng chỉ import thêm sau này cần thêm một alarm mới. EventBridge nhận event ACM Certificate Approaching Expiration hằng ngày, bắt đầu từ 45 ngày trước khi hết hạn với chứng chỉ private hoặc import và 30 ngày với chứng chỉ public. Managed rule acm-certificate-expiration-check đánh giá mọi chứng chỉ trong account theo cùng một ngưỡng và lưu lịch sử tuân thủ, không cần tạo alarm cho từng chứng chỉ.
Khi cần áp dụng cùng một bộ Config rule cho nhiều account, MFTECH dùng conformance pack: tập hợp Config rule và remediation action, viết trong một template YAML, triển khai như một đơn vị trong một account và Region hoặc trên toàn bộ organization. Khi triển khai từ management account, account thành viên không sửa đổi được các rule và remediation action đó. Conformance pack chỉ đánh giá và khắc phục cấu hình; nó không tạo account và không dựng hạ tầng mạng dùng chung.
- Ai gọi API nào, vào thời điểm nào: CloudTrail (thao tác IAM là management event, được trail ghi theo mặc định).
- Cấu hình tài nguyên theo thời gian và mức tuân thủ: AWS Config.
- Đảm bảo trail luôn hoạt động kể cả khi developer có quyền root: SCP.
- Organization trail chỉ tạo được từ management account hoặc delegated administrator; account thành viên không sửa được trail này.
- Chứng chỉ import vào ACM không được tự động gia hạn: managed rule acm-certificate-expiration-check cảnh báo trước (metric DaysToExpiry cần một alarm cho mỗi chứng chỉ).
- Config rule kết hợp remediation để tự động khắc phục; conformance pack triển khai một bộ rule và remediation cho cả organization.
Recording API activity with CloudTrail, evaluating compliance with AWS Config
After an incident, you need to know who did what and when, and whether the current configuration complies with policy; each question has a service that provides the data.
After an incident, the MFTECH operations team needs to answer many questions; each question can be answered by only one service. Choose each question and send the query:
Chọn một câu hỏi, sau đó chọn Hỏi để xác định dịch vụ cung cấp câu trả lời.
CloudTrail records the activity of users, roles and AWS services in an account: each API call is recorded as an event; by default, a trail records management events, while data events (for example operations on S3 objects) must be enabled additionally. AWS Config keeps the configuration history: each time a resource changes, Config records a configuration item, and a Config rule evaluates whether that configuration is compliant or noncompliant. The two services complement each other. Choose each point in time during the week of security group sg-web:
AWS Config: trạng thái cấu hình
- + 443/tcp ← 0.0.0.0/0
Đang được gắn vào: i-web1, i-web2
CloudTrail: người thực hiện thay đổi
CreateSecurityGroup AuthorizeSecurityGroupIngress user: role/cloudformation
Security group được tạo, chỉ cho phép HTTPS. Config ghi configuration item đầu tiên.
Detecting a violation is different from preventing it or remediating it automatically. Three layers of guardrails that MFTECH applies to its accounts:
Chọn một tình huống, thay đổi cấu hình, sau đó chọn nút chạy.
The audit-trail trail in the scenario above is an ordinary trail created in account dev-an. A mandatory trail can also be created as an organization trail. An organization trail can only be created from the management account or a CloudTrail delegated administrator account; it is applied automatically to every member account, including accounts that join the organization later. Users in member accounts can see the organization trail, but cannot delete it, turn logging on or off, or change it in any way. By contrast, a trail that a developer creates inside their own account is an ordinary trail of that account, and the root user can delete it; for trails in member accounts, an SCP remains the necessary layer of protection.
For certificates, ACM offers two more signal sources besides the Config rule. The DaysToExpiry metric (namespace AWS/CertificateManager, dimension CertificateArn) is published by ACM to CloudWatch twice per day for every certificate until it expires; because the metric is tied to a single ARN, each certificate needs its own alarm, and every certificate imported later needs one more alarm. EventBridge receives a daily ACM Certificate Approaching Expiration event, starting 45 days before expiration for private or imported certificates and 30 days for public certificates. The acm-certificate-expiration-check managed rule evaluates every certificate in the account against the same threshold and keeps a compliance history, with no alarm to create per certificate.
To apply the same set of Config rules to many accounts, MFTECH uses a conformance pack: a collection of Config rules and remediation actions, written in a YAML template and deployed as a single entity in an account and Region or across the whole organization. When it is deployed from the management account, member accounts cannot modify those rules and remediation actions. A conformance pack only evaluates and remediates configuration; it does not create accounts and does not build shared network infrastructure.
- Who called which API, and when: CloudTrail (IAM operations are management events, recorded by a trail by default).
- Resource configuration over time and compliance: AWS Config.
- Make sure a trail always keeps running even when developers have root access: SCP.
- An organization trail can only be created from the management account or a delegated administrator; member accounts cannot change it.
- Certificates imported into ACM are not renewed automatically: the acm-certificate-expiration-check managed rule warns in advance (the DaysToExpiry metric needs one alarm per certificate).
- Config rules combined with remediation fix violations automatically; a conformance pack deploys one set of rules and remediations to the whole organization.