Ngân hàng đề — AWS Certified Developer Associate
Tìm thấy 1356 câu.
One of the Lambda functions occasionally fails because of timeout errors during periods of high demand. The developer must ensure that the workflow automatically retries the failed function invocation if a timeout error occurs.
Which solution will meet this requirement?
- A Add a Retry field in the Step Functions state machine definition. Configure the state machine with the maximum number of retry attempts and the timeout error type to retry on.
- B Add a Timeout field in the Step Functions state machine definition. Configure the state machine with the maximum number of retry attempts.
- C Add a Fail state to the Step Functions state machine definition. Configure the state machine with the maximum number of retry attempts.
- D Update the Step Functions state machine to pass the invocation request to an Amazon Simple Notification Service (Amazon SNS) topic. Subscribe a Lambda function to the SNS topic. Configure the Lambda function with the maximum number of retry attempts for a timeout error type.
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 xây dựng một ứng dụng serverless trên AWS sử dụng AWS Step Functions để quản lý workflow xử lý lượng dữ liệu lớn (high volumes of data). Trong workflow này, state machine của Step Functions sẽ gọi (invoke) nhiều AWS Lambda functions.
Vấn đề cụ thể: Một Lambda function thỉnh thoảng thất bại (fails) do lỗi timeout (timeout errors) trong các giai đoạn nhu cầu cao (high demand). Yêu cầu là đảm bảo workflow tự động retry (thử lại) việc gọi Lambda thất bại nếu gặp lỗi timeout, mà không cần can thiệp thủ công.
🛠️ Mục tiêu chính: Tìm giải pháp tích hợp sẵn trong Step Functions để xử lý lỗi timeout một cách tự động và hiệu quả, phù hợp với kiến trúc serverless (không cần thêm dịch vụ ngoài).
📘 Kiến thức AWS cập nhật đến 2026: AWS Step Functions (phiên bản Express Workflows và Standard Workflows) hỗ trợ cơ chế Retry và Catch mạnh mẽ cho Task states (như Lambda invoke). Lỗi timeout của Lambda được map thành States.Timeout trong Step Functions, và có thể retry dựa trên error types cụ thể (theo tài liệu AWS Step Functions Error Handling mới nhất).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Add a Retry field in the Step Functions state machine definition. Configure the state machine with the maximum number of retry attempts and the timeout error type to retry on.
Lý do chi tiết:
- Trong định nghĩa ASL (Amazon States Language) của Step Functions, mỗi Task state (như Lambda invoke) có thể thêm Retry field để tự động retry khi gặp lỗi cụ thể.
- Cấu hình bao gồm:
MaxAttempts(số lần thử lại tối đa),IntervalSeconds/BackoffRate(khoảng cách và backoff), và ErrorNames (ví dụ:["States.Timeout"]để chỉ retry lỗi timeout từ Lambda). - Giải pháp này tích hợp sẵn, serverless thuần túy, không cần thêm code hay dịch vụ ngoài, và hoàn toàn tự động. Phù hợp với high demand vì Step Functions quản lý throttling và scaling tự động.
- ✅ Hoàn hảo cho yêu cầu: Đảm bảo retry chỉ khi timeout, tránh lãng phí tài nguyên.
🔍 Giải thích tất cả các phương án (đúng và sai)
-
✅ Phương án ĐÚNG: Add a Retry field in the Step Functions state machine definition. Configure the state machine with the maximum number of retry attempts and the timeout error type to retry on.
🟢 Lý do đúng: Như giải thích trên, Retry field là cơ chế chuẩn của Step Functions cho Task states. Ví dụ ASL:"Retry": [ { "ErrorEquals": ["States.Timeout"], "IntervalSeconds": 2, "MaxAttempts": 3, "BackoffRate": 2.0 } ]Đây là best practice cho error handling trong workflows serverless (AWS Well-Architected Framework - Reliability Pillar).
-
❌ Phương án SAI: Add a Timeout field in the Step Functions state machine definition. Configure the state machine with the maximum number of retry attempts.
🔴 Lý do sai: Timeout field chỉ định thời gian chờ tối đa cho state (ví dụ:"TimeoutSeconds": 30), không hỗ trợ retry tự động. Nó chỉ fail state nếu vượt timeout, không cấu hình "max retry attempts". Không giải quyết retry cho lỗi Lambda timeout. -
❌ Phương án SAI: Add a Fail state to the Step Functions state machine definition. Configure the state machine with the maximum number of retry attempts.
🔴 Lý do sai: Fail state dùng để kết thúc workflow với lỗi (terminal state), không retry gì cả. Không có khái niệm "max retry attempts" trong Fail state. Thêm Fail chỉ làm workflow dừng đột ngột khi timeout, trái ngược yêu cầu retry tự động. -
❌ Phương án SAI: Update the Step Functions state machine to pass the invocation request to an Amazon Simple Notification Service (Amazon SNS) topic. Subscribe a Lambda function to the SNS topic. Configure the Lambda function with the maximum number of retry attempts for a timeout error type.
🔴 Lý do sai: Giải pháp này phức tạp hóa không cần thiết (thêm SNS + Lambda subscriber), không serverless thuần (tăng chi phí, độ trễ). Step Functions không cần "pass to SNS" vì đã hỗ trợ retry native. Lambda subscriber cũng không retry trực tiếp timeout từ Lambda gốc, dễ tạo loop vô tận.
📚 Tài liệu tham khảo (AWS chính thức - cập nhật 2026)
- AWS Step Functions Error Handling and Retries ✅ (Chi tiết Retry/Catch với States.Timeout).
- AWS Step Functions ASL Reference - Retry Field.
- AWS Well-Architected Framework: Reliability for Serverless.
- Best practice từ AWS re:Invent 2025: Sử dụng Express Workflows cho high-volume data với built-in retry.
🛠️ Kết luận: Giải pháp đúng tận dụng sức mạnh native của Step Functions, đảm bảo scalability và reliability cho serverless workflows! Nếu cần ví dụ code ASL đầy đủ, hãy hỏi thêm nhé! 🚀
The developer needs to use AWS Secrets Manager to manage the user credentials. The password must to be rotated on a regular basis. The solution needs to ensure that there is high availability and no downtime for the application during secret rotation.
What should the developer do to meet these requirements?
- A Configure managed rotation with the single user rotation strategy.
- B Configure managed rotation with the alternating users rotation strategy.
- C Configure automatic rotation with the single user rotation strategy.
- D Configure automatic rotation with the alternating users rotation strategy.
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi xoay quanh một ứng dụng serverless trên AWS, sử dụng AWS Lambda để xử lý dữ liệu và lưu trữ vào Amazon RDS for PostgreSQL. Developer đã tạo tài khoản người dùng (user credentials) trong database cho ứng dụng. Yêu cầu chính là sử dụng AWS Secrets Manager để quản lý credentials này, với mật khẩu (password) phải được xoay vòng (rotate) định kỳ. Giải pháp phải đảm bảo high availability (tính sẵn sàng cao) và không có downtime (không gián đoạn dịch vụ) cho ứng dụng trong quá trình rotation.
🛠️ Thách thức cốt lõi: Rotation password cho RDS PostgreSQL cần tránh tình trạng ứng dụng Lambda mất kết nối tạm thời, vì Lambda đọc secret từ Secrets Manager để kết nối DB. Cần strategy hỗ trợ zero-downtime và tự động hóa hoàn toàn.
✅ Đáp án đúng: Configure automatic rotation with the alternating users rotation strategy.
Lý do lựa chọn:
- Automatic rotation kích hoạt Secrets Manager tự động xoay vòng secret theo lịch (ví dụ: hàng ngày/tuần), sử dụng AWS Lambda function managed để thực hiện.
- Alternating users strategy tạo hai user luân phiên (user gốc và temp user): Rotate password của temp user trước, test kết nối ứng dụng với temp user thành công, sau đó cập nhật secret chỉ đến temp user (bây giờ thành active), và xóa user cũ. Quá trình này đảm bảo zero downtime vì ứng dụng luôn kết nối với user có password hợp lệ, không gián đoạn Lambda. Phù hợp hoàn hảo với RDS PostgreSQL và yêu cầu high availability.
📘 Nguồn tham khảo: AWS Secrets Manager User Guide - Rotating database credentials (cập nhật 2024-2026): docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-paas-secrets.html#rotating-rds-paas-secrets-alternating-users. Strategy này được khuyến nghị cho serverless apps như Lambda để tránh reconnection failures.
📋 Phân tích tất cả các phương án
✅ Configure automatic rotation with the alternating users rotation strategy.
Phương án ĐÚNG ✅. Như giải thích trên, kết hợp automatic scheduling với alternating users đảm bảo rotation định kỳ mà không downtime, lý tưởng cho RDS PostgreSQL trong môi trường serverless. Lambda có thể cache secret ngắn hạn nhưng vẫn an toàn nhờ test connection trước khi switch.
❌ Configure managed rotation with the single user rotation strategy.
Phương án SAI ❌. "Managed rotation" sử dụng AWS-managed Lambda function cơ bản, nhưng single user strategy chỉ rotate password của một user duy nhất mà ứng dụng dùng. Khi rotate, password cũ bị vô hiệu ngay lập tức, dẫn đến downtime ngắn (Lambda fail kết nối đến khi refresh secret mới). Không đáp ứng yêu cầu no downtime và high availability.
❌ Configure managed rotation with the alternating users rotation strategy.
Phương án SAI ❌. Mặc dù alternating users đúng strategy cho zero-downtime (luân phiên hai user), nhưng managed rotation ám chỉ Lambda managed mặc định của AWS, thường không hỗ trợ đầy đủ alternating users tự động cho tất cả DB types hoặc yêu cầu config custom thêm. AWS ưu tiên automatic rotation cho quy trình end-to-end với RDS PostgreSQL để đảm bảo tính tự động và HA hoàn chỉnh.
❌ Configure automatic rotation with the single user rotation strategy.
Phương án SAI ❌. Automatic rotation đúng về tự động hóa định kỳ, nhưng single user strategy gây downtime vì rotate trực tiếp password user active: Ứng dụng Lambda mất kết nối tạm thời (có thể vài phút) cho đến khi pull secret mới. Không phù hợp với yêu cầu "no downtime" cho production serverless app.
🧮 Tóm tắt nhanh: Chỉ alternating users mới đảm bảo zero-downtime bằng cách test và switch user mượt mà. Kết hợp automatic để rotate regular. Sử dụng AWS Console/CLI: Tạo secret → Enable rotation → Chọn RDS PostgreSQL → Automatic + Alternating users. 🚀
A developer needs to find the slow executions across all the Lambda functions.
Which solution will meet these requirements?
- A Perform a query across all the Lambda function log groups by using Amazon CloudWatch Logs Insights. Filter on type of report and sort descending by Lambda function execution duration.
- B Enable AWS CloudTrail Insights on the account where the Lambda functions are running. After CloudTrail Insights has finished processing, review CloudTrail Insights to find the anomalous functions.
- C Enable AWS X-Ray for all the Lambda functions. Configure an X-Ray insight on a new group that includes all the Lambda functions. After the X-Ray insight has finished processing, review the X-Ray logs.
- D Set up AWS Glue to crawl through the logs in Amazon CloudWatch Logs for the Lambda functions. Configure an AWS Glue job to transform the logs into a structured format and to output the logs into Amazon S3. Use the Amazon CloudWatch dashboard to visualize the slowest functions based on the duration.
Xem giải thích
🧩 Phân tích chi tiết câu hỏi trắc nghiệm AWS
📖 Nội dung câu hỏi:
Câu hỏi mô tả một ứng dụng AWS bao gồm website tĩnh lưu trữ trên Amazon S3, kết hợp với Amazon API Gateway gọi các hàm AWS Lambda. Trong giai đoạn lưu lượng truy cập cao, người dùng báo cáo ứng dụng chậm ở các khoảng thời gian không đều (irregular intervals), nhưng không có yêu cầu nào thất bại (no failed requests). Nhà phát triển cần tìm ra các thực thi chậm (slow executions) trên tất cả các hàm Lambda (across all the Lambda functions).
🛠️ Yêu cầu chính: Giải pháp phải xác định chính xác các thực thi chậm, phù hợp với tình huống hiệu suất không ổn định do traffic cao, mà không liên quan đến lỗi (failures). Đây là vấn đề về latency/anomaly detection trong môi trường serverless, cần công cụ theo dõi phân tán (distributed tracing) để phân tích cross-function.
✅ Đáp án đúng:
Enable AWS X-Ray for all the Lambda functions. Configure an X-Ray insight on a new group that includes all the Lambda functions. After the X-Ray insight has finished processing, review the X-Ray logs.
Lý do chọn đáp án đúng (bằng tiếng Việt):
Giải pháp này sử dụng AWS X-Ray – dịch vụ tracing phân tán chuyên phát hiện anomalies và latencies trong các service AWS như Lambda. Bằng cách kích hoạt X-Ray cho tất cả Lambda, tạo X-Ray Insight trên group bao quát tất cả functions, hệ thống sẽ tự động phân tích traces, phát hiện các slow executions bất thường (irregular slow periods) mà không cần query thủ công. X-Ray Insights xử lý dữ liệu realtime/ML-based để highlight root causes cross-functions, phù hợp hoàn hảo với yêu cầu "across all Lambda functions" và high-traffic scenarios (cập nhật AWS 2024-2026: X-Ray hỗ trợ enhanced Insights với auto-grouping và anomaly detection cho Lambda). Không có failed requests nên tracing latency-focused như X-Ray là optimal.
🔍 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 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 chi tiết bằng tiếng Việt dựa trên best practices AWS mới nhất (2026).
-
❌ [SAI] Perform a query across all the Lambda function log groups by using Amazon CloudWatch Logs Insights. Filter on type of report and sort descending by Lambda function execution duration.
Phương án này dùng CloudWatch Logs Insights để query logs Lambda (REPORT lines chứa DURATION), filter/sort theo thời gian thực thi. Tuy có thể tìm slow invocations thủ công, nhưng không hiệu quả cho irregular slow periods across ALL functions: Query cần cross-log groups phức tạp, không auto-detect anomalies, dễ miss patterns high-traffic (phải chạy query liên tục). Không phải giải pháp tự động/optimized cho tracing distributed như yêu cầu. -
❌ [SAI] Enable AWS CloudTrail Insights on the account where the Lambda functions are running. After CloudTrail Insights has finished processing, review CloudTrail Insights to find the anomalous functions.
AWS CloudTrail Insights phát hiện anomalies trong API calls (e.g., unusual management actions), không phải execution latencies của Lambda runtime. Nó tập trung vào security/compliance (e.g., unauthorized calls), không hỗ trợ metrics performance như duration/slow executions. Sai hoàn toàn cho vấn đề app slowness, không liên quan đến Lambda traces. -
✅ [ĐÚNG] Enable AWS X-Ray for all the Lambda functions. Configure an X-Ray insight on a new group that includes all the Lambda functions. After the X-Ray insight has finished processing, review the X-Ray logs.
Như đã giải thích ở trên: X-Ray Insights lý tưởng cho anomaly detection cross-Lambda, auto-group traces, highlight slow segments realtime (sampling active traces). Hỗ trợ API Gateway + Lambda + S3 integration, perfect cho irregular slowness mà no failures. (Cập nhật 2026: X-Ray SDK v3 với ML Insights cải tiến). -
❌ [SAI] Set up AWS Glue to crawl through the logs in Amazon CloudWatch Logs for the Lambda functions. Configure an AWS Glue job to transform the logs into a structured format and to output the logs into Amazon S3. Use the Amazon CloudWatch dashboard to visualize the slowest functions based on the duration.
Sử dụng AWS Glue để ETL logs CloudWatch sang S3 rồi visualize trên dashboard là quá phức tạp, tốn kém, không realtime. Glue dành cho big data batch processing, không phù hợp anomaly detection nhanh (delay crawl/job hours), thiếu tracing context cross-functions. CloudWatch dashboard chỉ visualize metrics cơ bản, không thay thế X-Ray cho slowness analysis.
📘 Tài liệu tham khảo (AWS Documentation - Cập nhật mới nhất 2026)
- AWS X-Ray Developer Guide: Using X-Ray Insights for anomaly detection – Chi tiết về group insights cho Lambda.
- AWS Lambda Monitoring: Using AWS X-Ray with Lambda – Tracing latencies across functions.
- CloudWatch Logs Insights vs X-Ray: Best practices for Lambda observability (Architecture Blog 2025).
- Exam Topic DOP-C02: Performance optimization & observability in serverless (AWS Certified DevOps Engineer - Professional).
🛠️ Lời khuyên DevOps: Luôn enable X-Ray sampling cho production Lambda để proactive monitoring. Kết hợp CloudWatch Metrics cho p99 latency alerts!
Which solution will meet these requirements with the LEAST development effort?
- A Use API Gateway stage variables and create Lambda aliases to reference environment-specific resources.
- B Use Amazon Elastic Container Service (Amazon ECS) to deploy the application to the environments.
- C Duplicate the code for each environment. Deploy the code to a separate API Gateway stage.
- D Use AWS Elastic Beanstalk to deploy the application to the environments.
Xem giải thích
🧩 Phân tích chi tiết câu hỏi trắc nghiệm AWS
📖 Nội dung câu hỏi:
Câu hỏi tập trung vào việc triển khai một ứng dụng serverless trên AWS, sử dụng Amazon API Gateway và AWS Lambda, với yêu cầu triển khai vào ba môi trường: development (dev), test và production (prod). Mục tiêu là chọn giải pháp ít nỗ lực phát triển nhất (LEAST development effort).
🛠️ Phân tích ngữ cảnh:
- Ứng dụng serverless nghĩa là không quản lý server, tận dụng API Gateway làm gateway cho các endpoint REST/HTTP và Lambda làm backend xử lý logic.
- Thách thức: Cần tách biệt môi trường (dev/test/prod) mà không làm phức tạp code hoặc quy trình deploy.
- Yêu cầu "LEAST development effort" nhấn mạnh vào giải pháp tự động hóa cao, tái sử dụng code, sử dụng native features của AWS thay vì custom code hoặc dịch vụ không phù hợp.
(Kiến thức cập nhật đến 2026: API Gateway và Lambda hỗ trợ multi-stage deployment qua stage variables và aliases/versions, theo AWS Well-Architected Framework for Serverless - phiên bản mới nhất 2024+ vẫn giữ nguyên best practice này).
✅ Đáp án đúng:
Use API Gateway stage variables and create Lambda aliases to reference environment-specific resources.
🔍 Lý do chọn đáp án này (chi tiết):
- API Gateway stage variables cho phép định nghĩa biến động (như
$stage) để reference tài nguyên khác nhau theo từng stage (dev, test, prod) mà không cần thay đổi code integration. Ví dụ: Mappingarn:lambda:dev-functioncho stage dev,arn:lambda:prod-functioncho prod. - Lambda aliases (hoặc versions) giúp tạo pointer đến Lambda function versions khác nhau cho từng môi trường, dễ promote (blue-green deployment) mà không duplicate code.
- Least effort: Chỉ cần config một lần qua AWS Console/CLI/CDK/Serverless Framework, deploy stage riêng biệt, zero code change. Hỗ trợ CI/CD tự động qua AWS CodePipeline.
- Lợi ích: Cost-effective, scalable, tuân thủ serverless principles (immutable deployments).
(Nguồn: AWS Docs - API Gateway Stage Variables và Lambda Aliases/Versions - cập nhật 2025).
📋 Giải thích tất cả các phương án (đúng/sai):
✅ Use API Gateway stage variables and create Lambda aliases to reference environment-specific resources.
- 🟢 Đúng vì: Giải pháp native serverless, tận dụng stage variables để switch động Lambda ARNs theo môi trường, aliases hỗ trợ versioning/promotion dễ dàng. Không cần code mới, chỉ config deploy pipeline → least effort.
❌ [SAI] Use Amazon Elastic Container Service (Amazon ECS) to deploy the application to the environments.
- 🔴 Sai vì: ECS là dịch vụ container (Fargate/EC2), không phải serverless thuần (vẫn quản lý container orchestration). Phải refactor Lambda thành container images, tăng effort lớn (Dockerize code, ECS task definitions, ALB integration). Không phù hợp với API Gateway + Lambda gốc.
❌ [SAI] Duplicate the code for each environment. Deploy the code to a separate API Gateway stage.
- 🔴 Sai vì: Duplicate code dẫn đến maintenance nightmare (thay đổi phải sync thủ công 3 nơi), tăng effort phát triển/deploy cao. Vi phạm DRY principle, dễ lỗi config, không scalable cho serverless.
❌ [SAI] Use AWS Elastic Beanstalk to deploy the application to the environments.
- 🔴 Sai vì: Elastic Beanstalk dành cho apps có server (EC2/ containers), không tối ưu cho serverless Lambda. Phải wrap Lambda vào EB environments phức tạp (qua EB extensions), mất tính serverless (cold starts kém, scaling kém hơn native Lambda). Tăng effort migration.
🚀 Kết luận & Best Practices:
Giải pháp đúng là cách tối ưu nhất cho multi-env serverless, dễ integrate với AWS SAM/ CDK cho IaC. Khuyến nghị dùng AWS CodePipeline + CodeDeploy để automate.
(Tài liệu tham khảo thêm: AWS Serverless Application Model (SAM) Docs - Multi-Environment Deployments; AWS DevOps Pro Exam Guide 2025).
Which solution will meet these requirements MOST cost-effectively?
- A Configure the CloudFormation template to reference the API endpoint in the DefinitionSubstitutions property for the AWS::StepFunctions::StateMachine resource.
- B Configure the CloudFormation template to store the API endpoint in an environment variable for the AWS::StepFunctions::StateMachine resource. Configure the state machine to reference the environment variable.
- C Configure the CloudFormation template to store the API endpoint in a standard AWS::SecretsManager::Secret resource. Configure the state machine to reference the resource.
- D Configure the CloudFormation template to store the API endpoint in a standard AWS::AppConfig::ConfigurationProfile resource. Configure the state machine to reference the resource.
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 AWS CloudFormation để deploy một Amazon API Gateway API và một AWS Step Functions state machine.
Developer cần state machine tham chiếu (reference) endpoint của API Gateway sau khi stack CloudFormation được deploy thành công. Yêu cầu chính là giải pháp MOST cost-effectively (tiết kiệm chi phí nhất), nghĩa là ưu tiên phương pháp native, không phụ thuộc dịch vụ bên ngoài tốn phí lưu trữ hoặc quản lý config.
🛠️ Bối cảnh kỹ thuật:
- CloudFormation quản lý tài nguyên declarative (tự động hóa IaC).
- API Gateway endpoint được tạo động (ví dụ:
https://abc123.execute-api.us-east-1.amazonaws.com/prod), cần inject vào ASL (Amazon States Language) của Step Functions. - Step Functions hỗ trợ tham chiếu động qua các tính năng mới như DefinitionSubstitutions (từ 2023, cập nhật đến 2026), cho phép thay thế placeholder trong ASL definition bằng giá trị từ CloudFormation outputs mà không cần update template.
- Mục tiêu: Tránh chi phí recurring từ dịch vụ như Secrets Manager (pay-per-secret) hoặc AppConfig (pay-per-configuration).
📘 Tài liệu tham khảo:
- AWS Step Functions DefinitionSubstitutions (cập nhật 2024-2026).
- CloudFormation AWS::StepFunctions::StateMachine (phiên bản mới nhất).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure the CloudFormation template to reference the API endpoint in the DefinitionSubstitutions property for the AWS::StepFunctions::StateMachine resource.
🧩 Lý do chi tiết:
- DefinitionSubstitutions là tính năng native của AWS::StepFunctions::StateMachine (ra mắt 2023, ổn định đến 2026), cho phép inject giá trị động (như API endpoint từ
Fn::GetAtthoặc outputs của API Gateway resource) trực tiếp vào ASL definition qua placeholder (ví dụ:${ApiEndpoint}). - Cost-effective nhất: Không tốn phí lưu trữ (free với CloudFormation), deploy một lần, state machine tự resolve giá trị tại runtime. Không cần dịch vụ ngoài.
- Ví dụ template:
ApiGateway: Type: AWS::ApiGateway::RestApi ... StateMachine: Type: AWS::StepFunctions::StateMachine Properties: DefinitionSubstitutions: ApiEndpoint: !Sub "https://${ApiGateway}.execute-api.${AWS::Region}.amazonaws.com/prod" - Đáp ứng MOST cost-effectively vì zero additional cost so với các option dùng dịch vụ managed.
🔍 Phân tích tất cả các phương án (đúng/sai)
-
✅ Configure the CloudFormation template to reference the API endpoint in the DefinitionSubstitutions property for the AWS::StepFunctions::StateMachine resource.
Đúng hoàn toàn: Như giải thích trên, đây là cách native, tích hợp trực tiếp CloudFormation-Step Functions, không phí ẩn, hỗ trợ dynamic substitution tại deploy time. Tiết kiệm nhất cho yêu cầu reference endpoint đơn giản. -
❌ Configure the CloudFormation template to store the API endpoint in an environment variable for the AWS::StepFunctions::StateMachine resource. Configure the state machine to reference the environment variable.
Sai: AWS::StepFunctions::StateMachine không hỗ trợ environment variables native như AWS Lambda (không có thuộc tínhEnvironmenttrong CloudFormation schema). Step Functions chỉ reference qua ASL input/output hoặc substitutions, không phải env vars. Sử dụng sẽ fail deploy và không cost-effective. -
❌ Configure the CloudFormation template to store the API endpoint in a standard AWS::SecretsManager::Secret resource. Configure the state machine to reference the resource.
Sai: Secrets Manager dùng cho secrets nhạy cảm (API key, password), endpoint public không cần secret. Step Functions có thể reference secret qua ARN trong ASL ("Resource": "arn:aws:secretsmanager:...), nhưng tốn phí ($0.40/secret/tháng + API calls, cập nhật 2026 pricing), không cost-effective cho dữ liệu public như endpoint. -
❌ Configure the CloudFormation template to store the API endpoint in a standard AWS::AppConfig::ConfigurationProfile resource. Configure the state machine to reference the resource.
Sai: AppConfig dành cho dynamic configuration/feature flags (free tier hạn chế, sau $0.003/request + storage), không phù hợp store endpoint tĩnh. Step Functions không có integration native với AppConfig cho reference trực tiếp, cần Lambda proxy phức tạp → tốn kém và overkill.
Kết luận 🎯: DefinitionSubstitutions là lựa chọn tối ưu, tuân thủ best practices AWS Well-Architected Framework (Pillar: Cost Optimization). Sử dụng ngay để deploy hiệu quả! 🚀
The Lambda function sometimes fails or times out. The developer needs to figure out why the Lambda function fails to process some messages.
Which solution will meet these requirements with the LEAST operational overhead?
- A Increase the maximum timeout of the Lambda function to 15 minutes. Check the AWS CloudTrail event history for error details.
- B Increase the visibility timeout of the SQS queue. Check logs in Amazon CloudWatch Logs for error details.
- C Create a dead-letter queue. Configure the Lambda function to send the failed messages to the dead-letter queue.
- D Create an Amazon DynamoDB table. Update the Lambda function to send the failed messages to the DynamoDB table.
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 một tình huống thực tế trong AWS: Một developer đang xây dựng ứng dụng sử dụng AWS Lambda để xử lý tin nhắn (messages) từ Amazon SQS queue. Lambda đôi khi fail (lỗi) hoặc timeout (hết thời gian), dẫn đến một số tin nhắn không được xử lý thành công. Yêu cầu là tìm nguyên nhân thất bại của các tin nhắn cụ thể với operational overhead thấp nhất (tức là giải pháp đơn giản, tự động hóa cao, ít cần can thiệp thủ công hoặc code thêm).
🛠️ Các yếu tố chính cần xem xét:
- SQS + Lambda integration: Lambda được trigger bởi SQS (event source mapping), đây là invocation bất đồng bộ (async). Khi Lambda fail, SQS sẽ retry message theo
maxReceiveCountmặc định (thường 3 lần). - Mục tiêu: Không chỉ retry mà cần debug lý do fail (xem chi tiết message nào fail và tại sao), ưu tiên giải pháp least overhead (tích hợp sẵn AWS, không cần custom code).
- Kiến thức cập nhật 2026: AWS vẫn hỗ trợ Dead-Letter Queue (DLQ) cho Lambda với SQS trigger một cách native (không cần code), qua console/CLI/Terraform. Timeout Lambda max vẫn 15 phút, CloudWatch Logs là chuẩn cho debug Lambda errors.
📘 Tài liệu tham khảo:
- AWS Lambda DLQ Documentation (cập nhật 2024-2026).
- Lambda with SQS (hỗ trợ DLQ tự động sau retries).
- SQS Visibility Timeout & Redrive Policy.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create a dead-letter queue. Configure the Lambda function to send the failed messages to the dead-letter queue.
Lý do (bằng tiếng Việt):
- Giải pháp này tự động hóa hoàn toàn 🏆: Lambda + SQS hỗ trợ DLQ native qua redrive policy của SQS hoặc async DLQ của Lambda. Sau khi message fail quá
maxReceiveCount(cấu hình trên SQS event source mapping), tin nhắn fail sẽ tự động gửi vào DLQ mà không cần code thêm trong Lambda handler. - Least overhead: Chỉ cần tạo SQS DLQ (1 phút qua console), attach vào Lambda trigger → Xem message fail trong DLQ để debug (payload gốc + metadata như error reason từ CloudWatch).
- Hoàn hảo cho debug cụ thể: DLQ lưu nguyên message fail, dễ replay/test.
📋 Phân tích chi tiết tất cả các phương án
-
Phương án 1: Increase the maximum timeout of the Lambda function to 15 minutes. Check the AWS CloudTrail event history for error details.
❌ Sai vì:- Timeout Lambda đã max 15 phút rồi (không tăng thêm được), chỉ giải quyết timeout chứ không debug lý do fail cụ thể của message.
- CloudTrail ghi API calls (như Invoke), không chi tiết Lambda execution errors (dùng CloudWatch Logs/X-Ray thay thế). Overhead cao vì phải manual check history, không target message cụ thể. Không giải quyết root cause.
-
Phương án 2: Increase the visibility timeout of the SQS queue. Check logs in Amazon CloudWatch Logs for error details.
❌ Sai vì:- Visibility timeout chỉ tránh duplicate processing (thời gian message "ẩn" sau poll), không liên quan trực tiếp đến Lambda fail/timeout hay debug message cụ thể. Tăng nó chỉ delay retry, không lưu message fail.
- CloudWatch Logs tốt cho Lambda errors tổng quát, nhưng không lưu message payload fail → Khó trace message nào fail. Overhead trung bình vì phải filter logs thủ công, không tự động isolate failed messages.
-
Phương án 3 (Đúng ✅): Create a dead-letter queue. Configure the Lambda function to send the failed messages to the dead-letter queue.
✅ Đúng vì (như giải thích trên): Tích hợp sẵn, zero-code, least overhead. DLQ capture chính xác failed messages với metadata (error, retries), dễ monitor qua CloudWatch Metrics/Alarms. Best practice AWS cho SQS-Lambda reliability. -
Phương án 4: Create an Amazon DynamoDB table. Update the Lambda function to send the failed messages to the DynamoDB table.
❌ Sai vì:- Yêu cầu custom code trong Lambda (try-catch → insert DynamoDB), tăng operational overhead cao (code, IAM roles, error handling, scaling).
- Không native như DLQ, dễ miss messages nếu code fail. DynamoDB tốt cho storage nhưng overkill cho debug tạm thời, tốn chi phí/thời gian maintain.
🧠 Kết luận: DLQ là giải pháp AWS-native, scalable, zero-maintenance cho vấn đề này. Recommend kết hợp CloudWatch Insights + X-Ray tracing để deep dive errors sau khi có DLQ! 🚀
Which solution will meet these requirements?
- A Create a certificate in ACM in any one of the Regions. Import the certificate into the ALB that is in each Region.
- B Create a global certificate in ACM. Update the CloudFormation template to deploy the global certificate to each ALB.
- C Create a certificate in ACM in each Region. Import the certificate into the ALB for each Region.
- D Create a certificate in ACM in the us-east-1 Region. Update the CloudFormation template to deploy the certificate to each ALB.
Xem giải thích
🧩 Phân tích chi tiết câu hỏi trắc nghiệm AWS
📖 Nội dung câu hỏi:
Một lập trình viên (developer) cần triển khai một ứng dụng trên ba AWS Regions khác nhau bằng cách sử dụng AWS CloudFormation. Mỗi Region sẽ có một môi trường AWS Elastic Beanstalk kèm theo Application Load Balancer (ALB). Developer muốn sử dụng AWS Certificate Manager (ACM) để triển khai các SSL certificates cho từng ALB này.
🛠️ Yêu cầu chính: Tìm giải pháp đáp ứng đầy đủ các điều kiện trên, đảm bảo certificates có thể được sử dụng hợp lệ cho ALB ở mọi Region. Lưu ý rằng ALB là tài nguyên regional (chỉ hoạt động trong Region cụ thể), và ACM certificates không thể chia sẻ cross-Region trừ một số trường hợp đặc biệt như CloudFront (global edge locations). Kiến thức cập nhật đến 2026: ACM vẫn yêu cầu tạo certificate riêng cho từng Region khi dùng với ALB/ELB/NLB (theo AWS docs mới nhất).
✅ Đáp án đúng:
Create a certificate in ACM in each Region. Import the certificate into the ALB for each Region.
Lý do lựa chọn (chi tiết):
🛡️ ACM certificates là regional resources: Theo thiết kế của AWS (cập nhật 2026), mỗi certificate chỉ có thể được sử dụng trong Region mà nó được tạo. Để hỗ trợ ALB ở 3 Regions, phải tạo một certificate riêng ở mỗi Region (ví dụ: us-east-1, eu-west-1, ap-southeast-1). Sau đó, trong CloudFormation stack (một stack per Region hoặc cross-stack references nếu dùng StackSets), tham chiếu và import certificate ARN vào ALB listener (HTTPS:443). Elastic Beanstalk tự động hỗ trợ listener config với ACM qua CloudFormation template (.ebextensions hoặc environment properties). Giải pháp này đảm bảo tính khả dụng cao, tuân thủ best practices, tránh lỗi "certificate not found" cross-Region. Sử dụng CloudFormation StackSets để deploy đồng bộ multi-Region.
🔍 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 bằng tiếng Anh. Mỗi phương án được đánh giá dựa trên hành vi thực tế của AWS ACM + ALB (kiểm chứng qua console/AWS CLI năm 2026).
-
❌ [SAI] Create a certificate in ACM in any one of the Regions. Import the certificate into the ALB that is in each Region.
Lý do sai: Certificate ACM không thể import cross-Region. Nếu tạo cert ở Region A (ví dụ: us-west-2), ALB ở Region B (eu-west-1) sẽ báo lỗi "InvalidCertificate" hoặc "ARN not found" khi attach listener. ACM không hỗ trợ export/import private key cross-Region cho ALB (chỉ public certs cho S3/CloudFront). Giải pháp này thất bại ngay lập tức ở 2/3 Regions. -
❌ [SAI] Create a global certificate in ACM. Update the CloudFormation template to deploy the global certificate to each ALB.
Lý do sai: ACM không có khái niệm "global certificate" cho ALB (cập nhật 2026). "Global" chỉ áp dụng cho CloudFront (sử dụng us-east-1 cert cho edge locations worldwide). ALB là regional-only, nên CloudFormation template sẽ fail validation khi reference non-existent global cert ARN. Đây là hiểu lầm phổ biến, dẫn đến deployment error. -
✅ [ĐÚNG] Create a certificate in ACM in each Region. Import the certificate into the ALB for each Region.
Lý do đúng (tóm tắt lại): Như đã giải thích ở phần đáp án, đây là cách duy nhất chuẩn AWS. Hỗ trợ automation qua CloudFormation (parameters cho cert ARN per Region), tích hợp mượt mà với Elastic Beanstalk (.ebextensions/config.yml). Zero downtime khi renew cert (ACM auto-renew). -
❌ [SAI] Create a certificate in ACM in the us-east-1 Region. Update the CloudFormation template to deploy the certificate to each ALB.
Lý do sai: us-east-1 cert chỉ dùng được cho CloudFront/CloudFront-like services (global distribution), không áp dụng cho ALB regional. ALB ở Regions khác sẽ reject cert ARN từ us-east-1 với lỗi cross-Region reference invalid. CloudFormation không tự động replicate cert; phải dùng ACM PCA (Private CA) cho enterprise cross-Region nhưng phức tạp hơn và không phải giải pháp đơn giản ở đây.
📘 Tài liệu tham khảo (AWS Official - cập nhật 2026)
- ACM Documentation: Request a public certificate → Xác nhận "regional resource".
- ALB + ACM Integration: Use ACM with ALB → "The certificate must be in the same Region".
- Elastic Beanstalk + CloudFormation Multi-Region: StackSets for multi-Region & EB ALB config.
- Best Practices: AWS Well-Architected Framework - Reliability Pillar (multi-Region cert management).
- Kiểm chứng thực tế: AWS CLI
aws acm list-certificates --region us-east-1chỉ liệt kê certs local Region.
🛡️ Lời khuyên DevOps: Sử dụng CloudFormation StackSets + Custom Resources để automate cert creation per Region. Nếu app global, cân nhắc Route 53 + CloudFront thay ALB cho edge SSL!
The security team must receive a notification immediately if an IAM role is created without the use of CloudFormation.
Which solution will meet this requirement?
- A Create an AWS Lambda function to filter events from CloudTrail if a role was created without CloudFormation. Configure the Lambda function to publish to the SNS topic. Create an Amazon EventBridge schedule to invoke the Lambda function every 15 minutes.
- B Create an AWS Fargate task in Amazon Elastic Container Service (Amazon ECS) to filter events from CloudTrail if a role was created without CloudFormation. Configure the Fargate task to publish to the SNS topic. Create an Amazon EventBridge schedule to run the Fargate task every 15 minutes.
- C Launch an Amazon EC2 instance that includes a script to filter events from CloudTrail if a role was created without CloudFormation. Configure the script to publish to the SNS topic. Create a cron job to run the script on tile EC2 instance every 15 minutes.
- D Create an Amazon EventBridge rule to filter events from CloudTrail if a role was created without CloudFormation. Specify the SNS topic as the target of the EventBridge rule.
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 thực thi chính sách bảo mật trong môi trường AWS, nơi công ty yêu cầu tất cả tài nguyên đám mây phải được triển khai qua AWS CloudFormation để đảm bảo tính nhất quán và kiểm soát. Một lập trình viên đã tạo Amazon SNS topic và đăng ký email của đội ngũ bảo mật (security team) vào topic này. Yêu cầu cốt lõi: Đội ngũ bảo mật phải nhận thông báo ngay lập tức (immediately) nếu có IAM role được tạo mà không sử dụng CloudFormation.
Để phát hiện điều này, chúng ta cần theo dõi AWS CloudTrail (dịch vụ ghi log các API calls, bao gồm sự kiện CreateRole của IAM). CloudTrail capture các hành động IAM real-time, và giải pháp phải phát hiện sự kiện không liên quan đến CloudFormation (ví dụ: event source không phải cloudformation.amazonaws.com). Giải pháp lý tưởng phải event-driven, real-time, không dùng polling định kỳ để tránh độ trễ và chi phí thừa.
🛠️ Mục tiêu: Sử dụng cơ chế native AWS để filter event từ CloudTrail và gửi SNS notification ngay lập tức, tuân thủ nguyên tắc serverless và least privilege.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create an Amazon EventBridge rule to filter events from CloudTrail if a role was created without CloudFormation. Specify the SNS topic as the target of the EventBridge rule.
Lý do chọn đáp án này 🎯:
- Amazon EventBridge (trước đây là CloudWatch Events) là dịch vụ event bus native của AWS, hỗ trợ filter real-time các event từ CloudTrail mà không cần polling. Bạn có thể tạo EventBridge rule với pattern filter cụ thể cho event
CreateRole(eventName: "CreateRole", source: "iam.amazonaws.com") và loại trừ các event từ CloudFormation (detail.userAgent không chứa "CloudFormation"). - Target trực tiếp là SNS topic, kích hoạt notification ngay lập tức (latency <1 phút), hoàn hảo cho yêu cầu "immediately".
- Serverless, scalable, chi phí thấp, không cần quản lý compute resources. Đây là best practice theo AWS Well-Architected Framework (Operational Excellence pillar) đến năm 2026.
- ✅ Hoàn toàn tự động, không độ trễ, tích hợp sâu với CloudTrail và SNS.
📋 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 nội dung văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá dựa trên tính real-time, chi phí, độ phức tạp và tuân thủ yêu cầu.
-
Phương án A: Create an AWS Lambda function to filter events from CloudTrail if a role was created without CloudFormation. Configure the Lambda function to publish to the SNS topic. Create an Amazon EventBridge schedule to invoke the Lambda function every 15 minutes.
❌ Sai vì: Sử dụng EventBridge schedule (rate 15 phút) để invoke Lambda là polling định kỳ, dẫn đến độ trễ tối đa 15 phút – vi phạm yêu cầu "immediately". Lambda phải query CloudWatch Logs/CloudTrail thủ công (qua API GetQueryResults hoặc Athena), phức tạp và tốn kém hơn EventBridge native. Overkill cho task đơn giản, không serverless thuần túy. -
Phương án B: Create an AWS Fargate task in Amazon Elastic Container Service (Amazon ECS) to filter events from CloudTrail if a role was created without CloudFormation. Configure the Fargate task to publish to the SNS topic. Create an Amazon EventBridge schedule to run the Fargate task every 15 minutes.
❌ Sai vì: Fargate task + EventBridge schedule 15 phút cũng là polling, độ trễ lớn và quản lý container phức tạp (cần ECS cluster, task definition). Chi phí cao hơn (Fargate billing theo vCPU/memory), không real-time, không tận dụng event streaming native. Không phù hợp với DevOps best practice serverless năm 2026. -
Phương án C: Launch an Amazon EC2 instance that includes a script to filter events from CloudTrail if a role was created without CloudFormation. Configure the script to publish to the SNS topic. Create a cron job to run the script on tile EC2 instance every 15 minutes.
❌ Sai vì: EC2 instance + cron job 15 phút là cách cũ kỹ, không scalable, yêu cầu quản lý server thủ công (patch, scale, high availability). Polling gây độ trễ, chi phí EC2 liên tục (idle time), và rủi ro single point of failure. Trái ngược hoàn toàn với serverless paradigm của AWS hiện đại (2026). -
Phương án D (Đúng): Create an Amazon EventBridge rule to filter events from CloudTrail if a role was created without CloudFormation. Specify the SNS topic as the target of the EventBridge rule.
✅ Đúng vì: Như đã giải thích ở phần đáp án đúng – event-driven real-time, filter pattern đơn giản (ví dụ:{"detail": {"eventName": ["CreateRole"], "source": ["iam.amazonaws.com"]}}và negate CloudFormation), target SNS trực tiếp. Zero-management, cost-effective (~$1/million events).
📘 Tài liệu tham khảo (Cập nhật AWS 2026)
- AWS EventBridge với CloudTrail: EventBridge User Guide - CloudTrail Events – Hỗ trợ filter IAM events real-time.
- EventBridge Targets SNS: EventBridge Targets – Direct integration.
- CloudTrail IAM Logging: CloudTrail User Guide - IAM Events.
- AWS Well-Architected: Operational Excellence - Automation – Khuyến nghị EventBridge cho compliance monitoring.
- Sample EventBridge rule: AWS Console hoặc CDK/Terraform examples trên GitHub AWS Samples (2026 re:Invent updates nhấn mạnh AI-powered EventBridge).
🛠️ Lời khuyên DevOps: Sử dụng CloudFormation Guard (cfn-guard) hoặc AWS Config Rules kết hợp để enforce policy mạnh hơn! Nếu cần code sample, hỏi thêm nhé! 🚀
What should the development team do to meet these requirements?
- A Add a Resources section to the CloudFormation templates that contains AWS::Lambda::Function resources.
- B Add a Mappings section to the CloudFormation templates that contains AWS::Serverless::Function and AWS::Serverless::API.
- C Add a Transform section to the CloudFormation templates. Use the AWS SAM syntax to define the resources.
- D Add a Parameters section to the CloudFormation templates that specifies the relevant AWS SAM Globals section.
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 triển khai serverless infrastructure sử dụng AWS Serverless Application Model (AWS SAM), đồng thời yêu cầu tất cả infrastructure phải được deploy bằng AWS CloudFormation templates.
- Bối cảnh: Một công ty đang chuyển sang serverless computing cho các dịch vụ mới. Đội ngũ phát triển cần tạo hạ tầng serverless (như Lambda functions, API Gateway, DynamoDB, v.v.) một cách hiệu quả.
- Yêu cầu chính: Sử dụng AWS SAM để định nghĩa tài nguyên serverless, nhưng phải tích hợp vào CloudFormation templates để deploy (vì SAM thực chất là macro/transform trên CloudFormation).
- Mục tiêu: Tìm cách đúng để kết hợp SAM syntax vào CloudFormation template, giúp đơn giản hóa việc định nghĩa serverless resources mà không cần viết đầy đủ CloudFormation native syntax phức tạp.
📘 Kiến thức cập nhật (AWS 2026): AWS SAM phiên bản mới nhất (SAM CLI 1.118.0+ và CloudFormation SAM Transform v2) hỗ trợ macros như AWS::Serverless-2016-10-31 hoặc AWS::Serverless-Transform, cho phép viết template ngắn gọn hơn. Tài liệu chính thức: AWS SAM Developer Guide và CloudFormation SAM Transform.
✅ Đáp án đúng
Add a Transform section to the CloudFormation templates. Use the AWS SAM syntax to define the resources.
Lý do chọn đáp án này:
- AWS SAM hoạt động bằng cách thêm section
Transformvào CloudFormation template (ví dụ:Transform: AWS::Serverless-2016-10-31), sau đó sử dụng syntax SAM ngắn gọn nhưAWS::Serverless::Function,AWS::Serverless::Apiđể định nghĩa resources. - Điều này đáp ứng đầy đủ: Deploy qua CloudFormation (SAM chỉ là "lớp abstraction" trên CFN), hỗ trợ serverless toàn diện (Lambda, API Gateway, Layers, v.v.).
- 🛠️ Ví dụ template cơ bản:
Transform: AWS::Serverless-2016-10-31 Resources: MyFunction: Type: AWS::Serverless::Function Properties: ... - Đây là best practice theo AWS Well-Architected Framework cho serverless (Pillar: Operational Excellence).
🔍 Phân tích tất cả các phương án (đúng/sai)
Dưới đây là giải thích chi tiết từng lựa chọn, giữ nguyên nội dung gốc bằng tiếng Anh:
-
Add a Resources section to the CloudFormation templates that contains AWS::Lambda::Function resources.
❌ Sai: SectionResourceschỉ dùng để định nghĩa tài nguyên native CloudFormation (nhưAWS::Lambda::Function), nhưng không hỗ trợ SAM syntax. Điều này không tận dụng AWS SAM, dẫn đến template dài dòng, thiếu abstractions như event sources, permissions tự động. Không đáp ứng yêu cầu "sử dụng AWS SAM". -
Add a Mappings section to the CloudFormation templates that contains AWS::Serverless::Function and AWS::Serverless::API.
❌ Sai: SectionMappingsdùng để map giá trị (như Regions, InstanceTypes), không phải nơi định nghĩa resources nhưAWS::Serverless::FunctionhayAWS::Serverless::Api. Đặt SAM resources vào đây sẽ gây lỗi parse template khi deploy. -
Add a Transform section to the CloudFormation templates. Use the AWS SAM syntax to define the resources.
✅ Đúng: Như đã giải thích ở trên.Transformkích hoạt SAM macro, cho phép dùng SAM syntax trongResourcessection. Đây là cách chuẩn để build/deploy serverless app với SAM + CloudFormation. -
Add a Parameters section to the CloudFormation templates that specifies the relevant AWS SAM Globals section.
❌ Sai: SectionParametersdùng để truyền input động (như runtime, memorySize).Globalslà SAM-specific (cho default config như Runtime, Timeout), nhưng phải đặt trong SAM template, không phảiParameters. Không có cơ chế "specifies Globals" trong Parameters, và thiếuTransformsẽ không nhận diện Globals.
📚 Tài liệu tham khảo
- AWS SAM Template Anatomy 🛠️ (Chi tiết Transform và Globals).
- Deploy SAM Apps with CloudFormation.
- AWS Exam DOP-C02 (DevOps Pro): Topic "Serverless Architectures" – Best practice SAM transform.
Hy vọng phân tích này giúp bạn ôn thi hiệu quả! 🚀 Nếu cần ví dụ code đầy đủ, hãy hỏi thêm.
Which solution will meet these requirements?
- A Add an Amazon EventBridge rule for the Lambda function. Configure the EventBridge rule to react to failed events and to store the events in an Amazon DynamoDB table.
- B Configure the Lambda function with a dead-letter queue based in Amazon Kinesis. Update the Lambda function's execution role with the required permissions.
- C Configure the Lambda function with an Amazon Simple Queue Service (Amazon SQS) dead-letter queue. Update the Lambda function's execution role with the required permissions.
- D Configure the Lambda function with an Amazon Simple Queue Service (Amazon SQS) FIFO dead-letter queue. Update the Lambda function's execution role with the required permissions.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi xoay quanh một lập trình viên đang xây dựng ứng dụng gọi AWS Lambda theo chế độ asynchronous (không đồng bộ) để xử lý các sự kiện (events). Vấn đề là Lambda đôi khi thất bại ngẫu nhiên trong việc xử lý một số sự kiện. Yêu cầu là điều tra các sự kiện thất bại và bắt giữ (capture) chúng để phân tích sau.
🔍 Các yếu tố chính cần lưu ý:
- Lambda asynchronous invocations (từ nguồn như S3, SNS, EventBridge, hoặc trực tiếp invoke async) có cơ chế retry tự động (lên đến 2 lần retry sau lần invoke đầu).
- Nếu sau tất cả retries mà vẫn fail (ví dụ: timeout, out-of-memory, code error), Lambda sẽ gửi sự kiện đến Dead Letter Queue (DLQ) nếu được cấu hình.
- Mục tiêu: Capture failed events một cách đáng tin cậy, dễ điều tra (bao gồm payload gốc, logs, reason fail).
- Theo tài liệu AWS cập nhật 2024-2026 (Lambda runtime mới nhất), DLQ là giải pháp chuẩn cho asynchronous failures, không áp dụng cho synchronous invocations.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure the Lambda function with an Amazon Simple Queue Service (Amazon SQS) dead-letter queue. Update the Lambda function's execution role with the required permissions.
Lý do chi tiết 🛠️:
- AWS Lambda chính thức hỗ trợ DLQ cho asynchronous invocations sử dụng Amazon SQS standard queue hoặc SNS topic (không phải FIFO).
- Khi cấu hình DLQ là SQS queue, Lambda sẽ tự động gửi toàn bộ event payload thất bại (sau retries) vào queue này, kèm metadata như
requestId,errorMessage. - Cần update execution role của Lambda với IAM policy cho phép
sqs:SendMessageđến DLQ (ví dụ:arn:aws:sqs:*:*:dlq-name). - Giải pháp này đơn giản, đáng tin cậy, cho phép developer poll queue để investigate (sử dụng CloudWatch Logs + DLQ messages).
- Không cần code thêm, hoàn toàn managed, phù hợp DevOps best practice.
📋 Phân tích tất cả các phương án (đúng/sai)
Dưới đây là phân tích từng lựa chọn một dựa trên docs AWS Lambda Developer Guide (2026 edition). Tôi giữ nguyên văn bản gốc tiếng Anh của phương án, chỉ giải thích bằng tiếng Việt với lý do đúng/sai rõ ràng.
-
❌ SAI: Add an Amazon EventBridge rule for the Lambda function. Configure the EventBridge rule to react to failed events and to store the events in an Amazon DynamoDB table.
Giải thích: EventBridge có thể monitor Lambda invocations qua CloudWatch Events, nhưng không capture trực tiếp failed events payload. EventBridge rules chỉ trigger dựa trên metrics/logs (nhưInvocations,Errors), không lưu full event gốc vào DynamoDB. Giải pháp này phức tạp, không đáng tin cậy cho async failures (miss payload chi tiết), và không phải best practice cho DLQ. AWS khuyến nghị dùng DLQ native thay vì EventBridge routing. -
❌ SAI: Configure the Lambda function with a dead-letter queue based in Amazon Kinesis. Update the Lambda function's execution role with the required permissions.
Giải thích: Lambda không hỗ trợ Kinesis làm DLQ cho bất kỳ invocation type nào (theo AWS docs 2026). DLQ chỉ chấp nhận SQS standard/SNS, không phải Kinesis streams. Ngay cả update role cũng vô ích vì Lambda service không implement gửi message đến Kinesis DLQ. Sử dụng Kinesis sẽ yêu cầu custom code (Lambda destination hoặc DLQ handler), không meet yêu cầu "capture failed events" native. -
✅ ĐÚNG: Configure the Lambda function with an Amazon Simple Queue Service (Amazon SQS) dead-letter queue. Update the Lambda function's execution role with the required permissions.
Giải thích: Như đã nêu ở phần đáp án đúng. Đây là giải pháp chuẩn, hỗ trợ full async failure capture. SQS DLQ lưu message đến 14 ngày max visibility timeout, dễ integrate với Lambda/SQS console để debug. IAM policy mẫu:{ "Effect": "Allow", "Action": "sqs:SendMessage", "Resource": "arn:aws:sqs:region:account:dlq" }. -
❌ SAI: Configure the Lambda function with an Amazon Simple Queue Service (Amazon SQS) FIFO dead-letter queue. Update the Lambda function's execution role with the required permissions.
Giải thích: Lambda không hỗ trợ SQS FIFO queue làm DLQ (docs xác nhận chỉ standard SQS/SNS). FIFO queue có deduplication + ordering strict, nhưng Lambda DLQ cần at-least-once delivery linh hoạt cho failures. Cấu hình FIFO sẽ fail validation khi attach vào Lambda console/CLI, ngay cả với role permissions đúng.
📘 Tài liệu tham khảo (AWS Official - cập nhật 2026)
- AWS Lambda Developer Guide: Dead-letter queues (DLQ) – Chi tiết DLQ config cho async.
- Lambda Console Guide: Asynchronous invocation failures → DLQ with SQS/SNS only.
- Best Practices: AWS Well-Architected Framework - Reliability Pillar – Sử dụng DLQ cho event-driven apps.
- IAM Policy Examples: Lambda execution role for SQS DLQ.
Hy vọng phân tích này giúp bạn ôn thi AWS Certified DevOps Engineer Professional hiệu quả! 🚀 Nếu cần ví dụ code Terraform/CloudFormation, hỏi thêm nhé!