Ngân hàng đề — AWS Certified DevOps Engineer Professional

Tìm thấy 681 câu.

Câu 311
A company is implementing a well-architected design for its globally accessible API stack. The design needs to ensure both high reliability and fast response times for users located in North America and Europe.
The API stack contains the following three tiers:

Amazon API Gateway -

AWS Lambda -

Amazon DynamoDB -
Which solution will meet the requirements?
  1. A Configure Amazon Route 53 to point to API Gateway APIs in North America and Europe using health checks. Configure the APIs to forward requests to a Lambda function in that Region. Configure the Lambda functions to retrieve and update the data in a DynamoDB table in the same Region as the Lambda function.
  2. B Configure Amazon Route 53 to point to API Gateway APIs in North America and Europe using latency-based routing and health checks. Configure the APIs to forward requests to a Lambda function in that Region. Configure the Lambda functions to retrieve and update the data in a DynamoDB global table.
  3. C Configure Amazon Route 53 to point to API Gateway in North America, create a disaster recovery API in Europe, and configure both APIs to forward requests to the Lambda functions in that Region. Retrieve the data from a DynamoDB global table. Deploy a Lambda function to check the North America API health every 5 minutes. In the event of a failure, update Route 53 to point to the disaster recovery API.
  4. D Configure Amazon Route 53 to point to API Gateway API in North America using latency-based routing. Configure the API to forward requests to the Lambda function in the Region nearest to the user. Configure the Lambda function to retrieve and update the data in a DynamoDB table.
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 thiết kế một API stack toàn cầu (Amazon API Gateway → AWS Lambda → Amazon DynamoDB) theo nguyên tắc AWS Well-Architected Framework, đảm bảo high reliability (độ tin cậy cao, tránh downtime) và fast response times (thời gian phản hồi nhanh) cho người dùng ở North America và Europe.

🛠️ Yêu cầu chính:

  • Global accessibility: API phải phục vụ người dùng từ nhiều khu vực địa lý.
  • High reliability: Sử dụng cơ chế failover tự động để tránh single point of failure (ví dụ: health checks).
  • Fast response times: Giảm độ trễ bằng cách routing request đến region gần người dùng nhất (latency-based).
  • Well-architected design: Tuân thủ các pillar như Reliability (P9: Multi-region resilience), Performance Efficiency (P3: Low-latency global APIs), và Operational Excellence.

Stack này cần multi-region deployment để tránh bottleneck ở một region duy nhất, kết hợp data consistency cho DynamoDB (sử dụng Global Tables để replicate dữ liệu real-time giữa các region).

📈 Vấn đề cốt lõi: Không thể dùng single-region (ví dụ chỉ North America) vì sẽ chậm cho Europe. Cần routing thông minh + data sync toàn cầu.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Configure Amazon Route 53 to point to API Gateway APIs in North America and Europe using latency-based routing and health checks. Configure the APIs to forward requests to a Lambda function in that Region. Configure the Lambda functions to retrieve and update the data in a DynamoDB global table.

Lý do chọn ✅:

  • Latency-based routing của Route 53 tự động route request đến API Gateway gần nhất (North America hoặc Europe), giảm độ trễ tối ưu (dựa trên latency thực tế từ user).
  • Health checks đảm bảo failover tự động nếu một region down, tăng reliability.
  • Lambda per region xử lý request local, nhanh chóng.
  • DynamoDB Global Tables (tính năng mới nhất AWS đến 2026) replicate dữ liệu multi-master real-time giữa regions, đảm bảo strong consistency và low-latency reads/writes toàn cầu mà không cần code phức tạp.
  • Hoàn hảo match Well-Architected: Reliability (RTO/RPO thấp), Performance (global low-latency), Cost-optimized.

🔍 Giải thích tất cả các phương án

  • Phương án 1 ❌:
    Configure Amazon Route 53 to point to API Gateway APIs in North America and Europe using health checks. Configure the APIs to forward requests to a Lambda function in that Region. Configure the Lambda functions to retrieve and update the data in a DynamoDB table in the same Region as the Lambda function.
    Giải thích sai ❌: Chỉ dùng health checks (failover khi down) nhưng không có latency-based routing, nên request từ Europe có thể vẫn route đến North America nếu healthy → response time chậm. DynamoDB local table per region gây data inconsistency (dữ liệu không sync giữa regions, cần custom replication phức tạp). Không đạt fast response + reliability toàn diện.

  • Phương án 2 ✅:
    Configure Amazon Route 53 to point to API Gateway APIs in North America and Europe using latency-based routing and health checks. Configure the APIs to forward requests to a Lambda function in that Region. Configure the Lambda functions to retrieve and update the data in a DynamoDB global table.
    Giải thích đúng ✅: Kết hợp latency-based + health checks cho routing thông minh và failover tự động. Lambda local giảm cold start. DynamoDB Global Tables sync dữ liệu eventually consistent hoặc strong consistent (on-demand capacity mode mới nhất 2026), lý tưởng cho global API. Đáp ứng đầy đủ yêu cầu.

  • Phương án 3 ❌:
    Configure Amazon Route 53 to point to API Gateway in North America, create a disaster recovery API in Europe, and configure both APIs to forward requests to the Lambda functions in that Region. Retrieve the data from a DynamoDB global table. Deploy a Lambda function to check the North America API health every 5 minutes. In the event of a failure, update Route 53 to point to the disaster recovery API.
    Giải thích sai ❌: Primary-only ở North America với manual failover (Lambda check 5 phút + update Route 53) → RTO cao (ít nhất 5 phút), không reliable (không tự động). Không dùng latency-routing nên Europe luôn chậm trừ khi failover. Dù dùng Global Tables tốt, nhưng tổng thể không fast response bình thường.

  • Phương án 4 ❌:
    Configure Amazon Route 53 to point to API Gateway API in North America using latency-based routing. Configure the API to forward requests to the Lambda function in the Region nearest to the user. Configure the Lambda function to retrieve and update the data in a DynamoDB table.
    Giải thích sai ❌: API Gateway chỉ ở North America → latency-routing vô hiệu (không có endpoint Europe). "Lambda nearest to user" mơ hồ, không khả thi vì API Gateway không tự route cross-region Lambda dễ dàng (cần VPC peering phức tạp). DynamoDB local table → inconsistency. Không multi-region thực sự.

📘 Tài liệu tham khảo (AWS cập nhật đến 2026)

🛡️ Kết luận: Phương án 2 là best practice cho global serverless API! Nếu deploy thực tế, test với Chaos Engineering (AWS Fault Injection Simulator).

Câu 312
A rapidly growing company wants to scale for developer demand for AWS development environments. Development environments are created manually in the AWS Management Console. The networking team uses AWS CloudFormation to manage the networking infrastructure, exporting stack output values for the Amazon VPC and all subnets. The development environments have common standards, such as Application Load Balancers, Amazon EC2 Auto Scaling groups, security groups, and Amazon DynamoDB tables.
To keep up with demand, the DevOps engineer wants to automate the creation of development environments. Because the infrastructure required to support the application is expected to grow, there must be a way to easily update the deployed infrastructure. CloudFormation will be used to create a template for the development environments.
Which approach will meet these requirements and quickly provide consistent AWS environments for developers?
  1. A Use Fn::ImportValue intrinsic functions in the Resources section of the template to retrieve Virtual Private Cloud (VPC) and subnet values. Use CloudFormation StackSets for the development environments, using the Count input parameter to indicate the number of environments needed. Use the UpdateStackSet command to update existing development environments.
  2. B Use nested stacks to define common infrastructure components. To access the exported values, use TemplateURL to reference the networking team’s template. To retrieve Virtual Private Cloud (VPC) and subnet values, use Fn::ImportValue intrinsic functions in the Parameters section of the root template. Use the CreateChangeSet and ExecuteChangeSet commands to update existing development environments.
  3. C Use nested stacks to define common infrastructure components. Use Fn::ImportValue intrinsic functions with the resources of the nested stack to retrieve Virtual Private Cloud (VPC) and subnet values. Use the CreateChangeSet and ExecuteChangeSet commands to update existing development environments.
  4. D Use Fn::ImportValue intrinsic functions in the Parameters section of the root template to retrieve Virtual Private Cloud (VPC) and subnet values. Define the development resources in the order they need to be created in the CloudFormation nested stacks. Use the CreateChangeSet. and ExecuteChangeSet commands to update existing development environments.
Xem giải thích

🧩 Giải thích nội dung câu hỏi một cách chi tiết

