Ngân hàng đề — AWS Certified DevOps Engineer Professional
Tìm thấy 681 câu.
A DevOps engineer needs to identify which applications are the source of the increased logging costs.
Which solution will meet this requirement in the MOST operationally efficient way?
- A Use CloudWatch metrics to create a custom expression that identifies the CloudWatch log groups that receive the most data.
- B Use Amazon CloudWatch Logs Insights to create a query for the application log groups to identify the number of log groups that received data during a specific time period.
- C Use AWS Cost Explorer to generate a cost report that details costs for CloudWatch usage.
- D Use AWS CloudTrail to filter for CreateLogStream events for each application.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi tập trung vào vấn đề quản lý chi phí CloudWatch Logs trong AWS. Một công ty có nhiều ứng dụng (applications) đang gửi logs đến các log group riêng biệt trong Amazon CloudWatch. Chi phí ingestion (tiếp nhận dữ liệu logs) đang tăng cao, và DevOps engineer cần xác định ứng dụng nào (tương ứng với log group) là nguồn gốc gây tăng chi phí này.
Yêu cầu chính là tìm giải pháp MOST operationally efficient (hiệu quả vận hành nhất), nghĩa là phải:
- ✅ Nhanh chóng, tự động hóa cao.
- ✅ Sử dụng các tính năng native của AWS mà không cần công cụ bên ngoài hoặc xử lý thủ công phức tạp.
- 📈 Tập trung vào việc đo lường lượng dữ liệu ingested (IncomingBytes) theo từng log group, vì chi phí CloudWatch Logs chủ yếu dựa trên volume dữ liệu tiếp nhận (theo GB ingested, cập nhật pricing 2026: $0.50/GB đầu tiên ở US East, giảm dần theo tier).
Vấn đề cốt lõi: Không phải đếm số lượng log events hay streams, mà là xác định log group nhận nhiều data nhất để pinpoint ứng dụng gây tốn kém.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Use CloudWatch metrics to create a custom expression that identifies the CloudWatch log groups that receive the most data.
Lý do:
- 🛠️ CloudWatch tự động emit metrics cho Logs, đặc biệt là IncomingBytes (tổng bytes ingested vào log group theo thời gian). Mỗi log group có dimension riêng (log-group name).
- Sử dụng Metric Math (custom expression) trong CloudWatch console/metrics explorer để tạo công thức so sánh (ví dụ: SUM([IncomingBytes cho log group A, B, C]) và sort theo giá trị cao nhất). Điều này real-time, granular, không tốn thêm chi phí, và operationally efficient vì chỉ cần vài cú click, không query dữ liệu lớn hay report chậm.
- Phù hợp nhất với DevOps best practice: Monitor metrics trước logs để optimize cost (AWS Well-Architected Framework: Cost Optimization pillar).
- 📘 Tài liệu tham khảo: CloudWatch Logs Metrics và Metric Math (cập nhật 2026).
📋 Giải thích tất cả các phương án
Dưới đây là phân tích chi tiết từng lựa chọn, đánh dấu ✅ đúng hoặc ❌ sai:
-
✅ Use CloudWatch metrics to create a custom expression that identifies the CloudWatch log groups that receive the most data.
🟢 Đúng vì: Như đã giải thích ở trên, IncomingBytes metric trực tiếp đo volume ingestion theo log group. Metric Math cho phép aggregate/sort dễ dàng (ví dụ:m1 = METRICS(); SORT(m1, DESC)), hiển thị top log groups tốn kém nhất. Hiệu quả cao, không cần ETL hay query. -
❌ Use Amazon CloudWatch Logs Insights to create a query for the application log groups to identify the number of log groups that received data during a specific time period.
🔴 Sai vì: Logs Insights dùng để query nội dung logs (parse events, fields), không phải đo ingestion bytes. Nó chỉ đếm số lượng events hoặc log groups có data (ví dụ:stats count() by logGroup), nhưng không chính xác về volume bytes (chi phí dựa trên bytes, không phải events). Query trên nhiều log groups lớn sẽ tốn thời gian/chi phí scan, kém efficient. -
❌ Use AWS Cost Explorer to generate a cost report that details costs for CloudWatch usage.
🔴 Sai vì: Cost Explorer phân tích cost theo service/usage type (ví dụ: "CloudWatchLogs-IngestedBytes"), nhưng không granular đến log group level cho Logs ingestion (chỉ theo account/region). Report chậm (daily granularity), cần filter thủ công, không real-time và kém efficient cho troubleshooting nhanh. -
❌ Use AWS CloudTrail to filter for CreateLogStream events for each application.
🔴 Sai vì: CloudTrail ghi API calls (management events), CreateLogStream chỉ là tạo log stream (một lần), không liên quan đến ingestion volume. Không đo được data lượng, chỉ đếm số stream tạo ra – vô ích cho cost analysis về logs data.
Kết luận 🏆: Giải pháp metrics + Metric Math là best practice cho monitoring CloudWatch Logs costs (AWS re:Post & Well-Architected Labs khuyến nghị). Implement ngay để dashboard hóa! 🚀
A DevOps engineer wants to configure the pipeline to use an AWS CodeDeploy application in an AWS account named CodeDeployAccount to deploy the produced artifact.
The DevOps engineer updates the KMS key policy to grant the CodeDeployAccount account permission to use the key. The DevOps engineer configures an IAM role named DevOps_Role in the CodeDeployAccount account that has access to the CodeDeploy resources that the pipeline requires. The DevOps engineer updates an Amazon EC2 instance role that operates within the CodeDeployAccount account to allow access to the S3 bucket and the KMS key that is in the PipelineAccount account.
Which additional steps will meet these requirements?
- A Update the S3 bucket policy to grant the CodeDeployAccount account access to the S3 bucket. Configure the DevOps_Role IAM role to have an IAM trust policy that allows the PipelineAccount account to assume the role. Update the CodePipeline_Service_Role IAM role to grant permission to assume the DevOps_Role role.
- B Update the S3 bucket policy to grant the CodeDeployAccount account access to the S3 bucket. Configure the DevOps_Role IAM role to have an IAM trust policy that allows the PipelineAccount account to assume the role. Update the DevOps_Role IAM role to grant permission to assume CodePipelfne_Service_Role role.
- C Update the S3 bucket policy to grant the PipelineAccount account access to the S3 bucket. Configure the DevOps_Role IAM role to have an IAM trust policy that allows the PipelineAccount account to assume the role. Update the CodePipeline_Service_Role IAM to grant permission to assume the DevOps_Role role.
- D Update the S3 bucket policy to grant the CodeDeployAccount account access to the S3 bucket. Configure the DevOps_Role IAM role to have an IAM trust policy that allows the CodeDeployAccount account to assume the role. Update the CodePipeline_Service_Role IAM role to grant permission to assume the DevOps_Role role.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi xoay quanh việc cấu hình pipeline cross-account trong AWS giữa hai tài khoản:
- PipelineAccount: Chứa AWS CodePipeline, IAM role
CodePipeline_Service_Role, artifact lưu trữ trong Amazon S3 bucket được mã hóa bằng customer-managed KMS key. - CodeDeployAccount: Chứa ứng dụng AWS CodeDeploy để deploy artifact từ pipeline.
Mục tiêu: DevOps engineer muốn CodePipeline (từ PipelineAccount) deploy artifact sang CodeDeploy app (từ CodeDeployAccount).
Các bước đã thực hiện ✅:
- Cập nhật KMS key policy để grant quyền sử dụng key cho toàn bộ tài khoản CodeDeployAccount (cho phép decrypt artifact).
- Tạo IAM role
DevOps_Roletrong CodeDeployAccount với quyền truy cập resources CodeDeploy cần thiết cho pipeline. - Cập nhật EC2 instance role trong CodeDeployAccount để cho phép truy cập S3 bucket và KMS key từ PipelineAccount (tức là EC2 agent có thể đọc và decrypt artifact).
Vấn đề còn thiếu ❓:
Để hoàn tất cross-account deployment (CodePipeline gọi CodeDeploy ở tài khoản khác), cần:
- Quyền đọc S3 bucket cross-account (cho EC2 agent).
- Cơ chế role assumption để CodePipeline_Service_Role (PipelineAccount) assume DevOps_Role (CodeDeployAccount) nhằm thực hiện deployment.
Điều này dựa trên mô hình cross-account access chuẩn của AWS: service role ở source account assume role ở target account qua STS (Security Token Service).
Kiến thức cập nhật 2026 📘: Không có thay đổi lớn từ AWS re:Post và docs chính thức (vẫn dùng STS AssumeRole cho CodePipeline cross-account actions).
Nguồn tham khảo 🔗:
- AWS Docs: CodePipeline cross-account actions (cập nhật 2024-2026).
- AWS CodeDeploy cross-account deployments.
- IAM best practices for cross-account.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng:
Update the S3 bucket policy to grant the CodeDeployAccount account access to the S3 bucket. Configure the DevOps_Role IAM role to have an IAM trust policy that allows the PipelineAccount account to assume the role. Update the CodePipeline_Service_Role IAM role to grant permission to assume the DevOps_Role role.
Lý do 🛠️:
- Update S3 bucket policy: EC2 instance role (CodeDeployAccount) cần đọc artifact từ S3 (PipelineAccount), nên bucket policy phải explicitly grant principal từ CodeDeployAccount (ví dụ:
"Principal": {"AWS": "arn:aws:iam::CODEDEPLOYACCOUNT:root"}, actionss3:GetObject,s3:GetBucketVersioning). Đã có IAM policy trên EC2 role nhưng thiếu bucket policy → cross-account fail. - DevOps_Role trust policy: Phải cho phép PipelineAccount (root hoặc specific role) assume role này qua
sts:AssumeRole(trust policy ví dụ: Principal"arn:aws:iam::PIPELINEACCOUNT:root"). Đây là bước bắt buộc cho CodePipeline assume role cross-account để invoke CodeDeploy. - CodePipeline_Service_Role permissions: Cần thêm policy
sts:AssumeRoletrên ARN của DevOps_Role để CodePipeline service có thể assume.
Kết hợp hoàn hảo, enable full flow: CodePipeline → assume DevOps_Role → deploy via CodeDeploy → EC2 agent đọc S3/decrypt KMS.
📋 Giải thích tất cả các phương án
-
✅ Update the S3 bucket policy to grant the CodeDeployAccount account access to the S3 bucket. Configure the DevOps_Role IAM role to have an IAM trust policy that allows the PipelineAccount account to assume the role. Update the CodePipeline_Service_Role IAM role to grant permission to assume the DevOps_Role role.
Đúng 🟢: Như phân tích trên, đây là các bước chuẩn xác theo AWS best practices cho cross-account CodePipeline-CodeDeploy. S3 policy enable EC2 đọc artifact, trust policy + AssumeRole permission enable delegation an toàn. -
❌ Update the S3 bucket policy to grant the CodeDeployAccount account access to the S3 bucket. Configure the DevOps_Role IAM role to have an IAM trust policy that allows the PipelineAccount account to assume the role. Update the DevOps_Role IAM role to grant permission to assume CodePipelfne_Service_Role role.
Sai 🔴: Phần S3 và trust policy đúng, nhưng update DevOps_Role để assume CodePipeline_Service_Role là ngược chiều và vô nghĩa. Flow chỉ cần PipelineAccount assume DevOps_Role (không ngược lại). Lỗi chính tả "CodePipelfne" cũng chỉ ra sai sót. -
❌ Update the S3 bucket policy to grant the PipelineAccount account access to the S3 bucket. Configure the DevOps_Role IAM role to have an IAM trust policy that allows the PipelineAccount account to assume the role. Update the CodePipeline_Service_Role IAM to grant permission to assume the DevOps_Role role.
Sai 🔴: S3 bucket policy grant PipelineAccount thừa thãi vì bucket đã thuộc PipelineAccount (self-access không cần explicit). Các phần còn lại đúng nhưng thiếu S3 đúng → EC2 agent không đọc được artifact. -
❌ Update the S3 bucket policy to grant the CodeDeployAccount account access to the S3 bucket. Configure the DevOps_Role IAM role to have an IAM trust policy that allows the CodeDeployAccount account to assume the role. Update the CodePipeline_Service_Role IAM role to grant permission to assume the DevOps_Role role.
Sai 🔴: Trust policy allow CodeDeployAccount assume chính DevOps_Role là self-assume (không liên quan cross-account). PipelineAccount không assume được → CodePipeline không invoke CodeDeploy được. S3 đúng nhưng trust sai phá hỏng toàn bộ.
A DevOps engineer needs to add tags to new resources that include the ID of the user that created the resource and the appropriate cost center ID. The DevOps engineer configures an AWS Lambda function to use the cost center mappings to tag the resources. The DevOps engineer also sets up AWS CloudTrail in the shared AWS account. An Amazon S3 bucket stores the CloudTrail event logs.
Which solution will meet the tagging requirements?
- A Create an S3 event notification on the S3 bucket to invoke the Lambda function for s3:ObjectTagging:Put events. Enable bucket versioning on the S3 bucket.
- B Enable server access logging on the S3 bucket. Create an S3 event notification on the S3 bucket for s3:ObjectTagging:* events.
- C Enable AWS Config in the account. Configure the required-tags AWS managed rule to check and update the required tags.
- D Create an Amazon EventBridge rule that uses Amazon EC2 as the event source. Configure the rule to match events that CloudTrail delivers. Configure the rule to target the Lambda function.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi xoay quanh một tình huống thực tế trong môi trường AWS chia sẻ tài khoản (shared AWS account) với nhiều team phát triển từ các business unit khác nhau. Yêu cầu chính là tất cả tài nguyên Amazon EC2 được tạo phải được gắn tag chỉ rõ user ID (người tạo) và cost center ID tương ứng, và việc gắn tag phải hoàn thành trong vòng 1 giờ đầu sau khi tạo.
- 🛠️ Bối cảnh kỹ thuật: DevOps engineer đã chuẩn bị AWS Lambda function để xử lý mapping cost center và gắn tag. Đồng thời, AWS CloudTrail đã được thiết lập trong account, với logs sự kiện lưu trữ vào Amazon S3 bucket. CloudTrail ghi lại tất cả API calls (như
RunInstancescho EC2), giúp theo dõi ai tạo resource. - 📘 Mục tiêu: Tìm giải pháp tự động gắn tag cho EC2 mới dựa trên CloudTrail events, đảm bảo thời gian phản hồi nhanh (dưới 1 giờ, lý tưởng là gần real-time).
- 🔍 Kiến thức AWS cập nhật đến 2026: Sử dụng Amazon EventBridge (trước đây là CloudWatch Events) để capture trực tiếp CloudTrail management events cho EC2 mà không cần chờ S3 delivery (EventBridge hỗ trợ native integration với CloudTrail từ 2021 và cải tiến real-time filtering đến 2026). Lambda có quyền
ec2:CreateTagsđể tag resource ngay lập tức.
Nguồn tham khảo:
- 📖 AWS EventBridge User Guide - CloudTrail Events
- 📖 AWS CloudTrail Integration with EventBridge
- 📖 Tagging EC2 Instances Automatically
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create an Amazon EventBridge rule that uses Amazon EC2 as the event source. Configure the rule to match events that CloudTrail delivers. Configure the rule to target the Lambda function.
Lý do chọn đáp án này 🏆:
- EventBridge rule lọc trực tiếp CloudTrail events liên quan đến EC2 (ví dụ:
RunInstances,CreateVolume), với event source là EC2 để match pattern như{"source":["aws.ec2"],"detail-type":["AWS API Call via CloudTrail"]}. - Khi EC2 được tạo qua API, CloudTrail ghi event gần real-time (thường <5 phút), EventBridge invoke Lambda ngay lập tức để gọi
ec2:CreateTagsvới user ID (từuserIdentitytrong event) và cost center (từ Lambda mapping). - Đảm bảo tagging trong 1 giờ (thực tế nhanh hơn nhiều), không phụ thuộc S3 latency. Đây là best practice cho auto-tagging theo AWS Well-Architected Framework (Operations Pillar, 2026 edition).
❌ Giải thích tất cả các phương án (đúng/sai)
-
Phương án SAI: Create an S3 event notification on the S3 bucket to invoke the Lambda function for s3:ObjectTagging:Put events. Enable bucket versioning on the S3 bucket.
Giải thích sai ❌: Sự kiệns3:ObjectTagging:Putchỉ trigger khi object trong S3 bucket bị tag, không liên quan đến EC2 creation events từ CloudTrail. Bucket versioning chỉ hỗ trợ version control cho S3 objects, không giúp detect EC2 API calls. Giải pháp này không bao quát EC2 và chậm (S3 delivery ~5-15 phút). -
Phương án SAI: Enable server access logging on the S3 bucket. Create an S3 event notification on the S3 bucket for s3:ObjectTagging:* events.
Giải thích sai ❌: Server access logging ghi HTTP requests đến S3 bucket (không phải CloudTrail EC2 events). Sự kiệns3:ObjectTagging:*vẫn chỉ cho S3 object tags, không captureRunInstancescủa EC2. Giải pháp off-topic hoàn toàn với yêu cầu tagging EC2, dẫn đến không trigger Lambda đúng. -
Phương án SAI: Enable AWS Config in the account. Configure the required-tags AWS managed rule to check and update the required tags.
Giải thích sai ❌: AWS Config rulerequired-tagschỉ kiểm tra compliance (report non-compliant resources), không tự động update/add tags (managed rule không hỗ trợ remediation native). Để remediate cần custom Lambda + SSM Automation, nhưng vẫn chậm (Config scan định kỳ, có thể >1 giờ) và không real-time như EventBridge. Không phù hợp với "within the first hour". -
Phương án ĐÚNG (đã giải thích chi tiết ở trên): Create an Amazon EventBridge rule that uses Amazon EC2 as the event source. Configure the rule to match events that CloudTrail delivers. Configure the rule to target the Lambda function.
Giải thích đúng ✅: Hoàn hảo match yêu cầu, real-time, scalable cho shared account. Lambda nhận event payload chứa resource ID, user info để tag chính xác.
🛠️ Lời khuyên triển khai: Test rule pattern với EventBridge console, grant Lambda IAM role ec2:CreateTags, cloudtrail:LookupEvents. Scale với DLQ nếu cần! 🚀
Which solution will meet these requirements?
- A Create an AWS CodeArtifact repository and associate the upstream repositories. Create an AWS CodeBuild project that builds the semantic version of the code artifacts. Configure the project to authenticate and connect to the CodeArtifact repository and publish the artifact to the repository.
- B Use AWS CodeDeploy to upload the generated semantic version of the artifact to an Amazon Elastic File System (Amazon EFS) file system.
- C Use an AWS CodeBuild project to build the code and to publish the generated semantic version of the artifact to AWS Artifact. Configure build caching in the CodeBuild project.
- D Create a new AWS CodeArtifact repository. Create an AWS Lambda function that pulls open source packages from the internet and publishes the packages to the repository. Configure AWS CodeDeploy to build semantic versions of the code and publish the versions to the repository.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi tập trung vào việc xây dựng một pipeline DevOps trên AWS để xử lý code phát triển sử dụng semantic versioning (phiên bản ngữ nghĩa, ví dụ: MAJOR.MINOR.PATCH). Các yêu cầu chính bao gồm:
- Compile code: Tạo pipeline để biên dịch code.
- Quản lý phiên bản compiled code: Lưu trữ và quản lý các artifact (sản phẩm biên dịch) với semantic versioning.
- Xử lý open source libraries: Cache các thư viện mã nguồn mở trong quá trình build để tăng tốc độ và tránh tải lại từ internet mỗi lần.
Giải pháp cần tích hợp chặt chẽ các dịch vụ AWS như CodeBuild (cho build), CodeArtifact (cho quản lý artifact và caching dependencies), đảm bảo hiệu quả, bảo mật và tuân thủ best practices DevOps trên AWS (cập nhật đến 2024-2026, với CodeArtifact hỗ trợ upstream proxy cho npm, Maven, Gradle, pip...).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng:
Create an AWS CodeArtifact repository and associate the upstream repositories. Create an AWS CodeBuild project that builds the semantic version of the code artifacts. Configure the project to authenticate and connect to the CodeArtifact repository and publish the artifact to the repository.
Lý do lựa chọn 🛠️:
- AWS CodeArtifact là dịch vụ quản lý private artifact repository chuyên dụng, hỗ trợ semantic versioning cho các package (Maven, npm, NuGet, Python...). Nó tự động cache và proxy upstream repositories (như npmjs.com, Maven Central) để tải/caching open source libraries một lần, tránh tải lại và tăng tốc build lên đến 50-70%.
- AWS CodeBuild là công cụ build serverless lý tưởng cho pipeline CI/CD, hỗ trợ build semantic version (qua buildspec.yaml định nghĩa version), authenticate với CodeArtifact qua IAM roles/OIDC, và publish artifacts trực tiếp vào repository.
- Giải pháp này đầy đủ yêu cầu: Build + version management + caching libraries, tích hợp AWS CodePipeline nếu cần. Đây là best practice theo AWS Well-Architected Framework (DevOps pillar, 2024).
📋 Giải thích tất cả các phương án
Dưới đây là phân tích chi tiết từng lựa chọn, với nội dung gốc giữ nguyên tiếng Anh:
-
✅ Create an AWS CodeArtifact repository and associate the upstream repositories. Create an AWS CodeBuild project that builds the semantic version of the code artifacts. Configure the project to authenticate and connect to the CodeArtifact repository and publish the artifact to the repository.
Giải thích đúng 🟢: Như trên, đây là giải pháp hoàn chỉnh, tận dụng upstream proxy của CodeArtifact để cache open source libraries tự động (không cần code thủ công). CodeBuild xử lý build/publish semantic versions an toàn, scalable. Hoàn hảo cho enterprise DevOps. -
❌ Use AWS CodeDeploy to upload the generated semantic version of the artifact to an Amazon Elastic File System (Amazon EFS) file system.
Giải thích sai 🔴: AWS CodeDeploy chỉ dùng cho deployment (triển khai ứng dụng lên EC2/ECS/Lambda), không hỗ trợ build/compile code hay quản lý semantic versions. Amazon EFS là file system chia sẻ, không phải artifact repository (không hỗ trợ versioning, caching packages, dễ gặp vấn đề consistency/scalability). Không đáp ứng build pipeline hoặc caching libraries. -
❌ Use an AWS CodeBuild project to build the code and to publish the generated semantic version of the artifact to AWS Artifact. Configure build caching in the CodeBuild project.
Giải thích sai 🔴: AWS CodeBuild đúng cho build và caching (local/S3 cache cho dependencies), nhưng AWS Artifact chỉ lưu trữ compliance reports (như PCI DSS, ISO certs) từ AWS, không phải code artifacts hoặc semantic versioning. Không hỗ trợ publish packages cá nhân hóa, vi phạm yêu cầu quản lý compiled code. -
❌ Create a new AWS CodeArtifact repository. Create an AWS Lambda function that pulls open source packages from the internet and publishes the packages to the repository. Configure AWS CodeDeploy to build semantic versions of the code and publish the versions to the repository.
Giải thích sai 🔴: CodeArtifact đúng, nhưng Lambda tự pull packages là thừa thãi (CodeArtifact có upstream proxy tự động cache). AWS CodeDeploy không build code (chỉ deploy), không publish artifacts. Giải pháp phức tạp, không scalable, dễ lỗi bảo mật (Lambda pull internet trực tiếp), không phải best practice.
📘 Tài liệu tham khảo
- AWS CodeArtifact Documentation: CodeArtifact User Guide (cập nhật 2024: Upstream proxy & Maven/Gradle integration).
- AWS CodeBuild: Buildspec Reference (Caching & Artifact publishing).
- AWS DevOps Best Practices: Well-Architected Framework - DevOps Pillar (2024 edition).
- Exam Prep: AWS Certified DevOps Engineer Professional (DOP-C02) Sample Questions, AWS Training Portal.
Giải pháp này đảm bảo CI/CD pipeline hiệu quả, bảo mật trên AWS! 🚀
Which solution will meet this requirement?
- A Configure a new stage in the pipeline that includes an AWS FIS action. Configure the action to reference the AWS FIS experiment template. Grant the pipeline access to start the experiment.
- B Create an Amazon EventBridge scheduler. Grant the scheduler permission to start the AWS FIS experiment. Configure a new stage in the pipeline that includes an action to invoke the EventBridge scheduler.
- C Create an AWS Lambda function to start the AWS FIS experiment. Grant the Lambda function permission to start the experiment. Create a new stage in the pipeline that has a Lambda action. Set the action to invoke the Lambda function.
- D Export the AWS FIS experiment template to an Amazon S3 bucket. Create an AWS CodeBuild unit test project that has a buildspec that starts the AWS FIS experiment. Grant the CodeBuild project access to start the experiment. Configure a new stage in the pipeline that includes an action to run the CodeBuild unit test project.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi xoay quanh việc tích hợp AWS Fault Injection Service (AWS FIS) experiment template vào pipeline AWS CodePipeline để kiểm tra tính phục hồi (resiliency) của ứng dụng. 🛠️ Cụ thể, một công ty đang sử dụng CodePipeline để deploy ứng dụng, và họ đã tạo sẵn experiment template trong AWS FIS. Nhiệm vụ của DevOps engineer là thêm experiment này vào pipeline một cách hiệu quả, sao cho pipeline có thể kích hoạt experiment tại một stage phù hợp (ví dụ: sau deploy để test fault injection như inject latency, terminate EC2, etc.).
📘 Bối cảnh AWS cập nhật đến 2026: AWS FIS (ra mắt 2022, cập nhật liên tục) cho phép simulate faults để test chaos engineering. CodePipeline hỗ trợ các action native như Lambda, CodeBuild, nhưng không có action FIS built-in trực tiếp (tính đến 2026, integration chủ yếu qua Lambda hoặc API calls gián tiếp). Mục tiêu là chọn giải pháp đơn giản, an toàn, và tích hợp mượt mà vào pipeline stage.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng là lựa chọn thứ 3 (C):
Create an Amazon Lambda function to start the AWS FIS experiment. Grant the Lambda function permission to start the experiment. Create a new stage in the pipeline that has a Lambda action. Set the action to invoke the Lambda function.
Lý do chọn ✅:
- AWS FIS experiment được kích hoạt qua API
StartExperiment(docs AWS FIS 2026). Lambda là action native của CodePipeline, dễ dàng gọi API này với IAM role phù hợp (fis:StartExperiment). - Giải pháp serverless, scalable, không phụ thuộc schedule hay export file, phù hợp cho pipeline CI/CD. Lambda có thể pass parameters từ pipeline (như ARN của template).
- Best practice cho integration FIS vào CodePipeline: AWS khuyến nghị dùng Lambda để trigger FIS trong các pipeline resiliency testing (ví dụ: Netflix Chaos Monkey pattern trên AWS).
- 🛡️ An toàn: Lambda execution role chỉ cần permission cụ thể cho FIS, tránh over-privilege.
📋 Giải thích chi tiết tất cả các phương án
Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá đúng/sai với lý do cụ thể dựa trên docs AWS mới nhất.
-
Phương án A (❌ SAI):
Configure a new stage in the pipeline that includes an AWS FIS action. Configure the action to reference the AWS FIS experiment template. Grant the pipeline access to start the experiment.
Giải thích sai: CodePipeline không hỗ trợ AWS FIS action native (không có provider "FIS" trong danh sách actions built-in như Lambda, CodeBuild, ECS đến 2026). Bạn không thể config stage với "AWS FIS action" trực tiếp – đây là sai lầm phổ biến. Phải dùng Lambda hoặc custom action để gọi FIS API. Grant access cho pipeline execution role không đủ vì thiếu action provider. -
Phương án B (❌ SAI):
Create an Amazon EventBridge scheduler. Grant the scheduler permission to start the AWS FIS experiment. Configure a new stage in the pipeline that includes an action to invoke the EventBridge scheduler.
Giải thích sai: EventBridge Scheduler dùng cho trigger theo lịch cố định (cron-based), không phù hợp cho pipeline stage (chạy on-demand khi pipeline execute). Pipeline không có action native để "invoke scheduler" – scheduler không phải target của CodePipeline action. Điều này tạo decoupling không cần thiết, dẫn đến timing issues trong resiliency testing. -
Phương án C (✅ ĐÚNG):
Create an Amazon Lambda function to start the AWS FIS experiment. Grant the Lambda function permission to start the experiment. Create a new stage in the pipeline that has a Lambda action. Set the action to invoke the Lambda function.
Giải thích đúng: Như đã nêu ở phần đáp án. Lambda invoke là action chuẩn của CodePipeline (dễ config input/output artifacts). Code trong Lambda dùng Boto3 SDK gọifis.start_experiment()với template ARN. IAM policy ví dụ:{"Action": "fis:StartExperiment", "Resource": "*"}. Hoàn hảo cho pipeline flow: Deploy → Test FIS → Validate. -
Phương án D (❌ SAI):
Export the AWS FIS experiment template to an Amazon S3 bucket. Create an AWS CodeBuild unit test project that has a buildspec that starts the AWS FIS experiment. Grant the CodeBuild project access to start the experiment. Configure a new stage in the pipeline that includes an action to run the CodeBuild unit test project.
Giải thích sai: FIS template không export trực tiếp ra S3 (templates lưu trong FIS console/API dưới dạng JSON ARN, không phải file S3). CodeBuild "unit test project" dành cho testing code, không phải chaos experiment. Buildspec có thể gọi AWS CLIaws fis start-experiment, nhưng phức tạp hơn Lambda (cần container, logs dài), và "unit test" là misuse – CodeBuild thường cho build/deploy, không optimal cho quick fault injection.
📚 Tài liệu tham khảo (AWS docs cập nhật 2026)
- AWS FIS Developer Guide: Integrating FIS with CI/CD pipelines – Khuyến nghị Lambda cho CodePipeline.
- CodePipeline User Guide: Lambda action reference & Supported actions – Xác nhận không có FIS action.
- AWS re:Post & Blogs: Chaos Engineering with FIS in Pipelines (2024).
- Boto3 FIS Client:
start_experiment()API – docs.aws.amazon.com/fis/latest/apireference/API_StartExperiment.html.
Hy vọng phân tích này giúp bạn ôn thi DOP-C02 hiệu quả! 🚀 Nếu cần ví dụ code Lambda, hãy hỏi thêm.
Which solution will meet these requirements?
- A Create an ECR private repository in the private registry to store the container images and scan images when images are pushed to the repository. Configure a replication rule in the private registry to replicate images from upstream repositories.
- B Create an ECR public repository in the public registry to cache images from upstream source repositories. Create an ECR private repository to store images. Configure the private repository to scan images when images are pushed to the repository.
- C Create an ECR public repository in the public registry. Configure a pull through cache rule for the repository. Create an ECR private repository to store images. Configure the ECR private registry to perform basic scanning.
- D Create an ECR private repository in the private registry to store the container images. Enable basic scanning for the private registry, and create a pull through cache rule.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi tập trung vào việc xây dựng một CI/CD pipeline để build các container images, sau đó lưu trữ chúng vào Amazon Elastic Container Registry (ECR) và quét lỗ hổng bảo mật phổ biến (common vulnerabilities). Yêu cầu quan trọng nhất là pipeline phải bền bỉ (resilient) với các sự cố gián đoạn (outages) từ upstream source container image repositories – tức là các kho lưu trữ hình ảnh container gốc bên ngoài như Docker Hub, Quay.io, v.v.
📌 Ngữ cảnh thực tế: Khi build image, pipeline thường pull base images từ upstream public registries. Nếu upstream down (ví dụ: Docker Hub outage), pipeline sẽ fail. Giải pháp cần cache/pull-through để lưu tạm base images locally trong ECR, đảm bảo build tiếp tục ngay cả khi upstream gián đoạn. Đồng thời, phải scan images được build/push vào ECR (sử dụng basic scanning hoặc enhanced). Kiến thức dựa trên AWS ECR phiên bản mới nhất 2025-2026: Pull Through Cache chỉ hỗ trợ cho private repositories, basic scanning tự động kích hoạt khi push image vào private repo.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create an ECR private repository in the private registry to store the container images. Enable basic scanning for the private registry, and create a pull through cache rule.
🛠️ Lý do chi tiết:
- Private repository lưu trữ images được build từ CI/CD, hỗ trợ pull through cache rule để tự động cache base images từ upstream (như Docker Hub) vào private repo. Khi pull image lần đầu, ECR proxy và cache nó; lần sau (hoặc upstream down), pull trực tiếp từ cache → resilient hoàn hảo.
- Basic scanning (miễn phí, dùng Clair scanner) tự động quét vulnerabilities khi push image vào private repo/registry. Không cần enhanced scanning vì yêu cầu chỉ "common vulnerabilities".
- Giải pháp đơn giản, chi phí thấp, một private repo duy nhất xử lý cả store, scan và cache. Phù hợp DevOps best practices (immutable infrastructure, security scanning in pipeline).
📋 Giải thích tất cả các phương án (đúng/sai)
-
❌ Phương án A (SAI):
Create an ECR private repository in the private registry to store the container images and scan images when images are pushed to the repository. Configure a replication rule in the private registry to replicate images from upstream repositories.
🧨 Lý do sai: Replication rule chỉ dùng để copy images giữa các ECR repos/regions/accounts AWS (cross-account/region), KHÔNG hỗ trợ replicate từ upstream external như Docker Hub. Không giải quyết outages upstream vì vẫn phải pull trực tiếp từ source ban đầu. Scan khi push là đúng nhưng thiếu resilience. -
❌ Phương án B (SAI):
Create an ECR public repository in the public registry to cache images from upstream source repositories. Create an ECR private repository to store images. Configure the private repository to scan images when images are pushed to the repository.
🧨 Lý do sai: Public repository (Public Gallery) không hỗ trợ pull through cache hoặc caching tự động từ upstream (chỉ cho public sharing). Phải dùng 2 repos (public + private) → phức tạp, tốn kém, không resilient (vẫn pull từ upstream qua public repo). Scan private repo đúng nhưng tổng thể không tối ưu. -
❌ Phương án C (SAI):
Create an ECR public repository in the public registry. Configure a pull through cache rule for the repository. Create an ECR private repository to store images. Configure the ECR private registry to perform basic scanning.
🧨 Lý do sai: Pull through cache rule CHỈ hỗ trợ cho private repositories, KHÔNG có trên public repositories (theo AWS docs 2025+). Public repo chỉ cho public pulls/sharing, không proxy/cache upstream. Cần 2 repos → dư thừa, không resilient đầy đủ cho toàn pipeline. -
✅ Phương án D (ĐÚNG):
Create an ECR private repository in the private registry to store the container images. Enable basic scanning for the private registry, and create a pull through cache rule.
🛠️ Lý do đúng: Như phân tích trên – một private repo duy nhất xử lý store (built images), scan (basic tự động), và pull through cache (resilient với upstream outages). Prefix nhưecr-publichoặc custom cho cache rules (e.g., docker.io/library/nginx).
📘 Tài liệu tham khảo (AWS cập nhật 2025-2026)
- ECR Pull Through Cache: AWS Docs - Pull through cache rules – Chỉ private repos, hỗ trợ Docker Hub, Quay, GitHub Container Registry.
- ECR Image Scanning: AWS Docs - Image scanning – Basic scanning mặc định private repos.
- Best Practices CI/CD: AWS DevOps Guidance - Container pipelines & Exam DOP-C02 blueprint (Domain 3: Automation).
- Video demo: AWS re:Invent 2024/2025 sessions về ECR resilience.
Hy vọng phân tích này giúp bạn ôn thi AWS Certified DevOps Engineer Professional hiệu quả! 🚀 Nếu cần thêm ví dụ code (Terraform/CloudFormation), hãy hỏi nhé!
The company needs to eliminate single points of failure in the architecture to improve the website's availability and resilience.
Which solution will meet these requirements with the LEAST configuration changes to the website?
- A Deploy the application by using AWS Fargate containers. Migrate the database to Amazon DynamoDB. Use Amazon API Gateway to route requests.
- B Deploy the application on EC2 instances across multiple Availability Zones. Put the EC2 instances into an Auto Scaling group behind an Application Load Balancer. Migrate the database to Amazon Aurora Multi-AZ. Use Amazon CloudFront for content delivery.
- C Use AWS Elastic Beanstalk to deploy the application across multiple AWS Regions. Migrate the database to Amazon Redshift. Use Amazon ElastiCache for session management.
- D Migrate the application to AWS Lambda functions. Use Amazon S3 for static content hosting. Migrate the database to Amazon DocumentDB (with MongoDB compatibility).
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi tập trung vào việc cải thiện độ khả dụng (availability) và khả năng phục hồi (resilience) cho một website ecommerce trên AWS.
Hiện tại, kiến trúc đang có single point of failure nghiêm trọng:
- Toàn bộ ứng dụng (app) và cơ sở dữ liệu MySQL chạy trên một EC2 instance duy nhất trong một Availability Zone (AZ).
- Nếu instance hoặc AZ gặp sự cố (như outage), toàn bộ website sẽ downtime.
Yêu cầu chính:
- Loại bỏ single points of failure bằng cách phân tán tài nguyên qua nhiều AZ (high availability).
- Với LEAST configuration changes to the website 🛠️: Nghĩa là ưu tiên giải pháp ít thay đổi code/app nhất, giữ nguyên công nghệ hiện tại (EC2 + MySQL) càng nhiều càng tốt, tránh refactor lớn như chuyển sang serverless hay NoSQL.
Mục tiêu là scale horizontally (nhiều instances/AZs), load balancing, DB replication, và CDN cho static content – tất cả theo best practices AWS cho ecommerce (dựa trên AWS Well-Architected Framework: Reliability pillar).
📘 Tài liệu tham khảo: AWS Well-Architected Framework (Reliability Pillar, cập nhật 2024), Amazon EC2 Auto Scaling docs (2025), Amazon Aurora Multi-AZ (phiên bản 3.x MySQL-compatible).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng:
Deploy the application on EC2 instances across multiple Availability Zones. Put the EC2 instances into an Auto Scaling group behind an Application Load Balancer. Migrate the database to Amazon Aurora Multi-AZ. Use Amazon CloudFront for content delivery.
Lý do chọn đáp án này (với LEAST changes):
- 🛠️ Giữ nguyên EC2 và app code: Chỉ deploy app lên nhiều EC2 instances qua Auto Scaling Group (ASG) ở nhiều AZ → Tự động scale, health checks, replace failed instances.
- Application Load Balancer (ALB): Route traffic đều, hỗ trợ multi-AZ, zero-downtime deployments.
- Amazon Aurora Multi-AZ: Migrate MySQL → Aurora (MySQL-compatible 100%, chỉ thay connection string), tự động failover <30s, replicas cross-AZ.
- Amazon CloudFront: CDN cho static assets (images, JS/CSS), giảm latency, offload EC2.
- Least changes: Không refactor code (vẫn EC2 app), DB migration đơn giản qua DMS hoặc snapshot, tổng chi phí thấp, availability >99.99%. Hoàn hảo cho ecommerce OLTP.
📘 Nguồn: AWS DOP-C02 exam guide (2024), Aurora docs: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-multi-az.html (cập nhật Multi-AZ v3 2025).
📋 Giải thích tất cả các phương án (đúng/sai)
-
❌ Phương án SAI:
Deploy the application by using AWS Fargate containers. Migrate the database to Amazon DynamoDB. Use Amazon API Gateway to route requests.
Giải thích sai: Thay đổi lớn – phải containerize app sang ECS/Fargate (viết Dockerfile, refactor deployment), DB sang DynamoDB NoSQL (phải rewrite queries từ SQL sang key-value), thêm API Gateway (thay đổi API layer). Không phải "least changes", tốn công refactor code cho ecommerce phức tạp. -
✅ Phương án ĐÚNG (như đã phân tích ở trên):
Deploy the application on EC2 instances across multiple Availability Zones. Put the EC2 instances into an Auto Scaling group behind an Application Load Balancer. Migrate the database to Amazon Aurora Multi-AZ. Use Amazon CloudFront for content delivery.
Giải thích đúng: Least changes, high availability multi-AZ, MySQL-compatible, scale dễ dàng. -
❌ Phương án SAI:
Use AWS Elastic Beanstalk to deploy the application across multiple AWS Regions. Migrate the database to Amazon Redshift. Use Amazon ElastiCache for session management.
Giải thích sai: Multi-Regions quá phức tạp (không cần cho HA cơ bản, chỉ multi-AZ là đủ), Redshift là data warehouse OLAP (không phù hợp OLTP ecommerce MySQL), ElastiCache chỉ cho sessions (không giải quyết DB failure). Beanstalk giúp deploy nhưng multi-region tăng latency/cost, không least changes. -
❌ Phương án SAI:
Migrate the application to AWS Lambda functions. Use Amazon S3 for static content hosting. Migrate the database to Amazon DocumentDB (with MongoDB compatibility).
Giải thích sai: Serverless hóa sang Lambda yêu cầu refactor toàn bộ code (stateless, event-driven), DocumentDB MongoDB không compatible MySQL (phải rewrite schema/queries), S3 chỉ static (app dynamic cần Lambda). Thay đổi cực lớn, không phù hợp ecommerce stateful hiện tại.
Kết luận 💡: Giải pháp đúng cân bằng reliability cao + operational simplicity, phù hợp DevOps best practices (IaC với CloudFormation/ASG). Nếu implement, dùng Route 53 cho DNS failover! 🚀
A DevOps engineer needs to implement a consistent deployment solution across all components of the application. The solution must automate the deployments, minimize downtime during updates, and manage configuration data for the application.
Which solution will meet these requirements with the LEAST development effort?
- A Use AWS CloudFormation to define and provision the Lambda functions and ECS services. Implement stack updates with resource replacement for all components. Use AWS Secrets Manager to manage the configuration data.
- B Use AWS CodeDeploy to manage deployments for the Lambda functions and ECS services. Implement canary deployments for the Lambda functions. Implement blue/green deployments for the ECS services. Use AWS Systems Manager Parameter Store to manage the configuration data.
- C Use AWS Step Functions to orchestrate deployments for the Lambda functions and ECS services. Use canary deployments for the Lambda functions and ECS services in a different AWS Region. Use AWS Systems Manager Parameter Store to manage the configuration data.
- D Use AWS Systems Manager to manage deployments for the Lambda functions and ECS services. Implement all-at-once deployments for the Lambda functions. Implement rolling updates for the ECS services. Use AWS Secrets Manager to manage the configuration data.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi tập trung vào việc triển khai một ứng dụng microservices trên AWS, bao gồm AWS Lambda functions và Amazon ECS services, với tần suất deploy thường xuyên. 🛠️ DevOps engineer cần một giải pháp nhất quán cho tất cả components, phải:
- Tự động hóa deployments (automate).
- Giảm thiểu downtime khi cập nhật (minimize downtime).
- Quản lý configuration data (config data như secrets hoặc parameters).
- Yêu cầu LEAST development effort (ít nỗ lực phát triển nhất, nghĩa là dùng dịch vụ managed sẵn có).
📘 Bối cảnh AWS cập nhật đến 2026: AWS CodeDeploy là dịch vụ chuẩn cho deployments zero-downtime trên Lambda (canary/linear) và ECS (blue/green). Parameter Store (trong AWS Systems Manager) là nơi lưu config data an toàn, miễn phí cho standard params. Không cần code custom nhiều.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Use AWS CodeDeploy to manage deployments for the Lambda functions and ECS services. Implement canary deployments for the Lambda functions. Implement blue/green deployments for the ECS services. Use AWS Systems Manager Parameter Store to manage the configuration data.
Lý do chọn 🏆:
- AWS CodeDeploy hỗ trợ nhất quán cho cả Lambda (canary deployments: traffic shift dần dần, giảm rủi ro) và ECS (blue/green: switch traffic zero-downtime giữa blue/green environments).
- Tự động hóa qua appspec.yaml và integration với CodePipeline/CodeBuild, least effort vì managed service, không cần code orchestration phức tạp.
- Parameter Store lý tưởng cho config data (hierarchical, secure, integrate dễ với Lambda/ECS via IAM).
- Đáp ứng tất cả yêu cầu: automate, minimize downtime, consistent, low effort. ✅
Tài liệu tham khảo 📚:
- AWS CodeDeploy for Lambda (canary support).
- ECS Blue/Green with CodeDeploy.
- Systems Manager Parameter Store (updated 2024+).
🔍 Phân tích tất cả các phương án (đúng/sai)
Dưới đây là phân tích từng lựa chọn một cách chi tiết, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá ✅ (đúng) hoặc ❌ (sai), kèm giải thích hoàn toàn bằng tiếng Việt dựa trên best practices AWS DOP-C02 (2024-2026).
-
Phương án 1: Use AWS CloudFormation to define and provision the Lambda functions and ECS services. Implement stack updates with resource replacement for all components. Use AWS Secrets Manager to manage the configuration data.
❌ Sai vì: CloudFormation là IaC provisioning tool, không phải deployment service chuyên cho runtime updates. "Resource replacement" gây downtime cao (delete/create lại resources). Không automate deployments nhất quán cho microservices frequent deploy, cần effort cao để handle traffic shift. Secrets Manager chỉ cho secrets, không phải general config data (overkill và tốn phí). Không meet "minimize downtime" và "least effort". -
Phương án 2: Use AWS CodeDeploy to manage deployments for the Lambda functions and ECS services. Implement canary deployments for the Lambda functions. Implement blue/green deployments for the ECS services. Use AWS Systems Manager Parameter Store to manage the configuration data.
✅ Đúng vì: Như phân tích trên, CodeDeploy native support canary cho Lambda (gradual rollout) và blue/green cho ECS (zero-downtime switch). Parameter Store perfect cho config (free tier, integrate IAM). Least effort với templates sẵn, consistent across components. Ideal cho frequent deploys microservices. -
Phương án 3: Use AWS Step Functions to orchestrate deployments for the Lambda functions and ECS services. Use canary deployments for the Lambda functions and ECS services in a different AWS Region.
❌ Sai vì: Step Functions là workflow orchestrator, không phải deployment tool (phải custom code nhiều states, integrations phức tạp → high effort). Canary cho ECS cần CodeDeploy, không native ở Step Functions. "Different AWS Region" gây latency cao, cross-region costs, không minimize downtime mà còn tăng rủi ro failover. Không consistent và không least effort. -
Phương án 4: Use AWS Systems Manager to manage deployments for the Lambda functions and ECS services. Implement all-at-once deployments for the Lambda functions. Implement rolling updates for the ECS services. Use AWS Secrets Manager to manage the configuration data.
❌ Sai vì: Systems Manager (SSM) chủ yếu cho fleet management (Run Command/State Manager), không support deployments cho Lambda/ECS native như CodeDeploy. "All-at-once" cho Lambda gây downtime lớn (toàn bộ traffic shift đột ngột). Rolling updates ECS cơ bản nhưng không zero-downtime tốt bằng blue/green. Secrets Manager không phải cho general config (chỉ secrets). High effort custom scripts, không automate consistent.
Kết luận 🚀: Phương án 2 là optimal theo AWS Well-Architected DevOps pillar (automation + safety). Sử dụng CodeDeploy + Parameter Store là pattern chuẩn DOP-C02 exam!
Which solution will meet these requirements?
- A Create an AWS Lambda function to run unit tests and generate code coverage reports. Add a Lambda invoke action to a stage in the CodePipeline pipeline. Create an Amazon EventBridge scheduled rule to run hourly to monitor the Lambda function's output. Configure the rule to fail the pipeline if coverage is less than 80%.
- B Create an AWS Step Functions workflow to run unit tests and generate code coverage reports. Add a Step Functions test action to a stage in the CodePipeline pipeline to invoke the workflow. Configure the workflow to fail if the code coverage is less than 80%.
- C Create a CodeBuild project with a buildspec.yml file that includes commands to run unit tests and generate code coverage reports. Add a CodeBuild test action to a stage in the CodePipeline pipeline. Configure the CodeBuild test action to use the source artifacts from the source action as input. Modify the buildspec.yml file to fail the build if coverage is less than 80%.
- D Create a CodeBuild project with Jenkins installed. Configure Jenkins to run unit tests and generate code coverage reports. Add a Jenkins test action to a stage in the CodePipeline pipeline. Configure the Jenkins test action to output the coverage report as an output artifact. Configure an approval action to fail the pipeline if code coverage is less than 80%.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi mô tả một tình huống thực tế trong DevOps trên AWS:
Một công ty đang xây dựng pipeline CI/CD cho ứng dụng bằng AWS CodePipeline và AWS CodeBuild. Họ cần một giải pháp để:
- Chạy unit tests (kiểm thử đơn vị).
- Tự động tạo báo cáo code coverage (phạm vi bao phủ mã nguồn).
- Thực hiện việc này trước khi deploy lên production (giai đoạn trước production).
- Pipeline phải fail (thất bại) nếu code coverage thấp hơn 80%.
🛠️ Yêu cầu chính: Giải pháp phải tích hợp mượt mà vào CodePipeline, sử dụng test action phù hợp, kiểm tra coverage tự động và dừng pipeline nếu không đạt ngưỡng. Đây là best practice trong CI/CD trên AWS, tận dụng CodeBuild để chạy build/test với buildspec.yml (file cấu hình build chuẩn của CodeBuild). Kiến thức dựa trên tài liệu AWS cập nhật đến 2026 (AWS CodePipeline User Guide và CodeBuild Buildspec Reference).
📘 Tài liệu tham khảo:
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng:
Create a CodeBuild project with a buildspec.yml file that includes commands to run unit tests and generate code coverage reports. Add a CodeBuild test action to a stage in the CodePipeline pipeline. Configure the CodeBuild test action to use the source artifacts from the source action as input. Modify the buildspec.yml file to fail the build if coverage is less than 80%.
Lý do chi tiết:
🟢 Đây là giải pháp chuẩn và tối ưu nhất theo best practice AWS. CodeBuild test action trong CodePipeline được thiết kế dành riêng cho unit tests và reporting. File buildspec.yml cho phép:
- Chạy lệnh test (ví dụ:
npm testhoặcpytest). - Generate báo cáo coverage (hỗ trợ JUnit/XML, Cobertura, v.v.).
- Upload reports vào CodeBuild reports group để visualize coverage %.
- Fail build bằng exit code != 0 nếu coverage <80% (qua script kiểm tra, ví dụ:
if [ coverage < 80 ]; then exit 1; fi).
Pipeline sẽ tự động fail stage này, ngăn deploy. Không cần tool ngoài, tích hợp native, scalable và cost-effective. ✅
📋 Phân tích tất cả các phương án (đúng/sai)
Dưới đây là phân tích từng lựa chọn. Tôi giữ nguyên văn bản gốc bằng tiếng Anh, và giải thích hoàn toàn bằng tiếng Việt với lý do đúng/sai:
-
Create an AWS Lambda function to run unit tests and generate code coverage reports. Add a Lambda invoke action to a stage in the CodePipeline pipeline. Create an Amazon EventBridge scheduled rule to run hourly to monitor the Lambda function's output. Configure the rule to fail the pipeline if coverage is less than 80%.
❌ Sai. Lambda invoke action chỉ chạy hàm ngắn hạn (15 phút max), không phù hợp cho unit tests phức tạp hoặc generate reports lớn. EventBridge rule hourly (chạy theo lịch) không liên kết realtime với pipeline execution – nó không theo dõi output của từng pipeline run, dẫn đến fail không đúng lúc. Không có cơ chế native fail pipeline từ EventBridge. Phức tạp và không reliable. -
Create an AWS Step Functions workflow to run unit tests and generate code coverage reports. Add a Step Functions test action to a stage in the CodePipeline pipeline to invoke the workflow. Configure the workflow to fail if the code coverage is less than 80%.
❌ Sai. CodePipeline không có "Step Functions test action" chuẩn (chỉ hỗ trợ invoke Step Functions qua general action, không optimized cho tests). Step Functions mạnh về orchestration dài hạn, nhưng không phải tool cho unit tests/coverage (thiếu reporting native như CodeBuild). Việc fail workflow chỉ dừng Step Functions, không tự động fail CodePipeline stage một cách seamless. Quá phức tạp cho yêu cầu đơn giản. -
Create a CodeBuild project with a buildspec.yml file that includes commands to run unit tests and generate code coverage reports. Add a CodeBuild test action to a stage in the CodePipeline pipeline. Configure the CodeBuild test action to use the source artifacts from the source action as input. Modify the buildspec.yml file to fail the build if coverage is less than 80%.
✅ Đúng (như đã giải thích ở trên). Giải pháp native, hỗ trợ đầy đủ test reports, coverage thresholds qua buildspec, và fail pipeline tự động. Hoàn hảo cho CI/CD. -
Create a CodeBuild project with Jenkins installed. Configure Jenkins to run unit tests and generate code coverage reports. Add a Jenkins test action to a stage in the CodePipeline pipeline. Configure the Jenkins test action to output the coverage report as an output artifact. Configure an approval action to fail the pipeline if code coverage is less than 80%.
❌ Sai. Jenkins trên CodeBuild có thể dùng qua Jenkins action, nhưng approval action là manual (yêu cầu con người approve), không tự động check coverage từ artifact. Phải install/maintain Jenkins thủ công trên CodeBuild (container custom), tăng complexity và overhead. Không có cơ chế tự động fail dựa trên coverage % – approval chỉ fail nếu manual reject. Không phải best practice so với native CodeBuild test action.
Kết luận: 🏆 Sử dụng CodeBuild test action với buildspec.yml là cách native, tự động và hiệu quả nhất trên AWS (2026). Nếu implement, thêm reports: section trong buildspec để visualize coverage trên Console! 🚀
The company wants to create a dashboard that displays the number of successful transactions.
Which solution will meet this requirement with the LEAST operational overhead?
- A Create an Amazon OpenSearch Service cluster and an OpenSearch Service subscription filter to send the log group data to the cluster. Create a dashboard within the Dashboards feature in the OpenSearch Service cluster by using a search query for transactions that have a status of success.
- B Create a CloudWatch subscription filter for the log group that uses an AWS Lambda function. Configure the Lambda function to parse the JSON logs and publish a custom metric to CloudWatch for transactions that have a status of success. Create a CloudWatch dashboard by using a metric graph that displays the custom metric.
- C Create a CloudWatch metric filter for the log groups with a filter pattern that matches the transaction status property and a value of success. Create a CloudWatch dashboard by using a metric graph that displays the new metric.
- D Create an Amazon Kinesis data stream that is subscribed to the log group. Configure the data stream to filter incoming log data based on a status of success and to send the filtered logs to an AWS Lambda function. Configure the Lambda function to publish a custom metric to CloudWatch. Create a CloudWatch dashboard by using a metric graph that displays the custom metric.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi tập trung vào việc tối ưu hóa dashboard hiển thị số lượng giao dịch thành công (successful transactions) từ logs JSON được publish vào Amazon CloudWatch Logs log group. Logs chứa metadata transactions với trường status là "success" hoặc "failure". Yêu cầu chính là giải pháp có ít overhead vận hành nhất (LEAST operational overhead), nghĩa là ưu tiên phương pháp đơn giản, không cần quản lý tài nguyên phức tạp như cluster, stream hay function code.
Chi tiết vấn đề:
- Logs ở định dạng JSON, dễ parse với filter patterns.
- Dashboard cần hiển thị metric đếm số lượng success (ví dụ: Sum hoặc Count metric).
- AWS CloudWatch hỗ trợ metric filters (cập nhật đến 2024-2026) để tự động extract metrics từ logs mà không cần code thêm, rất phù hợp cho real-time monitoring với chi phí thấp và zero management overhead.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng:
Create a CloudWatch metric filter for the log groups with a filter pattern that matches the transaction status property and a value of success. Create a CloudWatch dashboard by using a metric graph that displays the new metric.
Lý do chọn (bằng kiến thức AWS mới nhất):
- 🛠️ CloudWatch metric filters là tính năng native của CloudWatch Logs (hỗ trợ JSON parsing nâng cao từ 2023), cho phép định nghĩa filter pattern như
{ $.status = "success" }để tự động tạo custom metric (ví dụ: SuccessTransactions) mỗi khi log khớp. - 📊 Tạo dashboard chỉ cần kéo-thả metric graph từ metric mới này – zero code, zero provisioning, fully managed bởi AWS.
- Least overhead: Không cần Lambda code, không stream data, không cluster → Tiết kiệm chi phí (pay-per-metric), scale tự động, phù hợp DevOps best practice cho monitoring logs-to-metrics.
📋 Phân tích tất cả các phương án
Dưới đây là phân tích từng phương án một cách chi tiết, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá dựa trên operational overhead (quản lý tài nguyên, code, scale, chi phí). ✅ Đúng duy nhất một cái, ❌ Sai vì phức tạp hơn cần thiết.
-
Phương án 1:
Create an Amazon OpenSearch Service cluster and an OpenSearch Service subscription filter to send the log group data to the cluster. Create a dashboard within the Dashboards feature in the OpenSearch Service cluster by using a search query for transactions that have a status of success.
❌ Sai vì overhead cao: Phải provision OpenSearch cluster (managed nhưng tốn phí cao, cần scale nodes, VPC/security config). Subscription filter đẩy toàn bộ logs → ingest volume lớn, query dashboard chỉ là visualization chứ không phải metric native. Không "least" vì phức tạp cho simple counting (theo AWS Well-Architected: tránh over-engineering cho logs monitoring). -
Phương án 2:
Create a CloudWatch subscription filter for the log group that uses an AWS Lambda function. Configure the Lambda function to parse the JSON logs and publish a custom metric to CloudWatch for transactions that have a status of success. Create a CloudWatch dashboard by using a metric graph that displays the custom metric.
❌ Sai vì overhead trung bình: Subscription filter + Lambda yêu cầu viết code (parse JSON, publish metric via PutMetricData API), manage permissions (IAM role), cold starts, và error handling. Scale tốt nhưng không native như metric filter → Tăng vận hành (debug Lambda, monitor executions), vi phạm least overhead. -
Phương án 3 (ĐÚNG):
Create a CloudWatch metric filter for the log groups with a filter pattern that matches the transaction status property and a value of success. Create a CloudWatch dashboard by using a metric graph that displays the new metric.
✅ Đúng vì least overhead: Metric filter là serverless thuần túy, tự parse JSON với pattern như[status="success"]hoặc{ $.status: "success" }(hỗ trợ nested JSON từ 2022+). Tạo metric tự động (Count/Sum), dashboard chỉ drag-and-drop → Không code, không tài nguyên extra, real-time, chi phí ~$0.50/GB ingested + $0.30/metric/month. -
Phương án 4:
Create an Amazon Kinesis data stream that is subscribed to the log group. Configure the data stream to filter incoming log data based on a status of success and to send the filtered logs to an AWS Lambda function. Configure the Lambda function to publish a custom metric to CloudWatch. Create a CloudWatch dashboard by using a metric graph that displays the custom metric.
❌ Sai vì overhead cao nhất: Kinesis stream cần shard management, throughput config; subscription filter; Lambda code parse/publish → Multi-component (provisioning, monitoring shards/retention, costs ~$0.015/shard-hour + Lambda). Phù hợp high-volume streaming chứ không cho simple log metric → Overkill hoàn toàn.
📘 Tài liệu tham khảo (AWS docs cập nhật 2024-2026)
- CloudWatch Logs Metric Filters: docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html (JSON patterns chi tiết).
- CloudWatch Dashboards: docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-dashboard.html.
- Best Practices Logs Monitoring: AWS Well-Architected Framework - Operational Excellence pillar (Logs to Metrics).
- Exam Tips DOP-C02: Metric filters thường là đáp án "least overhead" cho CloudWatch Logs scenarios.
Hy vọng phân tích này giúp bạn ôn thi hiệu quả! 🚀 Nếu cần ví dụ filter pattern cụ thể, hỏi thêm nhé!