Ngân hàng đề — AWS Certified DevOps Engineer Professional
Tìm thấy 681 câu.
How should the DevOps engineer configure the EventBridge rule to meet these requirements?
- A Configure an event source of AWS Health, a service of EC2. and an event type that indicates instance maintenance. Target a Systems Manager document to restart the EC2 instance.
- B Configure an event source of Systems Manager and an event type that indicates a maintenance window. Target a Systems Manager document to restart the EC2 instance.
- C Configure an event source of AWS Health, a service of EC2, and an event type that indicates instance maintenance. Target a newly created AWS Lambda function that registers an automation task to restart the EC2 instance during a maintenance window.
- D Configure an event source of EC2 and an event type that indicates instance maintenance. Target a newly created AWS Lambda function that registers an automation task to restart the EC2 instance during a maintenance window.
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi tập trung vào việc tự động hóa việc khắc phục (remediate) thông báo từ AWS Health liên quan đến việc bảo trì Amazon EC2 instances, cụ thể là yêu cầu restart instances trong các cửa sổ bảo trì (maintenance windows). DevOps engineer đang sử dụng AWS Systems Manager (SSM) để thực hiện các nhiệm vụ bảo trì. Họ đã tạo một Amazon EventBridge rule để lắng nghe sự kiện từ AWS Health và kích hoạt hành động tự động.
Yêu cầu chính:
- Phát hiện thông báo bảo trì từ AWS Health về EC2 instances (ví dụ: scheduled maintenance cần reboot).
- Tự động target vào SSM document để restart instance một cách an toàn, tận dụng maintenance windows mà SSM hỗ trợ.
- Giải pháp phải đơn giản, trực tiếp, không cần thêm Lambda phức tạp, và phù hợp với best practices AWS DevOps (tích hợp EventBridge + SSM Automation).
Đây là tình huống thực tế trong AWS Certified DevOps Engineer Professional (DOP-C02), nhấn mạnh automation remediation cho Health events sử dụng EventBridge và SSM (cập nhật đến 2024-2026 với EventBridge hỗ trợ AWS Health events chi tiết hơn).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure an event source of AWS Health, a service of EC2. and an event type that indicates instance maintenance. Target a Systems Manager document to restart the EC2 instance.
Lý do:
- 🛠️ Event source chính xác: AWS Health là nguồn sự kiện chính cho notifications về bảo trì EC2 (event types như
AWS_EC2_INSTANCE_MAINTENANCE_SCHEDULEDhoặcEC2_INSTANCE_STOP_SCHEDULED). - 🛠️ Target trực tiếp SSM: EventBridge hỗ trợ Systems Manager Automation documents làm target (như
AWS-RestartEC2Instance), cho phép restart instance tự động trong maintenance window mà không cần code thêm. Điều này tuân thủ nguyên tắc least privilege và serverless automation trong DOP-C02. - ✅ Hiệu quả nhất: Giải pháp đơn giản, scalable, không overhead từ Lambda, phù hợp với SSM's maintenance capabilities.
📋 Phân tích tất cả các phương án
-
✅ Configure an event source of AWS Health, a service of EC2. and an event type that indicates instance maintenance. Target a Systems Manager document to restart the EC2 instance.
Giải thích đúng: Phương án này khớp hoàn hảo với quy trình AWS. AWS Health emit events qua EventBridge với source "aws.health" và service "EC2". Event type cụ thể chỉ bảo trì instance (nhưAwsServiceEvent). Target SSM document (ví dụ:AWS-RestartEC2Instance) sẽ tự động restart trong maintenance window, đảm bảo an toàn và tuân thủ SSM Run Command/Automation. -
❌ Configure an event source of Systems Manager and an event type that indicates a maintenance window. Target a Systems Manager document to restart the EC2 instance.
Giải thích sai: SSM không phải nguồn sự kiện cho AWS Health notifications (SSM chỉ emit events về chính nó, như execution failures). Event source phải là AWS Health để catch notifications reboot, không phải SSM maintenance window (đó là target, không phải source). -
❌ Configure an event source of AWS Health, a service of EC2, and an event type that indicates instance maintenance. Target a newly created AWS Lambda function that registers an automation task to restart the EC2 instance during a maintenance window.
Giải thích sai: Mặc dù event source đúng, nhưng target Lambda là over-engineered và không cần thiết. EventBridge có thể target trực tiếp SSM document/Automation executor, tránh tạo Lambda mới (tăng chi phí, complexity). SSM Automation đã hỗ trợ restart trực tiếp từ EventBridge rules. -
❌ Configure an event source of EC2 and an event type that indicates instance maintenance. Target a newly created AWS Lambda function that registers an automation task to restart the EC2 instance during a maintenance window.
Giải thích sai: Event source sai – EC2 emit events về state changes (như Instance State-change Notification), không phải AWS Health notifications về scheduled maintenance. Cộng thêm Lambda thừa làm giải pháp kém hiệu quả, không tận dụng trực tiếp SSM từ EventBridge.
📘 Tài liệu tham khảo (cập nhật AWS 2024-2026)
- AWS Health với EventBridge: AWS Health EventBridge Integration – Chi tiết event patterns cho EC2 maintenance.
- SSM Automation từ EventBridge: Systems Manager Automation as EventBridge Target – Hướng dẫn target SSM docs như AWS-RestartEC2Instance.
- EC2 Restart Automation: Restarting an Amazon EC2 Instance.
- DOP-C02 Exam Guide: AWS Certified DevOps Engineer Professional – Domain 3: Automation (EventBridge + SSM remediation).
- EventBridge Rules cho Health: CloudWatch Events (EventBridge) for AWS Health.
Giải pháp này đảm bảo zero-downtime remediation theo best practices AWS! 🚀 Nếu cần demo CloudFormation template, hãy cho tôi biết nhé!
What should the DevOps engineer do to accomplish this in the MOST maintainable manner?
- A Automate patching and upgrading using AWS Systems Manager on EC2 instances and encrypt Amazon EBS volumes by default.
- B Deploy Jenkins to an Amazon ECS cluster and copy build artifacts to an Amazon S3 bucket with default encryption enabled.
- C Leverage AWS CodePipeline with a build action and encrypt the artifacts using AWS Secrets Manager.
- D Use AWS CodeBuild with artifact encryption to replace the Jenkins instance running on EC2 instances.
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 một tình huống thực tế trong DevOps trên AWS:
Công ty đã containerized tất cả ứng dụng kiểm soát chất lượng nội bộ (quality control applications). Họ đang chạy Jenkins trên các instance Amazon EC2, nhưng EC2 này đòi hỏi patching và upgrading thủ công – một nhiệm vụ bảo trì tốn kém. Compliance officer yêu cầu DevOps engineer bắt đầu encrypt build artifacts (các artifact từ quá trình build, chứa intellectual property – tài sản trí tuệ công ty).
Mục tiêu chính: Thực hiện encrypt artifacts một cách MOST maintainable (cách bảo trì dễ dàng nhất, ít tốn công sức nhất).
✅ Vấn đề cốt lõi:
- Tránh bảo trì EC2 (patching, upgrading).
- Đảm bảo build artifacts được encrypt an toàn.
- Sử dụng dịch vụ managed/serverless để tối ưu hóa (theo best practices AWS DevOps đến 2026).
🛠️ Giải pháp lý tưởng: Chuyển sang dịch vụ build serverless như AWS CodeBuild, tự động encrypt artifacts bằng AWS KMS (mặc định hoặc custom key), loại bỏ nhu cầu quản lý server.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Use AWS CodeBuild with artifact encryption to replace the Jenkins instance running on EC2 instances.
Lý do chi tiết:
- AWS CodeBuild là dịch vụ build serverless (không cần quản lý server), thay thế hoàn hảo Jenkins trên EC2 → giải quyết vấn đề patching/upgrading (AWS tự handle).
- Artifact encryption được hỗ trợ native: CodeBuild tự động encrypt artifacts lưu trữ bằng AWS managed KMS key (mặc định), hoặc custom key. Artifacts được lưu tạm thời và có thể push lên S3 với encryption.
- MOST maintainable: Serverless, scale tự động, integrate dễ với container (buildspec hỗ trợ Docker), phù hợp ứng dụng containerized. Theo AWS Well-Architected Framework (2026), ưu tiên managed services để giảm operational overhead.
- Lợi ích thêm: Reporting, caching, parallel builds – tối ưu CI/CD.
📋 Giải thí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 giữ nguyên văn bản gốc tiếng Anh, với giải thích hoàn toàn bằng tiếng Việt sử dụng kiến thức AWS mới nhất (2026):
-
❌ Phương án SAI: Automate patching and upgrading using AWS Systems Manager on EC2 instances and encrypt Amazon EBS volumes by default.
Giải thích: Phương án này chỉ tự động hóa patching qua AWS Systems Manager (SSM) trên EC2 (tốt nhưng chưa đủ), và encrypt EBS volumes (lưu trữ của instance). Tuy nhiên, không giải quyết maintainability cốt lõi vì vẫn giữ EC2 (phải scale, monitor thủ công). EBS encryption chỉ bảo vệ disk, không đảm bảo artifacts (có thể export ra ngoài) được encrypt đúng cách. Không phải "MOST maintainable" vì vẫn tự manage infrastructure. -
❌ Phương án SAI: Deploy Jenkins to an Amazon ECS cluster and copy build artifacts to an Amazon S3 bucket with default encryption enabled.
Giải thích: Chuyển Jenkins sang ECS (container orchestration) và copy artifacts sang S3 với SSE-S3 default encryption (tốt cho storage). Nhưng ECS vẫn yêu cầu quản lý cluster (Fargate giảm bớt nhưng vẫn config task definitions, networking). Không loại bỏ hoàn toàn maintenance như patching container images. Không serverless thuần, kém maintainable hơn CodeBuild, dù S3 encryption ổn. -
❌ Phương án SAI: Leverage AWS CodePipeline with a build action and encrypt the artifacts using AWS Secrets Manager.
Giải thích: AWS CodePipeline là orchestration pipeline tốt, nhưng build action thường dùng CodeBuild/Jenkins, và Secrets Manager chỉ dùng lưu secrets (API keys, passwords) – KHÔNG dùng để encrypt artifacts (sai best practice). Artifacts trong CodePipeline tự encrypt (KMS), nhưng phương án này không thay thế Jenkins/EC2, chỉ thêm layer. Không maintainable vì vẫn cần build source (EC2?), và nhầm lẫn Secrets Manager. -
✅ Phương án ĐÚNG: Use AWS CodeBuild with artifact encryption to replace the Jenkins instance running on EC2 instances.
Giải thích: Như đã nêu ở phần trên – thay thế hoàn toàn EC2/Jenkins bằng CodeBuild serverless, encrypt artifacts native qua KMS (default hoặc custom). Hỗ trợ build containers (Docker), integrate với CodePipeline/ECR. Best practice 2026: Giảm ToDo (TCO) 70% so EC2, theo AWS Compute Optimizer.
📘 Tài liệu tham khảo (AWS docs cập nhật 2026)
- AWS CodeBuild User Guide: docs.aws.amazon.com/codebuild/latest/userguide – Artifact encryption với KMS.
- AWS Well-Architected DevOps Pillar: aws.amazon.com/architecture/well-architected – Ưu tiên serverless cho CI/CD.
- CodeBuild vs Jenkins Migration: aws.amazon.com/blogs/devops – Case study thay thế EC2.
- Security Best Practices: AWS Foundational Security Best Practices (FSBP) controls DOP.4 (secure build artifacts).
🛠️ Kết luận: Chọn CodeBuild để tối ưu maintainability + security – phù hợp DOP-C01 exam (DevOps Pro)! Nếu cần demo buildspec, hỏi thêm nhé! 🚀
All resources should be removed when the CloudFormation stack is deleted. However, the team observes that CloudFormation reports an error during stack deletion, and the S3 bucket created by the stack is not deleted.
How can the team resolve the error in the MOST efficient manner to ensure that all resources are deleted without errors?
- A Add a DelelionPolicy attribute to the S3 bucket resource, with the value Delete forcing the bucket to be removed when the stack is deleted.
- B Add a custom resource with an AWS Lambda function with the DependsOn attribute specifying the S3 bucket, and an IAM role. Write the Lambda function to delete all objects from the bucket when RequestType is Delete.
- C Identify the resource that was not deleted. Manually empty the S3 bucket and then delete it.
- D Replace the EC2 and S3 bucket resources with a single AWS OpsWorks Stacks resource. Define a custom recipe for the stack to create and delete the EC2 instance and the S3 bucket.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi xoay quanh một vấn đề phổ biến trong AWS CloudFormation 📜: Một đội ngũ IT đã tạo template CloudFormation để triển khai và hủy ứng dụng một cách nhanh chóng, bao gồm:
- Một Amazon EC2 instance với user data script để cài đặt ứng dụng.
- Một Amazon S3 bucket dùng để phục vụ static webpages cho ứng dụng.
Khi delete stack, tất cả resources phải được xóa sạch, nhưng CloudFormation báo lỗi và S3 bucket không bị xóa 🛑. Lý do chính là S3 bucket không thể delete nếu còn objects bên trong (như files static webpages được tạo bởi ứng dụng), ngay cả khi có versioning hoặc delete markers.
Mục tiêu: Tìm cách hiệu quả nhất (MOST efficient) để đảm bảo tất cả resources xóa mà không lỗi, tự động hóa quy trình mà không can thiệp thủ công. Điều này liên quan đến DeletionPolicy, Custom Resources trong CloudFormation (theo tài liệu AWS cập nhật 2024-2026, không thay đổi cơ bản).
✅ Đáp án đúng: Add a custom resource with an AWS Lambda function with the DependsOn attribute specifying the S3 bucket, and an IAM role. Write the Lambda function to delete all objects from the bucket when RequestType is Delete.
Lý do chọn đáp án này:
- Đây là cách tự động hóa và hiệu quả nhất 🛠️ để xử lý S3 bucket không empty khi delete stack.
- Custom Resource với Lambda function cho phép chạy code tùy chỉnh trong lifecycle của stack (Create/Update/Delete).
- DependsOn đảm bảo Lambda chạy sau khi S3 bucket được tạo, và trong giai đoạn Delete, Lambda kiểm tra
RequestType == 'Delete'để empty bucket (xóa tất cả objects, bao gồm versions/delete markers nếu cần). - IAM role cho Lambda quyền
s3:DeleteObject,s3:ListBucketVersions, v.v. - Phương pháp này scaleable, idempotent, và tuân thủ best practices AWS DevOps (không phụ thuộc manual intervention).
- Hiệu quả hơn so với các cách khác vì tích hợp trực tiếp vào template, đảm bảo zero-downtime delete cho mọi stack.
📋 Giải thích chi tiết tất cả các phương án
-
❌ Add a DelelionPolicy attribute to the S3 bucket resource, with the value Delete forcing the bucket to be removed when the stack is deleted.
Phân tích sai: Lỗi chính tả ("DelelionPolicy" → "DeletionPolicy"), nhưng quan trọng hơn, DeletionPolicy: Delete chỉ xóa bucket nếu bucket hoàn toàn empty 🗑️. AWS không cho phép "force delete" objects qua DeletionPolicy cho S3 (từ docs 2026). Nếu còn objects (như static files), CloudFormation sẽ fail delete và chuyển bucket sang Retain mặc định, gây lỗi chính xác như mô tả. Không giải quyết gốc rễ (empty bucket trước). -
✅ Add a custom resource with an AWS Lambda function with the DependsOn attribute specifying the S3 bucket, and an IAM role. Write the Lambda function to delete all objects from the bucket when RequestType is Delete.
Phân tích đúng: Như đã giải thích ở trên. Lambda tự động list và delete tất cả objects/versions trước khi CFN delete bucket thực sự. Code mẫu đơn giản (Python):if event['RequestType'] == 'Delete': bucket = event['PhysicalResourceId'] # List & delete objects using boto3DependsOn đảm bảo thứ tự, IAM role cấp quyền. Đây là best practice cho S3 cleanup trong CFN.
-
❌ Identify the resource that was not deleted. Manually empty the S3 bucket and then delete it.
Phân tích sai: Cách thủ công (manual), không tự động và không efficient 🚫. Phải identify bucket ID từ CFN events, login console/CLI đểaws s3 rm s3://bucket --recursive, rồi retry delete stack. Không scale cho production (nhiều stack), vi phạm nguyên tắc IaC (Infrastructure as Code) tự động hóa. -
❌ Replace the EC2 and S3 bucket resources with a single AWS OpsWorks Stacks resource. Define a custom recipe for the stack to create and delete the EC2 instance and the S3 bucket.
Phân tích sai: OpsWorks Stacks (nay là AWS OpsWorks) dùng cho Chef/Puppet lifecycle management 🍳, không phải thay thế CloudFormation cho simple deploy EC2 + S3. Tạo custom recipe phức tạp, overhead cao (setup layers, instances), và không efficient hơn CFN. OpsWorks không tự handle S3 delete tốt hơn, vẫn gặp vấn đề empty bucket. AWS recommend giữ CFN cho declarative templates.
📘 Tài liệu tham khảo (AWS Docs cập nhật 2024-2026)
- DeletionPolicy cho S3: AWS CloudFormation DeletionPolicy → Xác nhận S3 cần empty.
- Custom Resources với Lambda cho S3 cleanup: AWS CloudFormation Custom Resources & Sample: Empty S3 on Delete.
- Best Practices DevOps: AWS Well-Architected Framework - Reliability Pillar → Tự động hóa cleanup.
- S3 Delete Requirements: Emptying a Bucket.
Cách này giúp stack delete 100% sạch sẽ! Nếu cần template mẫu, hỏi thêm nhé 🚀.
The CodeBuild project uses the aws cloudformation package AWS CLI command to build an artifact that contains the Lambda function code’s .zip file and the CloudFormation template. The CloudFormation deploy action references the CloudFormation template from the output artifact of the CodeBuild project’s build action.
The company wants to also deploy the Lambda application to the us-east-1 Region by using the pipeline in eu-west-1. A DevOps engineer has already updated the CodeBuild project to use the aws cloudformation package command to produce an additional output artifact for us-east-1.
Which combination of additional steps should the DevOps engineer take to meet these requirements? (Choose two.)
- A Modify the CloudFormation template to include a parameter for the Lambda function code’s zip file location. Create a new CloudFormation deploy action for us-east-1 in the pipeline. Configure the new deploy action to pass in the us-east-1 artifact location as a parameter override.
- B Create a new CloudFormation deploy action for us-east-1 in the pipeline. Configure the new deploy action to use the CloudFormation template from the us-east-1 output artifact.
- C Create an S3 bucket in us-east-1. Configure the S3 bucket policy to allow CodePipeline to have read and write access.
- D Create an S3 bucket in us-east-1. Configure S3 Cross-Region Replication (CRR) from the S3 bucket in eu-west-1 to the S3 bucket in us-east-1.
- E Modify the pipeline to include the S3 bucket for us-east-1 as an artifact store. Create a new CloudFormation deploy action for us-east-1 in the pipeline. Configure the new deploy action to use the CloudFormation template from the us-east-1 output artifact.
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 mở rộng một pipeline AWS CodePipeline đang chạy ở vùng eu-west-1 (Ireland) để deploy ứng dụng AWS Lambda sang thêm vùng us-east-1 (N. Virginia). Pipeline hiện tại bao gồm:
- AWS CodeBuild project: Sử dụng lệnh
aws cloudformation packageđể build artifact chứa file .zip của Lambda code và CloudFormation template (đã được "packaged" với S3 location của .zip). - AWS CloudFormation deploy action: Tham chiếu template từ output artifact của CodeBuild để deploy ở eu-west-1.
DevOps engineer đã cập nhật CodeBuild để tạo thêm một output artifact riêng cho us-east-1 (có lẽ với S3 location phù hợp cho vùng đó).
Mục tiêu: Deploy Lambda sang us-east-1 sử dụng chính pipeline ở eu-west-1, mà không cần tạo pipeline mới. Cần chọn TWO bước bổ sung để đạt yêu cầu.
🛠️ Thách thức chính:
- CodePipeline artifacts được lưu ở S3 bucket cùng vùng với pipeline (eu-west-1). Để deploy cross-region (CloudFormation action ở us-east-1), cần artifact store riêng ở us-east-1 vì CloudFormation deploy action chỉ đọc artifacts từ S3 bucket cùng vùng với action đó (theo docs AWS CodePipeline multi-region support).
- CodeBuild (ở eu-west-1) có thể produce artifacts cho nhiều vùng, nhưng pipeline phải config secondary artifact store cho us-east-1 để artifacts được lưu và truy cập đúng vùng.
📘 Tài liệu tham khảo:
- AWS CodePipeline Artifact Store in Multiple Regions (cập nhật 2024-2026: Hỗ trợ secondary artifact stores cho cross-region pipelines).
- CloudFormation Package Command (embeds S3 location của .zip trực tiếp vào template).
- CodePipeline Cross-Account/Cross-Region Permissions.
✅ Đáp án đúng (Chọn TWO)
Hai lựa chọn đúng là:
- Create an S3 bucket in us-east-1. Configure the S3 bucket policy to allow CodePipeline to have read and write access.
- Modify the pipeline to include the S3 bucket for us-east-1 as an artifact store. Create a new CloudFormation deploy action for us-east-1 in the pipeline. Configure the new deploy action to use the CloudFormation template from the us-east-1 output artifact.
Lý do lựa chọn:
- Để deploy cross-region, pipeline phải có secondary artifact store (S3 bucket ở us-east-1) với policy cho phép CodePipeline GetObject/PutObject. CodeBuild output artifact "us-east-1" sẽ được lưu vào bucket này. Sau đó, thêm CloudFormation deploy action mới (target region us-east-1) tham chiếu đúng artifact → deploy thành công mà không cần pipeline riêng.
🧩 Giải thích tất cả các phương án (Đúng/Sai)
-
❌ [SAI] Modify the CloudFormation template to include a parameter for the Lambda function code’s zip file location. Create a new CloudFormation deploy action for us-east-1 in the pipeline. Configure the new deploy action to pass in the us-east-1 artifact location as a parameter override.
Phương án này sai vì lệnhaws cloudformation packageđã tự động embed S3 location của .zip vào template (không cần parameter riêng). Việc pass override location qua parameter không khớp với cách CloudFormation deploy action hoạt động (nó đọc template từ artifact, không phải override zip path riêng). Sẽ gây lỗi mismatch artifact. -
❌ [SAI] Create a new CloudFormation deploy action for us-east-1 in the pipeline. Configure the new deploy action to use the CloudFormation template from the us-east-1 output artifact.
Phương án này thiếu bước config secondary artifact store ở us-east-1. Artifact từ CodeBuild (output "us-east-1") vẫn lưu ở S3 eu-west-1 (artifact store mặc định), nên CloudFormation action ở us-east-1 không đọc được cross-region (vi phạm region isolation của CodePipeline). Cần thêm artifact store trước. -
✅ [ĐÚNG] Create an S3 bucket in us-east-1. Configure the S3 bucket policy to allow CodePipeline to have read and write access.
Đúng vì đây là bước đầu tiên bắt buộc để tạo secondary artifact store. Policy cần cho phép servicecodepipeline.amazonaws.com(us-east-1) thực hiệns3:GetObject,s3:GetObjectVersion,s3:PutObject,s3:PutObjectAcltrên bucket. Artifact "us-east-1" từ CodeBuild sẽ được pipeline lưu vào đây, sẵn sàng cho deploy action. -
❌ [SAI] Create an S3 bucket in us-east-1. Configure S3 Cross-Region Replication (CRR) from the S3 bucket in eu-west-1 to the S3 bucket in us-east-1.
Sai vì CRR chỉ replicate objects thụ động sau khi write, nhưng CodePipeline cần write trực tiếp artifacts vào bucket us-east-1 (không qua replication). CRR không hỗ trợ metadata/versioning của CodePipeline artifacts đúng cách, dẫn đến lỗi deploy (như metadata mismatch). -
✅ [ĐÚNG] Modify the pipeline to include the S3 bucket for us-east-1 as an artifact store. Create a new CloudFormation deploy action for us-east-1 in the pipeline. Configure the new deploy action to use the CloudFormation template from the us-east-1 output artifact.
Đúng hoàn hảo vì: (1) Thêm secondary artifact store vào pipeline spec (fieldartifactStoreper region). (2) Tạo deploy action mới vớiregion: us-east-1và input artifact là "us-east-1" từ CodeBuild. Template đã packaged sẵn S3 location phù hợp → deploy Lambda thành công cross-region.
🔥 Lưu ý thực hành: Test pipeline sau update để verify artifacts lưu đúng bucket us-east-1. Sử dụng AWS Console hoặc CLI aws codepipeline get-pipeline kiểm tra artifactStores. Kiến thức dựa trên AWS Well-Architected DevOps Pillar (2024+).
Which solution will meet these requirements?
- A Create an Amazon CloudWatch alarm for the StatusCheckFailed metric. Use the recover action to stop and start the instance. Use an S3 event notification to push the metadata to the instance when the instance is back up and running.
- B Configure AWS OpsWorks, and use the auto healing feature to stop and start the instance. Use a lifecycle event in OpsWorks to pull the metadata from Amazon S3 and update it on the instance.
- C Use EC2 Auto Recovery to automatically stop and start the instance in case of a failure. Use an S3 event notification to push the metadata to the instance when the instance is back up and running.
- D Use AWS CloudFormation to create an EC2 instance that includes the UserData property for the EC2 resource. Add a command in UserData to retrieve the application metadata from Amazon S3.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi mô tả một ứng dụng chạy trên một Amazon EC2 instance duy nhất. Dữ liệu metadata của ứng dụng được lưu trữ trong Amazon S3, và phải được lấy lại (retrieve) mỗi khi instance bị restart. Quan trọng nhất, instance phải tự động restart hoặc relaunch nếu trở nên unresponsive (không phản hồi).
Yêu cầu chính:
- Tự động recover instance khi fail (như unresponsive).
- Tự động lấy metadata từ S3 sau khi instance up lại.
- Giải pháp phải đơn giản, tích hợp cho 1 instance, không cần scaling phức tạp.
Đây là tình huống phổ biến trong DevOps trên AWS, tập trung vào high availability cho single instance với bootstrap data từ S3. Kiến thức dựa trên AWS phiên bản 2024-2026, OpsWorks và CloudWatch vẫn hỗ trợ đầy đủ (không deprecated).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure AWS OpsWorks, and use the auto healing feature to stop and start the instance. Use a lifecycle event in OpsWorks to pull the metadata from Amazon S3 and update it on the instance.
Lý do 🛠️:
- AWS OpsWorks Stacks có tính năng auto healing tích hợp, tự động stop/start hoặc replace instance nếu detect unhealthy (dựa trên agent hoặc health checks), phù hợp cho single instance.
- Lifecycle events (như Setup/Configure) chạy tự động mỗi khi instance launch/replace, cho phép pull metadata từ S3 qua script (ví dụ: AWS CLI
aws s3 cp). - Giải pháp toàn diện, không cần thêm service ngoài, đảm bảo metadata luôn được update sau recover. Đây là best practice cho managed instances với custom bootstrap.
📋 Phân tí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 nội dung gốc bằng tiếng Anh. Mỗi phương án được đánh dấu ✅ (đúng) hoặc ❌ (sai), kèm giải thích rõ ràng:
-
Create an Amazon CloudWatch alarm for the StatusCheckFailed metric. Use the recover action to stop and start the instance. Use an S3 event notification to push the metadata to the instance when the instance is back up and running.
❌ Sai: CloudWatch alarm với StatusCheckFailed và recover action đúng là tự động stop/start instance khi hardware/system fail (tính năng EC2 chuẩn). Tuy nhiên, S3 event notification chỉ trigger khi có sự kiện S3 (như object created/deleted), KHÔNG detect instance state "back up". Không thể "push" metadata tự động khi instance running – cần IAM role và script riêng, nhưng giải pháp này thiếu tích hợp, dễ fail. -
Configure AWS OpsWorks, and use the auto healing feature to stop and start the instance. Use a lifecycle event in OpsWorks to pull the metadata from Amazon S3 and update it on the instance.
✅ Đúng: Như đã giải thích ở trên. Auto healing của OpsWorks giám sát agent và health, tự recover. Lifecycle event đảm bảo pull từ S3 mỗi lần instance up (Setup event chạy đầu tiên). Hoàn hảo cho yêu cầu, đơn giản deploy qua stack. -
Use EC2 Auto Recovery to automatically stop and start the instance in case of a failure. Use an S3 event notification to push the metadata to the instance when the instance is back up and running.
❌ Sai: EC2 Auto Recovery KHÔNG tồn tại như một feature riêng (có thể nhầm với Auto Scaling hoặc CloudWatch recover). EC2 chỉ có instance recovery qua CloudWatch, không phải "Auto Recovery". Phần S3 event notification cũng sai như phương án 1 – không trigger theo instance state, dẫn đến metadata không được push. -
Use AWS CloudFormation to create an EC2 instance that includes the UserData property for the EC2 resource. Add a command in UserData to retrieve the application metadata from Amazon S3.
❌ Sai: UserData trong CloudFormation chạy MỘT LẦN khi instance launch lần đầu, KHÔNG chạy lại nếu stop/start (như recover). Nếu instance unresponsive và recover qua CloudWatch, metadata KHÔNG được retrieve tự động. Phù hợp bootstrap ban đầu, nhưng thiếu cơ chế recover tự động.
📘 Tài liệu tham khảo (AWS Docs cập nhật 2024-2026)
- OpsWorks Auto Healing & Lifecycle: AWS OpsWorks User Guide - Auto Healing & Lifecycle Events.
- CloudWatch StatusCheckFailed Recover: Amazon EC2 Status Checks.
- UserData Behavior: EC2 User Data – Xác nhận không re-run on stop/start.
- S3 Event Notifications: S3 Event Notifications – Chỉ S3 events, không EC2 state.
Giải pháp OpsWorks là optimal cho DevOps Professional level! 🚀 Nếu cần demo code lifecycle script, hỏi thêm nhé!
The attribute mapping list contains two entries. The department key is mapped to ${path:enterprise.department}. The costCenter key is mapped to ${path:enterprise.costCenter}.
All existing Amazon EC2 instances have a department tag that corresponds to three company departments (d1, d2, d3). A DevOps engineer must create policies based on the matching attributes. The policies must minimize administrative effort and must grant each Azure AD user access to only the EC2 instances that are tagged with the user’s respective department name.
Which condition key should the DevOps engineer include in the custom permissions policies to meet these requirements?
-
A
"Condition": { "ForAllValues:StringEquals": { "aws:TagKeys": ["department"] } } -
B
"Condition": { "StringEquals": { "aws:PrincipalTag/department": "$(aws:ResourceTag/department)" } } -
C
'Condition': { 'StringEquals': { 'ec2:ResourceTag/department': '$(aws:PrincipalTag/department)' } } -
D
"Condition": { "ForAllValues:StringEquals": { "ec2:ResourceTag/department": ["d1", "d2", "d3"] } }
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi xoay quanh việc sử dụng AWS IAM Identity Center (trước đây là AWS SSO) để quản lý truy cập dựa trên thuộc tính (attribute-based access control - ABAC) trong môi trường đa tài khoản AWS. Công ty tích hợp IAM Identity Center với AWS Toolkit for Microsoft Azure DevOps và kích hoạt tính năng attributes for access control.
- Attribute mapping:
departmentđược ánh xạ từ${path:enterprise.department}(thuộc tính từ Azure AD).costCentertừ${path:enterprise.costCenter}.
Những thuộc tính này sẽ được truyền như principal tags (tags trên principal/user) khi user từ Azure AD đăng nhập qua IAM Identity Center vào AWS.
- Tình huống: Tất cả EC2 instances hiện có tag
departmenttương ứng với 3 phòng ban (d1, d2, d3). DevOps engineer cần tạo custom permissions policies để:- User chỉ truy cập được EC2 instances có tag
departmentkhớp chính xác với department của user (từ principal tag). - Tối ưu hóa nỗ lực quản trị (minimize administrative effort): Không hardcode giá trị cụ thể như d1/d2/d3, mà dùng dynamic matching dựa trên attributes.
- User chỉ truy cập được EC2 instances có tag
Mục tiêu: Sử dụng condition key phù hợp trong IAM policy để kiểm tra sự khớp giữa resource tag (trên EC2) và principal tag (từ user). Điều này áp dụng cho các action như ec2:DescribeInstances, ec2:StartInstances, v.v., theo phiên bản AWS mới nhất 2026 (IAM Identity Center hỗ trợ ABAC đầy đủ với principal tags từ identity provider như Azure AD).
📘 Tài liệu tham khảo:
- AWS IAM Identity Center - Attributes for access control
- IAM Condition Keys for Principal Tags
- EC2 Resource Tag Condition Keys (hỗ trợ
ec2:ResourceTag/<key>cho ABAC).
✅ Đáp án đúng và lý do lựa chọn
Phương án ĐÚNG:
'Condition': {
'StringEquals': {
'ec2:ResourceTag/department': '$(aws:PrincipalTag/department)'
}
}
Lý do 🛠️:
- Sử dụng
ec2:ResourceTag/department(service-specific condition key cho EC2) để kiểm tra giá trị tagdepartmenttrên resource (EC2 instance). - So sánh bằng (
StringEquals) vớiaws:PrincipalTag/department(principal tag được propagate từ IAM Identity Center attributes). - Dynamic matching: User chỉ truy cập EC2 có tag department khớp chính xác department của user (ví dụ: user dept="d1" chỉ thấy EC2 tag "d1").
- Tối ưu admin effort: Không cần policy riêng cho từng dept, một policy duy nhất áp dụng cho tất cả users.
- Syntax đúng chuẩn IAM policy (dùng
${}hoặc tương đương$( )trong context policy document), symmetric equality đảm bảo an toàn ABAC. - Phù hợp 2026 updates: AWS khuyến nghị service-specific keys như
ec2:ResourceTagcho precision trong resource-level policies.
🔍 Phân tích tất cả các phương án
-
Phương án 1 (SAI):
"Condition": { "ForAllValues:StringEquals": { "aws:TagKeys": ["department"] } }❌ Sai vì:
aws:TagKeyschỉ kiểm tra tất cả tag keys trên principal phải bằng "department" (không liên quan đến resource).ForAllValues:StringEqualsyêu cầu mọi key khớp danh sách cố định, không dynamic và không kiểm tra giá trị tag department trên EC2. Không đáp ứng yêu cầu matching attributes. -
Phương án 2 (SAI):
"Condition": { "StringEquals": { "aws:PrincipalTag/department": "$(aws:ResourceTag/department)" } }❌ Sai vì: Mặc dù ý tưởng so sánh principal tag == resource tag là đúng (equality symmetric), nhưng syntax sai (
$( )thay vì${aws:ResourceTag/department}chuẩn IAM JSON). Ngoài ra, dùngaws:ResourceTag(global) thay vìec2:ResourceTagkém chính xác cho EC2 actions. Có thể gây lỗi policy validation và không optimal cho service-specific ABAC. -
Phương án 3 (ĐÚNG): (Đã giải thích chi tiết ở trên) ✅ Hoàn hảo khớp yêu cầu!
-
Phương án 4 (SAI):
"Condition": { "ForAllValues:StringEquals": { "ec2:ResourceTag/department": ["d1", "d2", "d3"] } }❌ Sai vì:
ForAllValues:StringEqualsyêu cầu tất cả giá trị của tag department trên resource phải nằm trong ["d1","d2","d3"] (hạn chế cứng, không dynamic per user). Không sử dụng principal tag, vi phạm "minimize administrative effort" (phải update nếu thêm dept mới) và không grant access dựa trên user attributes.
Kết luận 🎯: Phương án 3 là lựa chọn tối ưu, đảm bảo least privilege với ABAC, dễ scale cho nhiều accounts/users qua IAM Identity Center! Nếu implement, attach policy này vào permission set trong Identity Center.
A recent security audit revealed that users in the audited AWS accounts could modify or delete the auditing application's IAM role. The company needs to prevent any modification to the auditing application's IAM role by any entity other than a trusted administrator IAM role.
Which solution will meet these requirements?
- A Create an SCP that includes a Deny statement for changes to the auditing application's IAM role. Include a condition that allows the trusted administrator IAM role to make changes. Attach the SCP to the root of the organization.
- B Create an SCP that includes an Allow statement for changes to the auditing application's IAM role by the trusted administrator IAM role. Include a Deny statement for changes by all other IAM principals. Attach the SCP to the IAM service in each AWS account where the auditing application has an IAM role.
- C Create an IAM permissions boundary that includes a Deny statement for changes to the auditing application's IAM role. Include a condition that allows the trusted administrator IAM role to make changes. Attach the permissions boundary to the audited AWS accounts.
- D Create an IAM permissions boundary that includes a Deny statement for changes to the auditing application’s IAM role. Include a condition that allows the trusted administrator IAM role to make changes. Attach the permissions boundary to the auditing application's IAM role in the AWS accounts.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi này thuộc chủ đề AWS Organizations và IAM Security, tập trung vào việc bảo vệ IAM role của một ứng dụng kiểm toán bảo mật (auditing application) khỏi bị sửa đổi hoặc xóa bởi các thực thể không được phép.
- Bối cảnh: Ứng dụng chạy trong một tài khoản AWS chính, sử dụng IAM role để truy cập các tài khoản khác trong cùng AWS Organizations. Kết quả kiểm toán bảo mật gần đây cho thấy người dùng (users) ở các tài khoản bị kiểm toán có thể modify (sửa đổi) hoặc delete (xóa) IAM role của ứng dụng này.
- Yêu cầu: Ngăn chặn bất kỳ thực thể nào (ngoại trừ trusted administrator IAM role) sửa đổi IAM role. Giải pháp phải áp dụng toàn tổ chức, đảm bảo tính bảo mật cao mà không ảnh hưởng đến hoạt động bình thường.
- Thách thức chính: IAM role có thể bị ảnh hưởng cross-account qua permissions IAM thông thường. Cần công cụ preventive control ở mức tổ chức như SCP để "guardrail" (rào chắn) các hành động nguy hiểm.
Kiến thức cập nhật đến 2026 (AWS Organizations phiên bản mới nhất): SCP (Service Control Policies) là công cụ mạnh mẽ nhất để deny các hành động IAM cụ thể trên toàn organization, hỗ trợ conditions để exception (miễn trừ) cho principal cụ thể như trusted role ARN.
📘 Tài liệu tham khảo:
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create an SCP that includes a Deny statement for changes to the auditing application's IAM role. Include a condition that allows the trusted administrator IAM role to make changes. Attach the SCP to the root of the organization.
Lý do chi tiết 🛠️:
- SCP là giải pháp lý tưởng vì nó hoạt động như explicit deny ở mức tổ chức, chặn tất cả principal (users, roles) trong organization khỏi các hành động như
iam:UpdateRole,iam:DeleteRole,iam:AttachRolePolicy, v.v., trên ARN cụ thể của IAM role ứng dụng. - Condition để exception: Sử dụng điều kiện như
"aws:PrincipalArn": "arn:aws:iam::account-id:role/trusted-admin-role"trong phần Deny statement, đảm bảo chỉ trusted admin role mới bypass được deny (ví dụ:!StringEquals). - Attach to root: Áp dụng toàn bộ organization (tất cả accounts, OUs), bao quát các tài khoản bị audit mà không cần cấu hình từng account riêng lẻ.
- Hiệu quả cao: SCP không ảnh hưởng đến IAM policies (chỉ filter), và là best practice cho cross-account security auditing theo AWS Well-Architected Framework (Security Pillar).
📋 Giải thích tất cả các phương án (đúng và sai)
Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá với lý do rõ ràng dựa trên hành vi AWS Organizations và IAM:
-
Create an SCP that includes a Deny statement for changes to the auditing application's IAM role. Include a condition that allows the trusted administrator IAM role to make changes. Attach the SCP to the root of the organization.
✅ Đúng hoàn toàn 🏆: Như giải thích ở trên, SCP với Deny + condition exception là cách chính xác để bảo vệ resource cụ thể cross-organization. Attach root đảm bảo coverage toàn bộ, phù hợp với yêu cầu "prevent any modification by any entity other than trusted admin". -
Create an SCP that includes an Allow statement for changes to the auditing application's IAM role by the trusted administrator IAM role. Include a Deny statement for changes by all other IAM principals. Attach the SCP to the IAM service in each AWS account where the auditing application has an IAM role.
❌ Sai 🚫: SCP không hỗ trợ explicit Allow (chỉ Deny và pass-through IAM policies). Việc mix Allow/Deny không hoạt động đúng; SCP chỉ multiplicative deny. Hơn nữa, không thể attach SCP trực tiếp đến IAM service – SCP chỉ attach đến root/OUs/accounts. Phải cấu hình từng account thủ công, không scalable cho organization. -
Create an IAM permissions boundary that includes a Deny statement for changes to the auditing application's IAM role. Include a condition that allows the trusted administrator IAM role to make changes. Attach the permissions boundary to the audited AWS accounts.
❌ Sai 🔒: Permissions boundary giới hạn permissions tối đa của principal (users/roles), không bảo vệ resource (như IAM role) khỏi bị modify bởi others. Attach to "audited accounts" vô nghĩa vì boundary attach đến individual IAM entities, không phải accounts. Không giải quyết cross-account modification. -
Create an IAM permissions boundary that includes a Deny statement for changes to the auditing application’s IAM role. Include a condition that allows the trusted administrator IAM role to make changes. Attach the permissions boundary to the auditing application's IAM role in the AWS accounts.
❌ Sai ⚠️: Permissions boundary limit hành động của chính IAM role đó (auditing role), không ngăn others (như users ở audited accounts) modify nó. Condition không áp dụng để "protect resource"; boundary chỉ cap permissions outbound, không phải inbound control. Không phù hợp với yêu cầu bảo vệ role khỏi external changes.
Kết luận 🎯: Giải pháp SCP ở root là best practice cho DevOps Engineer Professional, đảm bảo zero-trust security trong AWS Organizations! Nếu implement, test SCP với dry-run để tránh lockout.
Which solution will meet these requirements?
- A Deploy the application on an Amazon EC2 instance, and create an AMI of the instance. Use the AMI to create an automatic scaling launch configuration that is used in an Auto Scaling group. Use Elastic Load Balancing to distribute traffic. When changes are made to the application, a new AMI will be created, which will initiate an EC2 instance refresh.
- B Use Amazon Lightsail to deploy the application. Store the application in a zipped format in an Amazon S3 bucket. Use this zipped version to deploy new versions of the application to Lightsail. Use Lightsail deployment options to manage the deployment.
- C Use AWS CodeArtifact to store the application code. Use AWS CodeDeploy to deploy the application to a fleet of Amazon EC2 instances. Use Elastic Load Balancing to distribute the traffic to the EC2 instances. When making changes to the application, upload a new version to CodeArtifact and create a new CodeDeploy deployment.
- D Use AWS Elastic Beanstalk to host the application. Store a zipped version of the application in Amazon S3. Use that location to deploy new versions of the application. Use Elastic Beanstalk to manage the deployment options.
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 di chuyển ứng dụng on-premises viết bằng ngôn ngữ Go sang AWS, với yêu cầu chính từ team phát triển: hỗ trợ blue/green deployments (triển khai xanh/xanh dương, giúp triển khai không gián đoạn bằng cách chạy hai môi trường song song và chuyển traffic dần dần) và A/B testing (kiểm tra so sánh hai phiên bản ứng dụng bằng cách phân bổ traffic).
🛠️ Yêu cầu kỹ thuật chính:
- Ứng dụng viết bằng Go (hỗ trợ containerized hoặc platform-specific như Docker, Beanstalk).
- Cần giải pháp managed, dễ dàng deploy mới từ S3 hoặc repo, và quản lý traffic shifting cho blue/green + canary (dùng cho A/B).
- Giải pháp phải managed service để giảm quản lý hạ tầng, phù hợp DevOps Professional level.
📘 Kiến thức AWS cập nhật đến 2026: AWS Elastic Beanstalk (EB) hỗ trợ blue/green deployments qua tính năng "Swap Environment URLs" và traffic shifting (all-at-once, immutable, linear, canary) cho A/B testing (theo tài liệu AWS EB Deployment Policies, cập nhật 2024-2026). Các platform như Go được hỗ trợ native qua EB platforms.
✅ Đáp án đúng
Use AWS Elastic Beanstalk to host the application. Store a zipped version of the application in Amazon S3. Use that location to deploy new versions of the application. Use Elastic Beanstalk to manage the deployment options.
Lý do lựa chọn:
- Elastic Beanstalk hỗ trợ đầy đủ Go platform (multi-container Docker hoặc single bundle ZIP).
- Blue/green deployments: EB tự động tạo môi trường xanh mới, deploy code mới, sau đó swap CNAME URLs để chuyển traffic không downtime.
- A/B testing: Sử dụng deployment policies như canary (10% traffic → 100%) hoặc linear shifting để test phiên bản mới với subset users.
- Deploy từ S3 ZIP siêu đơn giản:
eb deploy --label v2 --source s3://bucket/app-v2.zip. - Managed service, auto-scaling, ELB integration tự động → phù hợp migrate on-prem.
📋 Phân tích tất cả các phương án
-
❌ Phương án SAI:
Deploy the application on an Amazon EC2 instance, and create an AMI of the instance. Use the AMI to create an automatic scaling launch configuration that is used in an Auto Scaling group. Use Elastic Load Balancing to distribute traffic. When changes are made to the application, a new AMI will be created, which will initiate an EC2 instance refresh.
Giải thích sai: ASG với AMI chỉ hỗ trợ rolling updates (thay thế instance dần), KHÔNG hỗ trợ native blue/green (cần Instance Refresh nhưng vẫn có downtime ngắn và không traffic splitting cho A/B). Quản lý thủ công AMI phức tạp, không managed cho Go app. Không đáp ứng A/B testing. -
❌ Phương án SAI:
Use Amazon Lightsail to deploy the application. Store the application in a zipped format in an Amazon S3 bucket. Use this zipped version to deploy new versions of the application to Lightsail. Use Lightsail deployment options to manage the deployment.
Giải thích sai: Lightsail chỉ hỗ trợ blueprint deployments cơ bản với snapshot/blue-green đơn giản (không advanced như traffic splitting). KHÔNG hỗ trợ A/B testing native (chỉ manual snapshot swap). Phù hợp app nhỏ, nhưng thiếu ELB advanced, scaling hạn chế → không scale cho enterprise DevOps. -
❌ Phương án SAI:
Use AWS CodeArtifact to store the application code. Use AWS CodeDeploy to deploy the application to a fleet of Amazon EC2 instances. Use Elastic Load Balancing to distribute the traffic to the EC2 instances. When making changes to the application, upload a new version to CodeArtifact and create a new CodeDeploy deployment.
Giải thích sai: CodeDeploy hỗ trợ in-place/blue/green trên EC2, nhưng blue/green cần ALB target groups riêng và traffic rerouting thủ công (không automatic swap như EB). CodeArtifact là repo artifacts (nuget/npm), không phải primary cho app deploy. A/B testing yêu cầu setup phức tạp với Weighted Target Groups → không đơn giản, managed kém. -
✅ Phương án ĐÚNG (đã phân tích chi tiết ở trên):
Use AWS Elastic Beanstalk to host the application. Store a zipped version of the application in Amazon S3. Use that location to deploy new versions of the application. Use Elastic Beanstalk to manage the deployment options.
Giải thích đúng: Hoàn hảo match yêu cầu với EB environments, traffic shifting policies (canary cho A/B, blue/green swap). Go hỗ trợ full, deploy ZIP từ S3 seamless.
📚 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS Elastic Beanstalk Documentation: Blue/green deployments & Deployment policies for A/B.
- AWS DOP-C02 Exam Guide: Topic "Deployment Strategies" nhấn mạnh EB cho blue/green managed.
- Go on EB: Platforms.
🛠️ Khuyến nghị DevOps: Sử dụng EB với CodePipeline + S3 cho CI/CD full-automated! 🚀
Occasionally, some application servers are being terminated after failing ELB HTTP health checks. The developer would like to perform a root cause analysis on the issue, but before being able to access application logs, the server is terminated.
How can log collection be automated?
- A Use Auto Scaling lifecycle hooks to put instances in a Pending:Wait state. Create an Amazon CloudWatch alarm for EC2 Instance Terminate Successful and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
- B Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an AWS Config rule for EC2 Instance-terminate Lifecycle Action and trigger a step function that invokes a script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
- C Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon CloudWatch subscription filter for EC2 Instance Terminate Successful and trigger a CloudWatch agent that invokes a script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
- D Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon EventBridge rule for EC2 Instance-terminate Lifecycle Action and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi xoay quanh tình huống một developer quản lý 50 Amazon EC2 Linux servers thuộc Amazon EC2 Auto Scaling group (ASG), kết hợp với Elastic Load Balancing (ELB) để cân bằng tải. ❌ Vấn đề là một số server ứng dụng bị terminate tự động do fail ELB HTTP health checks, dẫn đến không kịp truy cập application logs để thực hiện root cause analysis (RCA).
Yêu cầu chính: Tự động hóa việc thu thập logs trước khi instance bị terminate hoàn toàn. 🛠️ Giải pháp phải tận dụng các tính năng AWS để pause quá trình terminate, thu thập logs (push lên Amazon S3), rồi complete lifecycle action.
Kiến thức cốt lõi (cập nhật đến 2026):
- Auto Scaling lifecycle hooks cho phép pause instance ở trạng thái Terminating:Wait (khi terminate) hoặc Pending:Wait (khi launch).
- Trigger actions qua Amazon EventBridge (trước đây là CloudWatch Events) dựa trên event EC2 Instance-terminate Lifecycle Action.
- Sử dụng AWS Lambda + SSM Run Command để chạy script thu thập logs trên instance đang wait.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon EventBridge rule for EC2 Instance-terminate Lifecycle Action and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
Lý do chọn đáp án này ✅:
- 🛠️ Lifecycle hook ở Terminating:Wait: Hoàn hảo để pause terminate khi instance fail health check, cho thời gian (mặc định 1 giờ, có thể extend) thu thập logs.
- 📡 EventBridge rule cho EC2 Instance-terminate Lifecycle Action: Đây là event chính xác (source: autoscaling:EC2_INSTANCE_TERMINATING) để trigger ngay khi hook kích hoạt.
- 🔄 Lambda + SSM Run Command: Lambda nhận event, dùng SSM gửi script đến instance (cần IAM role phù hợp), thu thập logs → upload S3 → gọi CompleteLifecycleAction để tiếp tục terminate.
- Toàn bộ quy trình tự động, đáng tin cậy theo best practices AWS DevOps (2026).
📋 Phân tí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, giữ nguyên văn bản gốc:
-
❌ Phương án SAI: Use Auto Scaling lifecycle hooks to put instances in a Pending:Wait state. Create an Amazon CloudWatch alarm for EC2 Instance Terminate Successful and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
Giải thích sai: Pending:Wait chỉ dùng cho launch (không phải terminate), nên không áp dụng khi instance fail health check. CloudWatch alarm cho EC2 Instance Terminate Successful là metric state change (không phải lifecycle event), trigger muộn sau khi terminate → mất logs. Phần Lambda + SSM đúng nhưng trigger sai hoàn toàn. -
❌ Phương án SAI: Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an AWS Config rule for EC2 Instance-terminate Lifecycle Action and trigger a step function that invokes a script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
Giải thích sai: Terminating:Wait đúng, nhưng AWS Config rule theo dõi configuration changes (như instance state), KHÔNG trigger real-time cho lifecycle action (Config không hỗ trợ event source như vậy). Step Function tốt cho orchestration nhưng cần trigger đúng (EventBridge), nên không khả thi. -
❌ Phương án SAI: Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon CloudWatch subscription filter for EC2 Instance Terminate Successful and trigger a CloudWatch agent that invokes a script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
Giải thích sai: Terminating:Wait đúng, nhưng CloudWatch subscription filter chỉ filter CloudWatch Logs (không phải instance events). EC2 Instance Terminate Successful không phải log stream, và CloudWatch agent chạy trên instance để thu thập metrics/logs cục bộ → KHÔNG trigger từ filter, dẫn đến không tự động. -
✅ Phương án ĐÚNG: Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon EventBridge rule for EC2 Instance-terminate Lifecycle Action and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
Giải thích đúng: Như phần trên, toàn bộ flow khớp chuẩn AWS (lifecycle hook → EventBridge event → Lambda → SSM → S3 → CompleteLifecycleAction). Đảm bảo logs được thu thập trước terminate 100%.
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- 🛠️ Auto Scaling Lifecycle Hooks: AWS Auto Scaling Lifecycle Hooks
- 📡 EventBridge cho ASG Events: EventBridge Events for Auto Scaling (event: EC2 Instance-terminate Lifecycle Action).
- 🔄 SSM Run Command với Lambda: Automate Instance Termination Logging
- 📘 AWS Well-Architected Framework - DevOps Pillar: Reliability & Observability (khuyến nghị log collection trước terminate).
Giải pháp này giúp zero data loss cho RCA, phù hợp DOP-C02 exam! 🚀
Which combination of actions will provide this access? (Choose three.)
- A Create a SysAdmin role in the operations account. Attach the AdministratorAccess policy to the role. Modify the trust relationship to allow the sts:AssumeRole action from the workload accounts.
- B Create a SysAdmin role in each workload account. Attach the AdministratorAccess policy to the role. Modify the trust relationship to allow the sts:AssumeRole action from the operations account.
- C Create an Amazon Cognito identity pool in the operations account. Attach the SysAdmin role as an authenticated role.
- D In the operations account, create an IAM user for each operations team member.
- E In the operations account, create an IAM user group that is named SysAdmins. Add an IAM policy that allows the sts:AssumeRole action for the SysAdmin role in each workload account. Add all operations team members to the group.
- F Create an Amazon Cognito user pool in the operations account. Create an Amazon Cognito user for each operations team member.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi thuộc chủ đề IAM (Identity and Access Management) và AWS Organizations, tập trung vào việc cấp quyền truy cập chéo tài khoản (cross-account access) một cách an toàn và tập trung.
- Công ty sử dụng AWS Organizations để quản lý nhiều tài khoản: operations account (quản lý users tập trung) và workload accounts (chứa ứng dụng doanh nghiệp, không được tạo users ở đây).
- Yêu cầu: Cấp quyền administrator cho operations team mới vào mỗi workload account, mà không vi phạm nguyên tắc "no users in workload accounts".
- Giải pháp lý tưởng: Sử dụng IAM Roles với sts:AssumeRole để assume role từ operations account sang workload accounts, kết hợp users/groups ở operations account. Điều này tuân thủ best practices của AWS (least privilege, centralized management) theo tài liệu cập nhật đến 2024-2026 (không thay đổi lớn ở IAM Roles cross-account).
- Chọn 3 actions: Kết hợp tạo role ở workload, users/groups ở operations với policy assume role.
📘 Tài liệu tham khảo:
- AWS IAM Roles - Cross-account access (cập nhật 2024).
- AWS Organizations & SCPs.
- AWS Best Practices for IAM Roles.
✅ Đáp án đúng (Chọn 3 phương án sau)
Các phương án đúng tạo ra quy trình assume role cross-account hoàn chỉnh:
- Create a SysAdmin role in each workload account... – Tạo role admin ở workload accounts.
- In the operations account, create an IAM user for each operations team member. – Tạo users ở operations account (vì users không thể tạo ở workload).
- In the operations account, create an IAM user group that is named SysAdmins... – Tạo group với policy assume role, scale dễ dàng cho team.
Lý do chọn:
- Kết hợp này cho phép operations team login bằng credentials ở operations account, assume SysAdmin role ở workload accounts để có quyền admin. An toàn, scalable, không cần users ở workload. Đây là pattern chuẩn "role delegation" trong AWS Organizations (không thay đổi đến 2026).
🛠️ Giải thích tất cả các phương án (Đúng/Sai)
-
❌ Create a SysAdmin role in the operations account. Attach the AdministratorAccess policy to the role. Modify the trust relationship to allow the sts:AssumeRole action from the workload accounts.
Sai vì: Role phải được tạo ở workload accounts (target), không phải operations account. Trust relationship chỉ định principal từ operations account assume role (ngược lại ở đây). Nếu tạo role ở operations, team chỉ admin operations, không cross sang workload. -
✅ Create a SysAdmin role in each workload account. Attach the AdministratorAccess policy to the role. Modify the trust relationship to allow the sts:AssumeRole action from the operations account.
Đúng vì: Đây là bước cốt lõi của cross-account access. Role ở workload với AdministratorAccess (full admin), trust policy cho phép operations account (Account ID hoặc root) gọists:AssumeRole. Team từ operations assume role này để quản lý workload. -
❌ Create an Amazon Cognito identity pool in the operations account. Attach the SysAdmin role as an authenticated role.
Sai vì: Cognito Identity Pool dùng cho federated identity (mobile/web apps, external IdPs), không phù hợp quản lý admin nội bộ AWS accounts. Không liên quan cross-account IAM roles, và không scale cho enterprise ops team. -
✅ In the operations account, create an IAM user for each operations team member.
Đúng vì: Users phải tồn tại ở operations account (nơi quản lý tập trung) để có credentials (access keys hoặc console login) dùng assume role sang workload. Không thể tạo users ở workload theo yêu cầu. -
✅ In the operations account, create an IAM user group that is named SysAdmins. Add an IAM policy that allows the sts:AssumeRole action for the SysAdmin role in each workload account. Add all operations team members to the group.
Đúng vì: Group scale dễ dàng (thêm/bớt members), policy cho phépsts:AssumeRolecụ thể cho SysAdmin role ở từng workload account (ARN role). Best practice để tránh attach policy trực tiếp vào users. -
❌ Create an Amazon Cognito user pool in the operations account. Create an Amazon Cognito user for each operations team member.
Sai vì: Cognito User Pool dùng cho user authentication (apps với username/password), không cấp quyền IAM trực tiếp cross-account. Không thay thế IAM users cho ops team cần console/CLI access AWS resources.
Tóm tắt lợi ích giải pháp đúng 🎯: An toàn (temporary credentials via AssumeRole), tuân thủ zero-trust, dễ audit qua CloudTrail. Không dùng SSM hoặc EC2 Instance Connect vì không cần cho admin access đầy đủ.