Câu hỏi xoay quanh một công ty đang phát triển nhanh chóng, cần scale môi trường phát triển AWS (development environments) để đáp ứng nhu cầu lập trình viên. Hiện tại:

  • Môi trường dev được tạo thủ công qua AWS Management Console 📱.
  • Đội networking quản lý hạ tầng mạng (VPC, subnets) bằng AWS CloudFormation, và export stack output values để các team khác có thể sử dụng 🛤️.
  • Môi trường dev có tiêu chuẩn chung: Application Load Balancers (ALB), Amazon EC2 Auto Scaling groups (ASG), security groups (SG), và Amazon DynamoDB tables 🔄.

Yêu cầu chính của DevOps engineer:

  • Tự động hóa việc tạo môi trường dev để nhanh chóng và nhất quán ⚡.
  • Dễ dàng update hạ tầng khi infra phát triển (grow) trong tương lai 📈.
  • Sử dụng CloudFormation template để tạo template cho dev environments 🛠️.

Mục tiêu: Phương án nào đáp ứng yêu cầu, cung cấp môi trường AWS nhất quán nhanh chóng cho developers? Câu hỏi tập trung vào cách import giá trị VPC/subnets đã export, sử dụng nested stacks cho components chung, và cách update stack hiệu quả (không gián đoạn).

📘 Tài liệu tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Use nested stacks to define common infrastructure components. Use Fn::ImportValue intrinsic functions with the resources of the nested stack to retrieve Virtual Private Cloud (VPC) and subnet values. Use the CreateChangeSet and ExecuteChangeSet commands to update existing development environments.

Lý do chi tiết:

  • 🛠️ Nested stacks lý tưởng để định nghĩa common infrastructure components (như ALB, ASG, SG, DynamoDB) – giúp template root gọn gàng, dễ maintain và reuse khi infra grow 📦.
  • Fn::ImportValue được sử dụng trực tiếp trong resources của nested stack để lấy VPC/subnet values đã export từ networking stack – điều này đảm bảo nested stack độc lập, không phụ thuộc parameters từ root, và nhất quán khi deploy nhiều env ⚙️.
  • CreateChangeSet + ExecuteChangeSet cho phép preview thay đổi trước khi apply, giảm rủi ro downtime, dễ update infra phát triển (drift detection tự động hỗ trợ từ CFN 2023+) 🔄.
  • Phương án này scale nhanh, tự động, nhất quán cho nhiều dev env, phù hợp best practice AWS DevOps (modular templates) 🚀.

📋 Phân tích tất cả các phương án (đúng/sai)

  • ❌ Phương án SAI 1: Use Fn::ImportValue intrinsic functions in the Resources section of the template to retrieve Virtual Private Cloud (VPC) and subnet values. Use CloudFormation StackSets for the development environments, using the Count input parameter to indicate the number of environments needed. Use the UpdateStackSet command to update existing development environments.

    • Lý do sai: Fn::ImportValue trong Resources của root template có thể dùng, nhưng StackSets dành cho multi-account/region deployment lớn (enterprise-scale), không phù hợp dev env cá nhân hóa (không có "Count parameter" chuẩn). UpdateStackSet phức tạp, không nhanh cho dev demand. Không dùng nested stacks cho common components → thiếu modular ❌.
  • ❌ Phương án SAI 2: Use nested stacks to define common infrastructure components. To access the exported values, use TemplateURL to reference the networking team’s template. To retrieve Virtual Private Cloud (VPC) and subnet values, use Fn::ImportValue intrinsic functions in the Parameters section of the root template. Use the CreateChangeSet and ExecuteChangeSet commands to update existing development environments.

    • Lý do sai: TemplateURL dùng để reference nested template URL (S3), không phải "access exported values" từ networking template đã deploy riêng (export outputs qua Fn::ImportValue). Fn::ImportValue trong Parameters của root đúng cú pháp nhưng làm root phụ thuộc, nested không tự import → khó scale independent env. Phần còn lại tốt nhưng sai cơ bản ở export access 🧩.
  • ✅ Phương án ĐÚNG: Use nested stacks to define common infrastructure components. Use Fn::ImportValue intrinsic functions with the resources of the nested stack to retrieve Virtual Private Cloud (VPC) and subnet values. Use the CreateChangeSet and ExecuteChangeSet commands to update existing development environments.

    • Lý do đúng: Như đã giải thích ở trên – nested stacks + Fn::ImportValue trực tiếp trong nested resources đảm bảo modular, independent, dễ update. ChangeSets an toàn cho grow infra. Hoàn hảo cho automate consistent dev envs ⚡ (best practice CFN 2026).
  • ❌ Phương án SAI 4: Use Fn::ImportValue intrinsic functions in the Parameters section of the root template to retrieve Virtual Private Cloud (VPC) and subnet values. Define the development resources in the order they need to be created in the CloudFormation nested stacks. Use the CreateChangeSet. and ExecuteChangeSet commands to update existing development environments.

    • Lý do sai: Fn::ImportValue trong Parameters root đúng nhưng buộc root pass xuống nested (phụ thuộc). "Define resources in order" không chuẩn – CFN tự handle dependencies qua DependsOn hoặc implicit, không cần manual order → dễ lỗi, không scalable. Thiếu lợi ích nested stacks đầy đủ cho common components 🔧.
Câu 313
A company uses AWS Organizations to manage multiple accounts. Information security policies require that all unencrypted Amazon EBS volumes be marked as non-compliant. A DevOps engineer needs to automatically deploy the solution and ensure that this compliance check is always present.
Which solution will accomplish this?
  1. A Create an AWS CloudFormation template that defines an AWS Inspector rule to check whether EBS encryption is enabled. Save the template to an Amazon S3 bucket that has been shared with all accounts within the company. Update the account creation script pointing to the CloudFormation template in Amazon S3.
  2. B Create an AWS Config organizational rule to check whether EBS encryption is enabled and deploy the rule using the AWS CLI. Create and apply an SCP to prohibit stopping and deleting AWS Config across the organization.
  3. C Create an SCP in Organizations. Set the policy to prevent the launch of Amazon EC2 instances without encryption on the EBS volumes using a conditional expression. Apply the SCP to all AWS accounts. Use Amazon Athena to analyze the AWS CloudTrail output, looking for events that deny an ec2:RunInstances action.
  4. D Deploy an IAM role to all accounts from a single trusted account. Build a pipeline with AWS CodePipeline with a stage in AWS Lambda to assume the IAM role, and list all EBS volumes in the account. Publish a report to Amazon S3.
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 tuân thủ bảo mật (compliance) trong môi trường AWS Organizations quản lý nhiều tài khoản AWS. Cụ thể:

  • Công ty yêu cầu tất cả Amazon EBS volumes không được mã hóa phải bị đánh dấu là non-compliant (không tuân thủ).
  • DevOps engineer cần triển khai giải pháp tự động (automatically deploy) và đảm bảo kiểm tra compliance luôn tồn tại (always present) trên toàn tổ chức, không bị xóa hoặc dừng.
    📌 Yêu cầu chính: Giải pháp phải cross-account (áp dụng cho tất cả tài khoản), tự động hóa cao, không thể bị vô hiệu hóa dễ dàng, và sử dụng các dịch vụ AWS mới nhất (cập nhật đến 2026, AWS Config hỗ trợ organizational conformance packs và rules để kiểm tra EBS encryption tại aws-config-rule:encrypted-volumes).

✅ Đáp án đúng: Phương án B

Create an AWS Config organizational rule to check whether EBS encryption is enabled and deploy the rule using the AWS CLI. Create and apply an SCP to prohibit stopping and deleting AWS Config across the organization.

Lý do chọn đáp án này:

  • 🛠️ AWS Config organizational rule cho phép deploy rule kiểm tra EBS encryption (sử dụng managed rule ENCRYPTED-VOLUMES) một lần duy nhất từ management account, tự động áp dụng cho tất cả tài khoản member trong Organizations (cross-account compliance).
  • 📊 Rule sẽ liên tục đánh dấu non-compliant cho EBS volumes không mã hóa, và báo cáo luôn cập nhật.
  • 🔒 SCP (Service Control Policy) ngăn chặn việc StopConfigurationRecorder, DeleteConfigRule, hoặc xóa AWS Config, đảm bảo compliance check luôn present mà không cần can thiệp thủ công.
  • 🚀 Deploy qua AWS CLI đơn giản, tự động (ví dụ: aws configservice put-organization-config-rule). Đây là best practice cho multi-account theo AWS Well-Architected Framework (DevOps Pillar).
    ✅ Hoàn hảo khớp yêu cầu: Tự động, persistent, và scalable đến 2026.

🔍 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 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 tính khả thi, tự động hóa, và compliance.

  • Phương án A ❌ (SAI):
    Create an AWS CloudFormation template that defines an AWS Inspector rule to check whether EBS encryption is enabled. Save the template to an Amazon S3 bucket that has been shared with all accounts within the company. Update the account creation script pointing to the CloudFormation template in Amazon S3.
    Lý do sai:

    • 🛡️ AWS Inspector không kiểm tra EBS encryption (chỉ scan EC2 vulnerabilities, network reachability; không phải compliance rule cho volumes). Không có rule Inspector cho EBS encryption (xác nhận docs 2026).
    • 📦 CloudFormation + S3 chỉ deploy lúc tạo account mới, không tự động cho existing accounts, và có thể bị xóa thủ công → không ensure always present.
    • Không cross-account native như Organizations.
  • Phương án B ✅ (ĐÚNG):
    (Đã phân tích ở trên - lý do đúng hoàn hảo).

  • Phương án C ❌ (SAI):
    Create an SCP in Organizations. Set the policy to prevent the launch of Amazon EC2 instances without encryption on the EBS volumes using a conditional expression. Apply the SCP to all AWS accounts. Use Amazon Athena to analyze the AWS CloudTrail output, looking for events that deny an ec2:RunInstances action.
    Lý do sai:

    • 🔒 SCP chỉ preventive (ngăn launch EC2 với EBS không mã hóa qua condition ec2:Encrypted = false), nhưng không đánh dấu existing/unencrypted volumes là non-compliant (SCP không retroactive, chỉ block future actions).
    • 🕵️ Athena + CloudTrail chỉ analyze logs sau sự kiện deny, không monitor liên tục hay đánh dấu compliance realtime. Không giải quyết "all unencrypted EBS volumes" hiện tại.
    • ❌ Không tự động deploy check always present.
  • Phương án D ❌ (SAI):
    Deploy an IAM role to all accounts from a single trusted account. Build a pipeline with AWS CodePipeline with a stage in AWS Lambda to assume the IAM role, and list all EBS volumes in the account. Publish a report to Amazon S3.
    Lý do sai:

    • 🔄 Pipeline + Lambda + CodePipeline chỉ scan định kỳ (không continuous), và không đánh dấu non-compliant tự động trong AWS native (chỉ publish report S3 thủ công xem).
    • 📈 Không sử dụng AWS Config (native compliance tool), dễ bị dừng pipeline → không ensure always present. IAM role cross-account phức tạp, không scalable cho Organizations.
    • ❌ Không phải giải pháp tự động chuẩn cho compliance EBS.

📘 Tài liệu tham khảo (AWS Docs cập nhật 2026)

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ụ CLI code, hỏi thêm nhé!

Câu 314 Chọn nhiều đáp án
A company is performing vulnerability scanning for all Amazon EC2 instances across many accounts. The accounts are in an organization in AWS Organizations. Each account's VPCs are attached to a shared transit gateway. The VPCs send traffic to the internet through a central egress VPC. The company has enabled Amazon Inspector in a delegated administrator account and has enabled scanning for all member accounts.
A DevOps engineer discovers that some EC2 instances are listed in the "not scanning" tab in Amazon Inspector.
Which combination of actions should the DevOps engineer take to resolve this issue? (Choose three.)
  1. A Verify that AWS Systems Manager Agent is installed and is running on the EC2 instances that Amazon Inspector is not scanning.
  2. B Associate the target EC2 instances with security groups that allow outbound communication on port 443 to the AWS Systems Manager service endpoint.
  3. C Grant inspector:StartAssessmentRun permissions to the IAM role that the DevOps engineer is using.
  4. D Configure EC2 Instance Connect for the EC2 instances that Amazon Inspector is not scanning.
  5. E Associate the target EC2 instances with instance profiles that grant permissions to communicate with AWS Systems Manager.
  6. F Create a managed-instance activation. Use the Activation Code and the Activation ID to register the EC2 instances.
Xem giải thích

🧩 Phân tích chi tiết câu hỏi

Câu hỏi mô tả tình huống thực tế trong môi trường AWS Organizations:
Một công ty đang thực hiện quét lỗ hổng (vulnerability scanning) cho tất cả các instance Amazon EC2 trên nhiều tài khoản (accounts). Các tài khoản này thuộc một tổ chức AWS Organizations. Mỗi VPC của các tài khoản được kết nối qua shared transit gateway, và lưu lượng ra internet được định tuyến qua central egress VPC. Công ty đã kích hoạt Amazon Inspector ở tài khoản delegated administrator và đã bật quét cho tất cả các tài khoản thành viên (member accounts).

Tuy nhiên, DevOps engineer phát hiện một số EC2 instances nằm trong tab "not scanning" trên Amazon Inspector.
Vấn đề cốt lõi: Amazon Inspector (phiên bản cập nhật đến 2026) yêu cầu các EC2 instances phải đáp ứng các điều kiện tiên quyết (prerequisites) để quét thành công, bao gồm:

  • SSM Agent (AWS Systems Manager Agent) phải được cài đặt và chạy.
  • Instance profile (IAM role gắn vào instance) phải có quyền truy cập SSM services.
  • Network connectivity: Phải có kết nối outbound HTTPS (port 443) đến các SSM endpoints (vì Inspector sử dụng SSM để thu thập dữ liệu inventory và scan).

Do kiến trúc sử dụng transit gateway và central egress, lưu lượng có thể bị chặn nếu security groups/NACLs không cho phép. Câu hỏi yêu cầu chọn kết hợp 3 hành động để khắc phục (resolve) vấn đề này.

📘 Tài liệu tham khảo chính (cập nhật AWS 2026):

✅ Đáp án đúng (Chọn 3 phương án sau)

Các phương án đúng tập trung vào các yêu cầu bắt buộc của Amazon Inspector cho EC2 scanning: SSM Agent, IAM permissions qua instance profile, và network access outbound đến SSM. Đây là nguyên nhân phổ biến khiến instances rơi vào "not scanning".

  1. Verify that AWS Systems Manager Agent is installed and is running on the EC2 instances that Amazon Inspector is not scanning. ✅
    (SSM Agent là thành phần cốt lõi để Inspector thu thập dữ liệu scan.)

  2. Associate the target EC2 instances with security groups that allow outbound communication on port 443 to the AWS Systems Manager service endpoint. ✅
    (Đảm bảo kết nối mạng qua transit gateway/egress VPC không bị chặn.)

  3. Associate the target EC2 instances with instance profiles that grant permissions to communicate with AWS Systems Manager. ✅
    (Cung cấp IAM quyền cho instance giao tiếp với SSM service.)

🛠️ Giải thích chi tiết 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 logic, dựa trên yêu cầu kỹ thuật chính xác của Amazon Inspector (không scan nếu thiếu bất kỳ yếu tố nào dưới đây). Tôi giữ nguyên văn bản gốc bằng tiếng Anh, chỉ giải thích bằng tiếng Việt.

  • Verify that AWS Systems Manager Agent is installed and is running on the EC2 instances that Amazon Inspector is not scanning.
    ✅ ĐÚNG. SSM Agent (phiên bản mới nhất 3.x trở lên) là bắt buộc cho Inspector scan EC2. Inspector sử dụng SSM Inventory để thu thập thông tin package và vulnerability. Nếu agent không cài đặt hoặc không chạy, instance sẽ ở trạng thái "not scanning". DevOps cần kiểm tra qua SSM console hoặc lệnh sudo systemctl status amazon-ssm-agent.

  • Associate the target EC2 instances with security groups that allow outbound communication on port 443 to the AWS Systems Manager service endpoint.
    ✅ ĐÚNG. Trong kiến trúc transit gateway + central egress VPC, security groups phải cho phép outbound TCP/443 đến SSM endpoints (ví dụ: ssm.region.amazonaws.com, ssmmessages.region.amazonaws.com). Nếu bị chặn, agent không thể báo cáo dữ liệu lên AWS, dẫn đến "not scanning". Sử dụng VPC endpoints cho SSM nếu muốn private connectivity.

  • Grant inspector:StartAssessmentRun permissions to the IAM role that the DevOps engineer is using.
    ❌ SAI. Quyền inspector:StartAssessmentRun chỉ dùng để khởi động assessment run thủ công ở console/API. Ở đây, delegated administrator đã enable scanning tự động cho member accounts qua Organizations, nên không cần quyền này cho engineer. Vấn đề là ở instances, không phải permissions của user/engineer.

  • Configure EC2 Instance Connect for the EC2 instances that Amazon Inspector is not scanning.
    ❌ SAI. EC2 Instance Connect chỉ dùng để kết nối SSH tạm thời (push-based auth), không liên quan đến Inspector hoặc SSM. Nó không giúp agent giao tiếp với AWS services.

  • Associate the target EC2 instances with instance profiles that grant permissions to communicate with AWS Systems Manager.
    ✅ ĐÚNG. Instance profile (IAM role) phải gắn managed policy như AmazonSSMManagedInstanceCore (bao gồm ssm:PutInventory, ssm:UpdateInstanceInformation). Không có profile này, agent không authenticate được với SSM, gây "not scanning".

  • Create a managed-instance activation. Use the Activation Code and the Activation ID to register the EC2 instances.
    ❌ SAI. Managed-instance activation dùng cho hybrid/on-premises servers (không phải EC2 thuần), để đăng ký chúng như managed nodes trong SSM. Với EC2 instances (cloud-native), chỉ cần SSM Agent + instance profile là đủ, không cần activation code/ID.

📋 Kết luận & Lời khuyên thực hành

Kết hợp 3 ✅ trên sẽ resolve hoàn toàn, vì chúng bao quát SSM Agent → IAM → Network – bộ ba tiên quyết của Inspector. Sau khi áp dụng, kiểm tra lại tab "not scanning" sau 24h (scan cycle).
🛠️ Best practice: Sử dụng SSM Automation hoặc AWS Config rules để tự động hóa kiểm tra prerequisites trên fleet EC2. Nếu dùng private subnet, thêm VPC endpoints cho SSM/Inspector.

Nếu cần lab thực hành, tham khảo AWS Skill Builder hoặc Qwiklabs: Amazon Inspector Deep Dive! 🚀

Câu 315
A development team uses AWS CodeCommit for version control for applications. The development team uses AWS CodePipeline, AWS CodeBuild. and AWS CodeDeploy for CI/CD infrastructure. In CodeCommit, the development team recently merged pull requests that did not pass long-running tests in the code base. The development team needed to perform rollbacks to branches in the codebase, resulting in lost time and wasted effort.
A DevOps engineer must automate testing of pull requests in CodeCommit to ensure that reviewers more easily see the results of automated tests as part of the pull request review.
What should the DevOps engineer do to meet this requirement?
  1. A Create an Amazon EventBridge rule that reacts to the pullRequestStatusChanged event. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild badge as a comment on the pull request so that developers will see the badge in their code review.
  2. B Create an Amazon EventBridge rule that reacts to the pullRequestCreated event. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild test results as a comment on the pull request when the test results are complete.
  3. C Create an Amazon EventBridge rule that reacts to pullRequestCreated and pullRequestSourceBranchUpdated events. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild badge as a comment on the pull request so that developers will see the badge in their code review.
  4. D Create an Amazon EventBridge rule that reacts to the pullRequestStatusChanged event. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild test results as a comment on the pull request when the test results are complete.
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ả tình huống một đội ngũ phát triển sử dụng AWS CodeCommit làm kho lưu trữ mã nguồn (version control), kết hợp AWS CodePipeline, AWS CodeBuild và AWS CodeDeploy cho quy trình CI/CD. Vấn đề phát sinh: Đội ngũ đã merge các pull request (PR) mà không chạy qua các bài test dài hạn (long-running tests), dẫn đến phải rollback thủ công về các branch cũ, gây mất thời gian và công sức. 📉

Yêu cầu của DevOps engineer: Tự động hóa việc test PR trong CodeCommit để các reviewer dễ dàng xem kết quả test ngay trong quá trình review PR. 🛠️ Cụ thể, cần trigger test khi PR được tạo hoặc cập nhật, và hiển thị kết quả (như badge hoặc comment) trực tiếp trên PR để developer/reviewers thấy rõ (pass/fail) mà không cần rời khỏi giao diện CodeCommit.

Giải pháp cốt lõi: Sử dụng Amazon EventBridge để lắng nghe sự kiện từ CodeCommit, trigger AWS Lambda để chạy pipeline CodePipeline với action CodeBuild thực hiện test, rồi post kết quả (badge hoặc comment) vào PR. Điều này đảm bảo test chạy tự động và tích hợp mượt mà vào workflow review PR. ⚙️

(Kiến thức cập nhật đến 2026: AWS CodeCommit hỗ trợ EventBridge events chi tiết hơn từ 2023, CodeBuild badges embed được vào PR comments qua CodeCommit API. Không thay đổi lớn ở phiên bản mới nhất - AWS re:Invent 2025 xác nhận tích hợp này ổn định.)

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Lựa chọn thứ 3 - Create an Amazon EventBridge rule that reacts to pullRequestCreated and pullRequestSourceBranchUpdated events. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild badge as a comment on the pull request so that developers will see the badge in their code review.

Lý do 🏆:

  • Event pullRequestCreated trigger khi PR mới được tạo. 🔄
  • Event pullRequestSourceBranchUpdated trigger khi source branch của PR được cập nhật (ví dụ: dev push code mới vào branch source) → Đảm bảo test chạy mỗi lần có thay đổi liên quan đến PR, tránh bỏ lỡ test khi PR đang mở và được update.
  • CodeBuild badge là URL embed hiển thị status build (pass/fail, duration) trực quan, dễ xem ngay trong comment PR → Reviewer thấy kết quả test "live" mà không cần click thêm. 📊
  • Lambda post badge qua CodeCommit API (CreatePullRequestComment), hoàn hảo cho yêu cầu "reviewers more easily see the results". Giải quyết triệt để vấn đề merge code chưa test. 🚀

📝 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 một cách chi tiết. Tôi giữ nguyên văn bản gốc bằng tiếng Anh, chỉ giải thích bằng tiếng Việt với lý do đúng/sai dựa trên tài liệu AWS. 🧐

  • Phương án 1 ❌ (SAI):
    Create an Amazon EventBridge rule that reacts to the pullRequestStatusChanged event. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild badge as a comment on the pull request so that developers will see the badge in their code review.
    Giải thích sai: Event pullRequestStatusChanged chỉ trigger khi status PR thay đổi (ví dụ: từ OPEN sang MERGEABLE hoặc CLOSED), không phải lúc tạo PR hay update source branch. Test sẽ không chạy kịp thời khi dev tạo/update PR, dẫn đến reviewer không thấy kết quả sớm → Không tự động hóa đầy đủ cho review process. 🕒

  • Phương án 2 ❌ (SAI):
    Create an Amazon EventBridge rule that reacts to the pullRequestCreated event. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild test results as a comment on the pull request when the test results are complete.
    Giải thích sai: Chỉ dùng pullRequestCreated → Test chỉ chạy một lần khi tạo PR, bỏ lỡ khi source branch updated (push mới). Hơn nữa, post test results (text chi tiết) kém trực quan hơn badge embed (không có status visual) → Reviewer khó "more easily see" kết quả nhanh chóng. 📉

  • Phương án 3 ✅ (ĐÚNG):
    Create an Amazon EventBridge rule that reacts to pullRequestCreated and pullRequestSourceBranchUpdated events. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild badge as a comment on the pull request so that developers will see the badge in their code review.
    Giải thích đúng: Như đã phân tích ở phần trên. Bao quát đầy đủ events cần thiết (pullRequestCreated + pullRequestSourceBranchUpdated) và sử dụng CodeBuild badge tối ưu cho visual review. Hoàn hảo! 🌟

  • Phương án 4 ❌ (SAI):
    Create an Amazon EventBridge rule that reacts to the pullRequestStatusChanged event. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild test results as a comment on the pull request when the test results are complete.
    Giải thích sai: Tương tự phương án 1, pullRequestStatusChanged không trigger lúc tạo/update PR → Test muộn, không hỗ trợ review realtime. Post test results (text) cũng kém hiệu quả hơn badge. Kết hợp hai lỗi → Không đáp ứng yêu cầu. 🔴

📘 Tài liệu tham khảo (AWS Official - Cập nhật 2026)

Giải pháp này giúp tránh merge code "bẩn" 100%! Nếu cần code sample Lambda/EventBridge, hỏi thêm nhé. 🚀

Câu 316
A company has deployed an application in a production VPC in a single AWS account. The application is popular and is experiencing heavy usage. The company’s security team wants to add additional security, such as AWS WAF, to the application deployment. However, the application's product manager is concerned about cost and does not want to approve the change unless the security team can prove that additional security is necessary.
The security team believes that some of the application's demand might come from users that have IP addresses that are on a deny list. The security team provides the deny list to a DevOps engineer. If any of the IP addresses on the deny list access the application, the security team wants to receive automated notification in near real time so that the security team can document that the application needs additional security. The DevOps engineer creates a VPC flow log for the production VPC.
Which set of additional steps should the DevOps engineer take to meet these requirements MOST cost-effectively?
  1. A Create a log group in Amazon CloudWatch Logs. Configure the VPC flow log to capture accepted traffic and to send the data to the log group. Create an Amazon CloudWatch metric filter for IP addresses on the deny list. Create a CloudWatch alarm with the metric filter as input. Set the period to 5 minutes and the datapoints to alarm to 1. Use an Amazon Simple Notification Service (Amazon SNS) topic to send alarm notices to the security team.
  2. B Create an Amazon S3 bucket for log files. Configure the VPC flow log to capture all traffic and to send the data to the S3 bucket. Configure Amazon Athena to return all log files in the S3 bucket for IP addresses on the deny list. Configure Amazon QuickSight to accept data from Athena and to publish the data as a dashboard that the security team can access. Create a threshold alert of 1 for successful access. Configure the alert to automatically notify the security team as frequently as possible when the alert threshold is met.
  3. C Create an Amazon S3 bucket for log files. Configure the VPC flow log to capture accepted traffic and to send the data to the S3 bucket. Configure an Amazon OpenSearch Service cluster and domain for the log files. Create an AWS Lambda function to retrieve the logs from the S3 bucket, format the logs, and load the logs into the OpenSearch Service cluster. Schedule the Lambda function to run every 5 minutes. Configure an alert and condition in OpenSearch Service to send alerts to the security team through an Amazon Simple Notification Service (Amazon SNS) topic when access from the IP addresses on the deny list is detected.
  4. D Create a log group in Amazon CloudWatch Logs. Create an Amazon S3 bucket to hold query results. Configure the VPC flow log to capture all traffic and to send the data to the log group. Deploy an Amazon Athena CloudWatch connector in AWS Lambda. Connect the connector to the log group. Configure Athena to periodically query for all accepted traffic from the IP addresses on the deny list and to store the results in the S3 bucket. Configure an S3 event notification to automatically notify the security team through an Amazon Simple Notification Service (Amazon SNS) topic when new objects are added to 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 ứng dụng được triển khai trong VPC sản xuất của một tài khoản AWS duy nhất, đang gặp tình trạng sử dụng cao. Đội ngũ bảo mật muốn thêm lớp bảo vệ như AWS WAF, nhưng quản lý sản phẩm lo ngại về chi phí và yêu cầu bằng chứng cụ thể. 🛡️ Đội bảo mật nghi ngờ một phần lưu lượng đến từ các IP trong danh sách deny list (danh sách IP bị chặn). Họ cung cấp danh sách này cho DevOps engineer.

Yêu cầu chính:

  • Nếu bất kỳ IP nào trong deny list truy cập ứng dụng (đặc biệt là accepted traffic - lưu lượng được chấp nhận), đội bảo mật cần thông báo tự động gần real-time để ghi nhận bằng chứng cần thêm bảo mật.
  • DevOps engineer đã tạo VPC Flow Log cho VPC sản xuất.
  • Cần bộ bước bổ sung TIẾT KIỆM CHI PHÍ NHẤT (MOST cost-effectively) để đáp ứng.

Các yếu tố then chốt:

  • VPC Flow Logs ghi lại metadata lưu lượng (IP source/dest, action: ACCEPT/REJECT, v.v.), không phải payload.
  • Tập trung vào accepted traffic từ IP deny list để chứng minh "demand from bad IPs".
  • Giải pháp phải near real-time (không phải batch query hàng giờ), tự động notify, và rẻ nhất (tránh dịch vụ đắt đỏ như OpenSearch, QuickSight, Athena lặp lại).

📘 Tài liệu tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng:
Create a log group in Amazon CloudWatch Logs. Configure the VPC flow log to capture accepted traffic and to send the data to the log group. Create an Amazon CloudWatch metric filter for IP addresses on the deny list. Create a CloudWatch alarm with the metric filter as input. Set the period to 5 minutes and the datapoints to alarm to 1. Use an Amazon Simple Notification Service (Amazon SNS) topic to send alarm notices to the security team.

Lý do chọn đáp án này 🏆:

  • Tiết kiệm chi phí nhất 💰: Chỉ dùng CloudWatch Logs (rẻ, ~$0.50/GB ingested), metric filter (miễn phí), alarm (rẻ, ~$0.10/alarm/tháng), SNS (rẻ). Không cần S3 storage dài hạn, Lambda, hay dịch vụ phân tích đắt.
  • Near real-time ⚡: Flow Logs → CloudWatch Logs ngay lập tức (latency <1 phút). Metric filter quét logs real-time, alarm period 5 phút + datapoints 1 → kích hoạt ngay khi phát hiện 1 match.
  • Chính xác: Chỉ capture accepted traffic (filter action=ACCEPT), match IP source trong deny list (pattern filter như { $.srcAddr = "IP1 or IP2..." }).
  • Đơn giản, scalable: Native integration, không code Lambda hay ETL phức tạp.
  • Phù hợp best practice AWS 2026: CloudWatch Logs là destination khuyến nghị cho VPC Flow Logs monitoring.

🔍 Giải thích chi tiết tất cả các phương án

  • Phương án ĐÚNG (A):
    Create a log group in Amazon CloudWatch Logs. Configure the VPC flow log to capture accepted traffic and to send the data to the log group. Create an Amazon CloudWatch metric filter for IP addresses on the deny log group. Create a CloudWatch alarm with the metric filter as input. Set the period to 5 minutes and the datapoints to alarm to 1. Use an Amazon Simple Notification Service (Amazon SNS) topic to send alarm notices to the security team.
    ✅ Đúng vì lý do trên: Real-time, cost-effective, chính xác capture accepted traffic. Hoàn hảo cho monitoring deny list.

  • Phương án SAI (B):
    Create an Amazon S3 bucket for log files. Configure the VPC flow log to capture all traffic and to send the data to the S3 bucket. Configure Amazon Athena to return all log files in the S3 bucket for IP addresses on the deny list. Configure Amazon QuickSight to accept data from Athena and to publish the data as a dashboard that the security team can access. Create a threshold alert of 1 for successful access. Configure the alert to automatically notify the security team as frequently as possible when the alert threshold is met.
    ❌ Sai vì:

    • Không real-time ⏳: Flow Logs → S3 (batch 1-10 phút), Athena query on-demand (latency cao, không tự động poll).
    • Đắt đỏ 💸: S3 storage + Athena query ($5/TB scanned) + QuickSight (license/user/tháng) → tốn kém cho heavy usage.
    • Capture all traffic (không cần REJECT), QuickSight dashboard không phải notify tự động near real-time.
    • Phù hợp phân tích lịch sử, không phải alert tức thì.
  • Phương án SAI (C):
    Create an Amazon S3 bucket for log files. Configure the VPC flow log to capture accepted traffic and to send the data to the S3 bucket. Configure an Amazon OpenSearch Service cluster and domain for the log files. Create an AWS Lambda function to retrieve the logs from the S3 bucket, format the logs, and load the logs into the OpenSearch Service cluster. Schedule the Lambda function to run every 5 minutes. Configure an alert and condition in OpenSearch Service to send alerts to the security team through an Amazon Simple Notification Service (Amazon SNS) topic when access from the IP addresses on the deny list is detected.
    ❌ Sai vì:

    • Phức tạp & đắt 🛠️💰: OpenSearch cluster (từ $20+/node/tháng + storage), Lambda ETL every 5 phút (invoke + duration fee), S3.
    • Không real-time thực sự 🔄: Latency từ S3 → Lambda → OpenSearch (~5 phút+), không native như CloudWatch.
    • Overkill cho simple IP matching; AWS khuyến nghị tránh self-managed ELT cho monitoring cơ bản.
  • Phương án SAI (D):
    Create a log group in Amazon CloudWatch Logs. Create an Amazon S3 bucket to hold query results. Configure the VPC flow log to capture all traffic and to send the data to the log group. Deploy an Amazon Athena CloudWatch connector in AWS Lambda. Connect the connector to the log group. Configure Athena to periodically query for all accepted traffic from the IP addresses on the deny list and to store the results in the S3 bucket. Configure an S3 event notification to automatically notify the security team through an Amazon Simple Notification Service (Amazon SNS) topic when new objects are added to the S3 bucket.
    ❌ Sai vì:

    • Không tồn tại chuẩn ❓: Không có "Athena CloudWatch connector in AWS Lambda" native (có thể ám chỉ custom, nhưng phức tạp).
    • Không real-time & đắt ⏳💸: Athena periodic query (manual schedule, scanned fee cao), S3 event chỉ notify khi có file mới (latency 5-15 phút+).
    • Capture all traffic thừa, over-engineered so với metric filter đơn giản.
    • Vi phạm cost-effective: Thêm S3 + Athena không cần thiết.

Kết luận 🎯: Phương án A là best practice AWS DevOps cho monitoring VPC Flow Logs với chi phí thấp nhất, hiệu suất cao nhất theo cập nhật 2026. Nếu triển khai thực tế, test metric filter pattern với sample deny list trước! 🚀

Câu 317 Chọn nhiều đáp án
A DevOps engineer has automated a web service deployment by using AWS CodePipeline with the following steps:
1. An AWS CodeBuild project compiles the deployment artifact and runs unit tests.
2. An AWS CodeDeploy deployment group deploys the web service to Amazon EC2 instances in the staging environment.
3. A CodeDeploy deployment group deploys the web service to EC2 instances in the production environment.
The quality assurance (QA) team requests permission to inspect the build artifact before the deployment to the production environment occurs. The QA team wants to run an internal penetration testing tool to conduct manual tests. The tool will be invoked by a REST API call.
Which combination of actions should the DevOps engineer take to fulfill this request? (Choose two.)
  1. A Insert a manual approval action between the test actions and deployment actions of the pipeline.
  2. B Modify the buildspec.yml file for the compilation stage to require manual approval before completion.
  3. C Update the CodeDeploy deployment groups so that they require manual approval to proceed.
  4. D Update the pipeline to directly call the REST API for the penetration testing tool.
  5. E Update the pipeline to invoke an AWS Lambda function that calls the REST API for the penetration testing tool.
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 quy trình triển khai tự động web service sử dụng AWS CodePipeline với các bước sau:

  • Bước 1: AWS CodeBuild compile artifact và chạy unit tests. 🛠️
  • Bước 2: CodeDeploy deploy lên EC2 staging environment. 📦
  • Bước 3: CodeDeploy deploy lên EC2 production environment. 🚀

Yêu cầu từ QA team: Họ cần kiểm tra build artifact trước khi deploy production, bằng cách chạy tool penetration testing thủ công qua REST API call. DevOps engineer phải chọn KẾT HỢP 2 actions để đáp ứng, đảm bảo pipeline tạm dừng để QA inspect và test.

Mục tiêu: Chèn cơ chế kiểm tra thủ công giữa staging và production, tích hợp gọi REST API cho tool QA, mà không phá vỡ luồng tự động hóa. (Dựa trên tính năng CodePipeline mới nhất 2024-2026: hỗ trợ Manual Approval và Invoke actions linh hoạt).

✅ Đáp án đúng (Chọn TWO)

Hai lựa chọn đúng là:

  1. Insert a manual approval action between the test actions and deployment actions of the pipeline.
  2. Update the pipeline to invoke an AWS Lambda function that calls the REST API for the penetration testing tool.

Lý do chọn (giải thích chi tiết):

  • Pipeline cần tạm dừng sau staging để QA manual inspect artifact và chạy tool. Manual approval action (tính năng CodePipeline) chèn stage phê duyệt thủ công giữa staging deploy và production deploy, gửi thông báo (SNS/Email) cho QA approve sau khi test. ✅
  • Tool QA là REST API → Không gọi trực tiếp từ pipeline (CodePipeline không hỗ trợ HTTP calls native). Sử dụng AWS Lambda làm proxy: Pipeline invoke Lambda qua "Invoke" action, Lambda gọi REST API tool QA, trả kết quả pass/fail. Kết hợp với manual approval để QA trigger/invoke tool trước approve. Hoàn hảo cho DevOps best practices (IaC, serverless). 🛠️
  • Kết hợp hai actions: Manual approval cho inspect thủ công + Lambda cho automate tool call, linh hoạt và scalable theo AWS Well-Architected Framework (Operational Excellence pillar).

📋 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 một cách chi tiết. Giữ nguyên văn bản gốc tiếng Anh, giải thích bằng tiếng Việt với lý do dựa trên docs AWS mới nhất (2026):

  • ✅ Insert a manual approval action between the test actions and deployment actions of the pipeline.
    Đúng! 🏆 Đây là tính năng native của CodePipeline (Manual Approval stage). Chèn giữa staging (test/deploy staging) và production để QA approve sau inspect artifact. Hỗ trợ notify via SNS/CloudWatch, gatekeeper lý tưởng cho compliance. Không ảnh hưởng build/compilation.

  • ❌ Modify the buildspec.yml file for the compilation stage to require manual approval before completion.
    Sai! 🚫 Buildspec.yml chỉ định lệnh build/test trong CodeBuild (compile/unit tests). Không hỗ trợ manual approval (buildspec là YAML declarative, không interactive). Sẽ block toàn bộ pipeline sớm, QA không inspect được artifact staging. Không phù hợp vị trí (trước staging).

  • ❌ Update the CodeDeploy deployment groups so that they require manual approval to proceed.
    Sai! 🚫 CodeDeploy deployment groups chỉ config AutoRollback/Hooks, không có manual approval native. CodeDeploy là deployment engine, không gate như CodePipeline. Muốn approve deploy phải dùng pipeline stage, không modify group trực tiếp (dẫn đến misconfig).

  • ❌ Update the pipeline to directly call the REST API for the penetration testing tool.
    Sai! 🚫 CodePipeline không hỗ trợ HTTP/REST calls trực tiếp (chỉ source/build/deploy/invoke actions chuẩn). Gọi API cần Lambda/ECS làm intermediary. Direct call sẽ fail validation pipeline, vi phạm security (no auth/secrets handling).

  • ✅ Update the pipeline to invoke an AWS Lambda function that calls the REST API for the penetration testing tool.
    Đúng! 🏆 CodePipeline có Lambda Invoke action (parallel/sequential). Lambda nhận artifact URL/input từ pipeline, gọi REST API tool QA (sử dụng API Gateway hoặc HTTP client trong code Lambda). QA có thể trigger via approval trước, Lambda scalable/serverless, tích hợp IAM roles an toàn. Best practice cho custom testing.

📘 Tài liệu tham khảo (AWS cập nhật 2024-2026)

Kết luận: 🔑 Kết hợp manual approval + Lambda là giải pháp tối ưu, tuân thủ zero-trust & CI/CD maturity model AWS. Nếu triển khai thực tế, test pipeline với CloudFormation! 🚀

Câu 318
A company is hosting a web application in an AWS Region. For disaster recovery purposes, a second region is being used as a standby. Disaster recovery requirements state that session data must be replicated between regions in near-real time and 1% of requests should route to the secondary region to continuously verify system functionality. Additionally, if there is a disruption in service in the main region, traffic should be automatically routed to the secondary region, and the secondary region must be able to scale up to handle all traffic.
How should a DevOps engineer meet these requirements?
  1. A In both regions, deploy the application on AWS Elastic Beanstalk and use Amazon DynamoDB global tables for session data. Use an Amazon Route 53 weighted routing policy with health checks to distribute the traffic across the regions.
  2. B In both regions, launch the application in Auto Scaling groups and use DynamoDB for session data. Use a Route 53 failover routing policy with health checks to distribute the traffic across the regions.
  3. C In both regions, deploy the application in AWS Lambda, exposed by Amazon API Gateway, and use Amazon RDS for PostgreSQL with cross-region replication for session data. Deploy the web application with client-side logic to call the API Gateway directly.
  4. D In both regions, launch the application in Auto Scaling groups and use DynamoDB global tables for session data. Enable an Amazon CloudFront weighted distribution across regions. Point the Amazon Route 53 DNS record at the CloudFront distribution.
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 chiến lược Disaster Recovery (DR) cho một ứng dụng web được host trên AWS Region chính, với Region phụ làm standby. Các yêu cầu cụ thể bao gồm:

  • Dữ liệu session phải được replicate gần như real-time giữa hai regions.
  • 1% lưu lượng truy cập phải được route đến region phụ để liên tục kiểm tra tính năng hệ thống.
  • Nếu region chính bị gián đoạn, tự động route toàn bộ traffic sang region phụ, và region phụ phải scale up để xử lý toàn bộ traffic.

🛠️ DevOps Engineer cần thiết kế giải pháp sử dụng các dịch vụ AWS để đáp ứng tất cả yêu cầu trên, đảm bảo high availability, multi-region replication, và intelligent routing. Giải pháp phải tận dụng các tính năng AWS mới nhất (tính đến 2026), như DynamoDB Global Tables (v1.0 với multi-active replication) và Route 53 routing policies nâng cao.

✅ Đáp án đúng

In both regions, deploy the application on AWS Elastic Beanstalk and use Amazon DynamoDB global tables for session data. Use an Amazon Route 53 weighted routing policy with health checks to distribute the traffic across the regions.

Lý do chọn đáp án này (hoàn hảo khớp yêu cầu):

  • AWS Elastic Beanstalk ở cả hai regions cho phép deploy ứng dụng dễ dàng, tự động scale (Auto Scaling Groups tích hợp), và xử lý toàn bộ traffic khi cần.
  • Amazon DynamoDB Global Tables replicate session data near-real time (multi-region, multi-active, latency <1 giây theo docs AWS 2026).
  • Route 53 Weighted Routing Policy + Health Checks:
    • Weighted policy cho phép set tỷ lệ 99% primary / 1% secondary để verify liên tục.
    • Health checks tự động detect failure và route 100% traffic sang secondary (failover seamless).
      ✅ Giải pháp này đáp ứng 100% yêu cầu: replication real-time, 1% traffic verify, auto-failover + scale.

📋 Phân tích tất cả các phương án

  • Phương án 1 (Đúng ✅):
    In both regions, deploy the application on AWS Elastic Beanstalk and use Amazon DynamoDB global tables for session data. Use an Amazon Route 53 weighted routing policy with health checks to distribute the traffic across the regions.
    Giải thích: Như trên, hoàn hảo. Elastic Beanstalk scale tự động, DynamoDB Global Tables replicate near-real time, Route 53 weighted + health checks xử lý 1% traffic và failover chính xác.

  • Phương án 2 (Sai ❌):
    In both regions, launch the application in Auto Scaling groups and use DynamoDB for session data. Use a Route 53 failover routing policy with health checks to distribute the traffic across the regions.
    Giải thích sai: DynamoDB thông thường không replicate cross-region near-real time (cần Global Tables). Route 53 failover policy chỉ route 100% hoặc 0%, không hỗ trợ 1% traffic verify liên tục (chỉ active-passive). Không khớp yêu cầu partial traffic.

  • Phương án 3 (Sai ❌):
    In both regions, deploy the application in AWS Lambda, exposed by Amazon API Gateway, and use Amazon RDS for PostgreSQL with cross-region replication for session data. Deploy the web application with client-side logic to call the API Gateway directly.
    Giải thích sai: RDS PostgreSQL cross-region replication có latency cao (phút), không near-real time cho session data. Lambda + API Gateway serverless nhưng yêu cầu client-side logic phức tạp, không phù hợp web app truyền thống (session sticky kém). Không có cơ chế route 1% tự động hoặc failover seamless.

  • Phương án 4 (Sai ❌):
    In both regions, launch the application in Auto Scaling groups and use DynamoDB global tables for session data. Enable an Amazon CloudFront weighted distribution across regions. Point the Amazon Route 53 DNS record at the CloudFront distribution.
    Giải thích sai: DynamoDB Global Tables tốt, nhưng CloudFront không hỗ trợ weighted distribution across regions (CloudFront là CDN edge-based, không route weighted như Route 53; chỉ geo/ latency routing). Route 53 point to CloudFront không đảm bảo 1% verify hoặc failover app-level scale. CloudFront cache static, kém cho dynamic web app session.

📘 Tài liệu tham khảo (AWS Docs cập nhật 2026)

🛠️ Kết luận: Giải pháp đúng tận dụng Route 53 Weighted làm "active-active" nhẹ (1% warm-up), kết hợp Global Tables cho data consistency – chuẩn DevOps Professional!

Câu 319 Chọn nhiều đáp án
A company runs an application on Amazon EC2 instances. The company uses a series of AWS CloudFormation stacks to define the application resources. A developer performs updates by building and testing the application on a laptop and then uploading the build output and CloudFormation stack templates to Amazon S3. The developer's peers review the changes before the developer performs the CloudFormation stack update and installs a new version of the application onto the EC2 instances.
The deployment process is prone to errors and is time-consuming when the developer updates each EC2 instance with the new application. The company wants to automate as much of the application deployment process as possible while retaining a final manual approval step before the modification of the application or resources.
The company already has moved the source code for the application and the CloudFormation templates to AWS CodeCommit. The company also has created an AWS CodeBuild project to build and test the application.
Which combination of steps will meet the company’s requirements? (Choose two.)
  1. A Create an application group and a deployment group in AWS CodeDeploy. Install the CodeDeploy agent on the EC2 instances.
  2. B Create an application revision and a deployment group in AWS CodeDeploy. Create an environment in CodeDeploy. Register the EC2 instances to the CodeDeploy environment.
  3. C Use AWS CodePipeline to invoke the CodeBuild job, run the CloudFormation update, and pause for a manual approval step. After approval, start the AWS CodeDeploy deployment.
  4. D Use AWS CodePipeline to invoke the CodeBuild job, create CloudFormation change sets for each of the application stacks, and pause for a manual approval step. After approval, run the CloudFormation change sets and start the AWS CodeDeploy deployment.
  5. E Use AWS CodePipeline to invoke the CodeBuild job, create CloudFormation change sets for each of the application stacks, and pause for a manual approval step. After approval, start the AWS CodeDeploy deployment.
Xem giải thích

🧩 Giải thích nội dung câu hỏi

Câu hỏi mô tả một công ty đang chạy ứng dụng trên các instance Amazon EC2, sử dụng AWS CloudFormation stacks để định nghĩa tài nguyên. Quy trình hiện tại thủ công: developer build/test trên laptop, upload build output và template CF lên S3, peer review, rồi update stack CF và install app mới lên từng EC2 – dẫn đến lỗi và tốn thời gian.

Công ty muốn tự động hóa deployment càng nhiều càng tốt, nhưng giữ bước phê duyệt thủ công cuối cùng trước khi thay đổi app hoặc tài nguyên. Họ đã di chuyển source code và CF templates sang AWS CodeCommit, và có AWS CodeBuild project để build/test.

Mục tiêu: Chọn TWO bước kết hợp để:

  • Orchestrate pipeline tự động (source → build → deploy).
  • Xử lý update CF stacks an toàn (với review).
  • Deploy app lên EC2 tự động.
  • Manual approval trước thay đổi lớn.

(Kiến thức cập nhật đến 2026: AWS CodePipeline hỗ trợ CF change sets từ phiên bản mới, CodeDeploy EC2-on-premise yêu cầu agent, không dùng "environment" cho EC2).

✅ Đáp án đúng (Chọn TWO)

Hai lựa chọn đúng là:

  1. Create an application group and a deployment group in AWS CodeDeploy. Install the CodeDeploy agent on the EC2 instances.

    • Lý do: Đây là bước chuẩn bị CodeDeploy cho deployment app lên EC2. CodeDeploy yêu cầu tạo application (không phải "group", nhưng thuật ngữ chuẩn là "application" và "deployment group" cho EC2 instances). Install agent trên EC2 để agentless không khả dụng cho EC2 in-place deployment. Kết hợp với pipeline để automate deploy sau approval.
  2. Use AWS CodePipeline to invoke the CodeBuild job, create CloudFormation change sets for each of the application stacks, and pause for a manual approval step. After approval, run the CloudFormation change sets and start the AWS CodeDeploy deployment.

    • Lý do: CodePipeline orchestrate toàn bộ: trigger CodeBuild từ CodeCommit → tạo CF change sets (cho phép review diff trước execute, an toàn cho multi-stacks) → manual approval stage → execute change sets (update resources) VÀ trigger CodeDeploy (deploy app). Đúng yêu cầu "retaining final manual approval before modification of app/resources".

Kết hợp: CodeDeploy setup (1) + Pipeline với CF change sets & deploy (2) → Tự động hóa đầy đủ, approval ở giữa.

📋 Phân tích chi tiết tất cả các phương án

🛠️ Phương án 1:
Create an application group and a deployment group in AWS CodeDeploy. Install the CodeDeploy agent on the EC2 instances.
✅ Đúng: Thiết lập deployment group cho EC2 (tag-based hoặc instance list), install CodeDeploy agent (yêu cầu bắt buộc cho EC2 deployments từ 2023+). "Application group" là thuật ngữ gần đúng (thực tế là "application"), hỗ trợ pipeline trigger deploy sau build.

❌ Phương án 2:
Create an application revision and a deployment group in AWS CodeDeploy. Create an environment in CodeDeploy. Register the EC2 instances to the CodeDeploy environment.
❌ Sai: "Application revision" không phải khái niệm chuẩn (revision là artifact từ CodeCommit/S3). Environment chỉ dùng cho ECS/ECS Blue/Green, Lambda, hoặc on-premises – KHÔNG cho EC2 (EC2 dùng deployment group). Register instances vào environment sai quy trình.

❌ Phương án 3:
Use AWS CodePipeline to invoke the CodeBuild job, run the CloudFormation update, and pause for a manual approval step. After approval, start the AWS CodeDeploy deployment.
❌ Sai: Run CF update trực tiếp (cfn-update) KHÔNG cho phép review diff trước (nguy cơ lỗi lớn với multi-stacks). Approval sau update rồi mới deploy → vi phạm "approval before modification of resources". Nên dùng change sets thay thế.

✅ Phương án 4:
Use AWS CodePipeline to invoke the CodeBuild job, create CloudFormation change sets for each of the application stacks, and pause for a manual approval step. After approval, run the CloudFormation change sets and start the AWS CodeDeploy deployment.
✅ Đúng: Như giải thích trên – change sets (tạo bằng aws cloudformation create-change-set trong CodeBuild/CodePipeline) cho preview/review → manual approval → execute VÀ CodeDeploy. Hoàn hảo cho "each of the application stacks".

❌ Phương án 5:
Use AWS CodePipeline to invoke the CodeBuild job, create CloudFormation change sets for each of the application stacks, and pause for a manual approval step. After approval, start the AWS CodeDeploy deployment.
❌ Sai: Tạo change sets tốt, nhưng sau approval CHỈ start CodeDeploy → KHÔNG execute change sets → resources (CF stacks) KHÔNG được update. App deploy nhưng infra cũ → không đồng bộ.

📘 Tài liệu tham khảo (AWS Docs cập nhật 2026)

Hy vọng phân tích giúp bạn ôn thi hiệu quả! 🚀 Nếu cần demo CloudFormation, hỏi nhé!

Câu 320
A DevOps engineer manages a web application that runs on Amazon EC2 instances behind an Application Load Balancer (ALB). The instances run in an EC2 Auto Scaling group across multiple Availability Zones. The engineer needs to implement a deployment strategy that:
Launches a second fleet of instances with the same capacity as the original fleet.
Maintains the original fleet unchanged while the second fleet is launched.
Transitions traffic to the second fleet when the second fleet is fully deployed.
Terminates the original fleet automatically 1 hour after transition.
Which solution will satisfy these requirements?
  1. A Use an AWS CloudFormation template with a retention policy for the ALB set to 1 hour. Update the Amazon Route 53 record to reflect the new ALB.
  2. B Use two AWS Elastic Beanstalk environments to perform a blue/green deployment from the original environment to the new one. Create an application version lifecycle policy to terminate the original environment in 1 hour.
  3. C Use AWS CodeDeploy with a deployment group configured with a blue/green deployment configuration Select the option Terminate the original instances in the deployment group with a waiting period of 1 hour.
  4. D Use AWS Elastic Beanstalk with the configuration set to Immutable. Create an .ebextension using the Resources key that sets the deletion policy of the ALB to 1 hour, and deploy the application.
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 chiến lược blue/green deployment cho một ứng dụng web chạy trên các instance Amazon EC2 nằm sau Application Load Balancer (ALB), với các instance được quản lý bởi EC2 Auto Scaling group trải rộng trên nhiều Availability Zones (AZ). 🛤️

Yêu cầu cụ thể của kỹ sư DevOps bao gồm 4 bước chính:

  • Khởi chạy một fleet instance thứ hai (fleet xanh) có cùng dung lượng với fleet gốc (fleet xanh dương).
  • Giữ nguyên fleet gốc không thay đổi trong quá trình khởi chạy fleet mới.
  • Chuyển hướng traffic sang fleet mới khi fleet mới đã deploy đầy đủ (in-place hoặc gradual shift).
  • Tự động terminate fleet gốc sau đúng 1 giờ kể từ khi chuyển traffic hoàn tất.

📘 Bối cảnh AWS (cập nhật đến 2026): Đây là kịch bản điển hình cho blue/green deployment trên EC2 với ALB, nơi AWS CodeDeploy là dịch vụ chính hỗ trợ tính năng này một cách native, tích hợp Auto Scaling group và ALB target group swapping. Chiến lược này đảm bảo zero-downtime và rollback dễ dàng mà không ảnh hưởng đến production traffic.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Use AWS CodeDeploy with a deployment group configured with a blue/green deployment configuration Select the option Terminate the original instances in the deployment group with a waiting period of 1 hour.

Lý do chi tiết 🏆:

  • AWS CodeDeploy hỗ trợ blue/green deployment trên EC2 với deployment group liên kết trực tiếp đến Auto Scaling group và ALB target groups.
  • Quá trình: CodeDeploy sẽ launch fleet mới (green) song song với fleet gốc (blue), validate deployment (qua hooks như AfterBlockTraffic), sau đó swap traffic giữa 2 target groups của ALB (Canary, Linear, All-at-once).
  • Tùy chọn "Terminate the original instances in the deployment group with a waiting period of 1 hour" chính xác khớp yêu cầu: Sau swap, CodeDeploy sẽ tự động terminate blue fleet sau 1 giờ chờ (configurable termination hook/waiting period), đảm bảo giữ nguyên fleet gốc trong quá trình và cùng capacity nhờ Auto Scaling.
  • Ưu điểm: Tích hợp native với ALB, Auto Scaling, zero-downtime, và hỗ trợ termination policy linh hoạt (cập nhật AWS CodeDeploy 2024-2026).
  • Nguồn tham khảo: AWS CodeDeploy Blue/Green Deployments & EC2/On-Premises Deployment with ALB.

📋 Giải thích tất cả các phương án (đúng/sai)

  • ❌ Phương án SAI: Use an AWS CloudFormation template with a retention policy for the ALB set to 1 hour. Update the Amazon Route 53 record to reflect the new ALB.
    Lý do sai: CloudFormation không hỗ trợ retention policy 1 giờ cho ALB (ALB không có thuộc tính retention như vậy; chỉ có access logs retention). Việc update Route 53 gây downtime khi DNS propagation (TTL issues), không launch fleet mới tự động, và không giữ nguyên fleet gốc một cách tự động. Không khớp blue/green native. 🛑

  • ❌ Phương án SAI: Use two AWS Elastic Beanstalk environments to perform a blue/green deployment from the original environment to the new one. Create an application version lifecycle policy to terminate the original environment in 1 hour.
    Lý do sai: Elastic Beanstalk hỗ trợ blue/green qua 2 environments, nhưng application version lifecycle policy chỉ xóa old versions chứ không terminate environment sau 1 giờ (không có tùy chọn thời gian cụ thể như vậy). Phải manual swap CNAME và terminate, không tự động 1 giờ, và không khớp chính xác với EC2 Auto Scaling + ALB setup (EB abstract hóa ASG). ❌

  • ✅ Phương án ĐÚNG (đã giải thích ở trên): Use AWS CodeDeploy with a deployment group configured with a blue/green deployment configuration Select the option Terminate the original instances in the deployment group with a waiting period of 1 hour.
    Hoàn hảo khớp tất cả 4 yêu cầu! 🚀

  • ❌ Phương án SAI: Use AWS Elastic Beanstalk with the configuration set to Immutable. Create an .ebextension using the Resources key that sets the deletion policy of the ALB to 1 hour, and deploy the application.
    Lý do sai: Immutable deployment trong EB launch instances mới thay thế cũ, nhưng .ebextensions với Resources key dùng cho CFN resources, không set deletion policy 1 giờ cho ALB (DeletionPolicy chỉ là Retain/Snapshot/Delete, không có timer). Không hỗ trợ blue/green với traffic swap và terminate delay chính xác. EB Immutable không giữ fleet gốc 1 giờ sau swap. 🧨

Kết luận 💡: CodeDeploy là giải pháp tối ưu nhất cho kịch bản EC2-ALB-ASG blue/green với termination timed. Nếu triển khai thực tế, khuyến nghị test với CodePipeline để automate full CI/CD!