Ngân hàng đề — AWS Certified Developer Associate

Tìm thấy 1356 câu.

Câu 1121
A company runs its website on AWS. The company posts daily polls on its website and publishes the poll results next day. The website stores user responses in an Amazon DynamoDB table. After the poll results are published, the company does not need to keep the user responses.

A developer needs to implement a solution that will automatically remove old user responses from the DynamoDB table. The developer adds a new expiration_date attribute to the DynamoDB table. The developer plans to use the expiration_date attribute for the automation.

Which solution will meet these requirements with the LEAST development effort?
  1. A Create an AWS Lambda function to delete old user responses based on the expiration_date attribute. Create an Amazon EventBridge schedule to run the Lambda function daily.
  2. B Create an AWS Fargate task in Amazon Elastic Container Service (Amazon ECS) to delete old user responses based on the expiration_date attribute. Create an Amazon EventBridge schedule to run the Fargate task daily.
  3. C Create an AWS Glue job to delete old user responses based on the expiration_date attribute. Create an AWS Glue trigger schedule to run the job daily.
  4. D Enable TTL on the DynamoDB table and specify the expiration_date attribute. Expire old user responses by using DynamoDB TTL.
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 công ty chạy website trên AWS, nơi họ đăng các cuộc thăm dò (polls) hàng ngày và công bố kết quả vào ngày hôm sau. Các phản hồi từ người dùng (user responses) được lưu trữ trong bảng Amazon DynamoDB. Sau khi kết quả poll được công bố, công ty không cần giữ lại các phản hồi cũ nữa.

Một developer đã thêm thuộc tính mới expiration_date vào bảng DynamoDB để hỗ trợ tự động hóa việc xóa dữ liệu. Yêu cầu chính: Triển khai giải pháp tự động xóa các phản hồi cũ dựa trên expiration_date với ít nỗ lực phát triển nhất (LEAST development effort).

🛠️ Mục tiêu cốt lõi: Tìm giải pháp tích hợp sẵn của AWS, không cần viết code phức tạp, lập lịch thủ công, để DynamoDB tự xử lý việc xóa item khi hết hạn (dựa trên timestamp trong expiration_date). Điều này giúp tiết kiệm chi phí, vận hành và phát triển.

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

Đáp án đúng: Enable TTL on the DynamoDB table and specify the expiration_date attribute. Expire old user responses by using DynamoDB TTL.

Lý do chi tiết (bằng tiếng Việt):
🔥 DynamoDB TTL (Time to Live) là tính năng tích hợp sẵn của DynamoDB (ra mắt từ 2018 và vẫn là phiên bản mới nhất đến 2026), cho phép tự động xóa các item khi giá trị thuộc tính TTL (ở đây là expiration_date - một Unix epoch timestamp) đã quá hạn.

  • Không cần code thêm: Chỉ cần enable TTL qua AWS Console, CLI hoặc CDK/Terraform, chỉ định tên thuộc tính (expiration_date). DynamoDB tự xử lý xóa ngầm (background process), không tốn throughput.
  • LEAST development effort: Zero code, zero scheduling, zero serverless setup. Item được xóa trong vòng 48 giờ sau khi hết hạn, tiết kiệm chi phí lưu trữ (RCU/WCU không tính phí cho item đã expire).
  • Phù hợp yêu cầu: Tự động, dựa chính xác vào expiration_date, và chỉ xóa sau khi poll kết thúc (developer set giá trị này khi lưu response).
    📘 Tài liệu tham khảo: AWS DynamoDB TTL Documentation (cập nhật 2024-2026, hỗ trợ GSIs và sparse indexes).

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

Dưới đây là phân tích từng lựa chọn một cách chi tiết, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá dựa trên development effort, tính tự động, và hiệu quả với DynamoDB.

  • [SAI] Create an AWS Lambda function to delete old user responses based on the expiration_date attribute. Create an Amazon EventBridge schedule to run the Lambda function daily.
    ❌ Lý do sai: Yêu cầu viết code Lambda (query/scan DynamoDB, delete items), setup IAM roles, EventBridge rule để chạy hàng ngày. Effort cao: code logic xử lý lỗi, pagination (nếu table lớn), tốn RCU/WCU cho query/delete. Không "least effort" vì DynamoDB TTL làm việc này native mà không code. Phù hợp hơn nếu cần logic phức tạp, nhưng ở đây thừa thãi. 🛠️ Chi phí: Lambda invocations + DynamoDB ops.

  • [SAI] Create an AWS Fargate task in Amazon Elastic Container Service (Amazon ECS) to delete old user responses based on the expiration_date attribute. Create an Amazon EventBridge schedule to run the Fargate task daily.
    ❌ Lý do sai: Phức tạp nhất - cần containerize app (Docker image với code delete), deploy ECS cluster/Fargate, EventBridge target ECS, networking/VPC setup. Effort cực cao: quản lý container, scaling, logs. Tốn chi phí Fargate (vCPU/memory) cho task chạy hàng ngày, kém hiệu quả so với TTL (zero infra). Không phải "least effort", chỉ dùng nếu cần batch processing lớn. 🛠️ Chi phí: ECS Fargate + EventBridge + DynamoDB.

  • [SAI] Create an AWS Glue job to delete old user responses based on the expiration_date attribute. Create an AWS Glue trigger schedule to run the job daily.
    ❌ Lý do sai: AWS Glue dành cho ETL/data analytics (Spark jobs), không tối ưu cho delete DynamoDB (phải dùng Glue crawler/script để query/delete, hỗ trợ kém DynamoDB so với S3). Effort cao: viết Glue script (PySpark), catalog table, schedule trigger. Chậm (batch job), tốn chi phí DPU, và không native cho DynamoDB delete. TTL đơn giản hơn gấp bội. 🛠️ Chi phí: Glue DPU-hours + DynamoDB ops.

  • [ĐÚNG] Enable TTL on the DynamoDB table and specify the expiration_date attribute. Expire old user responses by using DynamoDB TTL.
    ✅ Lý do đúng (tóm tắt lại): Native feature, zero code/scheduling/infra, tự động xóa dựa chính xác expiration_date. Hoàn hảo cho use case "xóa dữ liệu hết hạn" với least effort. Metrics theo dõi qua CloudWatch (TTL deletions). 📈 Lợi ích thêm: Giảm dung lượng table tự động, hỗ trợ Point-in-Time Recovery (PITR).

🏆 Kết luận và khuyến nghị

🔥 TTL là giải pháp tối ưu nhất cho DynamoDB cleanup, đặc biệt với dữ liệu tạm thời như poll responses. Nếu table có Global Secondary Indexes (GSIs), TTL cũng tự propagate xóa (cập nhật 2023+).
💡 Best practice: Set expiration_date = current timestamp + 1 ngày khi insert item. Test bằng AWS Console trước production.
📘 Tài liệu bổ sung:

Nếu cần code sample enable TTL qua CDK, hãy hỏi thêm! 🚀

Câu 1122
A developer is creating a simple proof-of-concept demo by using AWS CloudFormation and AWS Lambda functions. The demo will use a CloudFormation template to deploy an existing Lambda function. The Lambda function uses deployment packages and dependencies stored in Amazon S3. The developer defined an AWS::Lambda::Function resource in a CloudFormation template. The developer needs to add the S3 bucket to the CloudFormation template.

What should the developer do to meet these requirements with the LEAST development effort?
  1. A Add the function code in the CloudFormation template inline as the code property.
  2. B Add the function code in the CloudFormation template as the ZipFile property.
  3. C Find the S3 key for the Lambda function. Add the S3 key as the ZipFile property in the CloudFormation template.
  4. D Add the relevant key and bucket to the S3Bucket and S3Key properties in the CloudFormation template.
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi mô tả một lập trình viên đang xây dựng demo proof-of-concept (PoC) đơn giản sử dụng AWS CloudFormation để triển khai một AWS Lambda function hiện có. Lambda function này sử dụng deployment packages (gói triển khai) và dependencies (các thư viện phụ thuộc) được lưu trữ trong Amazon S3. Nhà phát triển đã định nghĩa tài nguyên AWS::Lambda::Function trong template CloudFormation, nhưng cần thêm thông tin về S3 bucket chứa code để template có thể deploy Lambda một cách chính xác.

Yêu cầu chính: Thực hiện với ít nỗ lực phát triển nhất (LEAST development effort), nghĩa là tránh phải copy code thủ công, chỉnh sửa lớn hoặc các bước phức tạp, mà ưu tiên cách đơn giản, tận dụng tài nguyên sẵn có từ S3.

Đây là tình huống phổ biến trong DevOps khi sử dụng Infrastructure as Code (IaC) với CloudFormation để quản lý Lambda, đặc biệt khi code lớn hoặc có dependencies (không phù hợp inline). Kiến thức dựa trên tài liệu AWS cập nhật đến 2026, nơi AWS::Lambda::Function hỗ trợ tham chiếu S3 trực tiếp cho code packaging.

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

Đáp án đúng: Add the relevant key and bucket to the S3Bucket and S3Key properties in the CloudFormation template.

Lý do:
Đây là cách ít nỗ lực nhất vì chỉ cần thêm hai thuộc tính S3Bucket (tên bucket chứa code) và S3Key (đường dẫn object/key trong bucket, ví dụ: lambda-function.zip) vào phần Code của tài nguyên AWS::Lambda::Function trong template YAML/JSON. CloudFormation sẽ tự động tải code từ S3 mà không cần copy inline hay thay đổi code. Phù hợp hoàn hảo với code "stored in Amazon S3" và là best practice cho deployment packages lớn/dependencies (hỗ trợ lên đến 250MB unzipped). Không yêu cầu thêm công cụ như SAM CLI hay chỉnh sửa function.

🛠️ 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. Tôi đánh dấu ✅ cho đúng, ❌ cho sai, kèm giải thích rõ ràng dựa trên tài liệu AWS CloudFormation (cập nhật 2026).

  • ❌ [SAI] Add the function code in the CloudFormation template inline as the code property.
    Phương án này sai vì yêu cầu chèn toàn bộ code trực tiếp (inline) vào thuộc tính Code của template, dẫn đến nỗ lực lớn: phải copy-paste code vào file YAML/JSON, không hỗ trợ tốt cho deployment packages phức tạp hoặc dependencies từ S3 (giới hạn kích thước inline chỉ 4KB cho ZipFile, và không an toàn cho code lớn). Không tận dụng S3 sẵn có, vi phạm "LEAST effort".

  • ❌ [SAI] Add the function code in the CloudFormation template as the ZipFile property.
    Phương án này sai vì ZipFile chỉ dùng cho single-file inline code (code viết trực tiếp trong template, tự động zip thành .zip), không hỗ trợ reference S3 bucket hay deployment packages lớn/dependencies. Nếu code ở S3, việc copy vào ZipFile vẫn tốn effort cao và có giới hạn 4KB (không phù hợp packages từ S3). AWS khuyến cáo dùng S3 cho code lớn.

  • ❌ [SAI] Find the S3 key for the Lambda function. Add the S3 key as the ZipFile property in the CloudFormation template.
    Phương án này sai vì ZipFile không chấp nhận S3 key – nó chỉ dành cho inline code (string code trực tiếp), không phải đường dẫn S3. Dù tìm được S3 key, việc gán vào ZipFile sẽ gây lỗi stack creation (CloudFormation validate fail). Sai lầm phổ biến nhầm lẫn giữa ZipFile (inline) và S3 properties.

  • ✅ [ĐÚNG] Add the relevant key and bucket to the S3Bucket and S3Key properties in the CloudFormation template.
    Như đã giải thích ở trên: Cách chính xác, đơn giản nhất. Cấu trúc template ví dụ:

    Code:
      S3Bucket: !Ref MyCodeBucket
      S3Key: lambda-function.zip
    

    CloudFormation xử lý tải code từ S3 tự động.

📘 Tài liệu tham khảo và nguồn chính thức

Hy vọng phân tích này giúp bạn nắm vững! 🚀 Nếu cần ví dụ template đầy đủ, hãy hỏi thêm nhé!

Câu 1123
A developer is building a microservices-based application by using Python on AWS and several AWS services. The developer must use AWS X-Ray. The developer views the service map by using the console to view the service dependencies. During testing, the developer notices that some services are missing from the service map.

What can the developer do to ensure that all services appear in the X-Ray service map?
  1. A Modify the X-Ray Python agent configuration in each service to increase the sampling rate.
  2. B Instrument the application by using the X-Ray SDK for Python. Install the X-Ray SDK for all the services that the application uses.
  3. C Enable X-Ray data aggregation in Amazon CloudWatch Logs for all the services that the application uses.
  4. D Increase the X-Ray service map timeout value in the X-Ray console.
Xem giải thích

🧩 Phân tích 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 microservices dựa trên Python trên AWS, sử dụng nhiều dịch vụ AWS và AWS X-Ray để theo dõi và phân tích traces. Họ đang xem service map qua console X-Ray để kiểm tra dependencies giữa các services. Tuy nhiên, trong quá trình testing, một số services không xuất hiện trên service map.
Vấn đề cốt lõi: Service map chỉ hiển thị các services đã gửi traces đến X-Ray. Nếu services chưa được instrument (tích hợp code để ghi traces), chúng sẽ bị thiếu. Câu hỏi yêu cầu giải pháp đảm bảo tất cả services đều xuất hiện trên service map.
🛠️ Nguyên lý AWS X-Ray (cập nhật 2026): X-Ray thu thập traces từ ứng dụng qua SDK hoặc agent. Service map được xây dựng tự động từ dữ liệu traces, yêu cầu instrumentation đầy đủ ở tất cả services để vẽ dependencies chính xác.

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

Đáp án đúng: Instrument the application by using the X-Ray SDK for Python. Install the X-Ray SDK for all the services that the application uses.

Lý do:

  • Để services xuất hiện trên service map, phải instrument code bằng X-Ray SDK for Python (thư viện chính thức của AWS). SDK này tự động ghi traces cho các subsegments (như AWS SDK calls, HTTP requests) và gửi đến X-Ray daemon/agent.
  • Nếu chỉ dùng daemon/agent mà không instrument SDK, traces sẽ không đầy đủ, dẫn đến services thiếu trên map.
  • Giải pháp này yêu cầu cài đặt SDK cho TẤT CẢ services, đảm bảo traces từ mọi microservice được thu thập, từ đó service map hiển thị đầy đủ dependencies.
    📘 Tài liệu tham khảo: AWS X-Ray SDK for Python và X-Ray Service Map (phiên bản cập nhật 2026 xác nhận SDK là bắt buộc cho Python apps).

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

Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Tôi đánh dấu ✅ đúng hoặc ❌ sai, kèm giải thích rõ ràng:

  • Modify the X-Ray Python agent configuration in each service to increase the sampling rate.
    ❌ Sai: Tăng sampling rate chỉ làm tăng tỷ lệ traces được gửi (mặc định 1/1M requests), giúp có nhiều dữ liệu hơn nhưng KHÔNG làm services chưa instrument xuất hiện. Nếu code chưa dùng SDK để generate traces, agent chỉ thu thập daemon traces hạn chế (như TCP), không đủ vẽ service map đầy đủ. Sampling chỉ ảnh hưởng traces đã có, không giải quyết vấn đề thiếu services.

  • Instrument the application by using the X-Ray SDK for Python. Install the X-Ray SDK for all the services that the application uses.
    ✅ Đúng: Như giải thích ở trên. Instrument với SDK Python là bước bắt buộc để tạo và gửi traces chi tiết từ mọi service. Cài đặt pip install aws-xray-sdk và wrap code (ví dụ: xray_recorder.capture()) đảm bảo traces flow qua dependencies, service map tự động hiển thị tất cả. Đây là best practice cho microservices Python (cập nhật 2026).

  • Enable X-Ray data aggregation in Amazon CloudWatch Logs for all the services that the application uses.
    ❌ Sai: CloudWatch Logs Insights chỉ aggregate logs có X-Ray trace ID (qua plugin), dùng để query logs liên kết traces, KHÔNG tạo traces hay ảnh hưởng service map. Service map dựa hoàn toàn vào traces gửi trực tiếp đến X-Ray service, không qua CloudWatch. Tính năng này hỗ trợ debugging logs, không giải quyết thiếu services trên map.

  • Increase the X-Ray service map timeout value in the X-Ray console.
    ❌ Sai: Timeout value trên console chỉ kiểm soát thời gian hiển thị map động (mặc định 1 phút), ảnh hưởng refresh rate chứ KHÔNG thêm services thiếu traces. Nếu không có dữ liệu traces từ services, tăng timeout vô ích. Map chỉ build từ dữ liệu thực tế đã thu thập trong 1 giờ qua.

🛠️ Khuyến nghị thực hành: Sau khi instrument SDK, chạy daemon (aws-xray-daemon) trên EC2/Fargate/Lambda và test với traffic để verify map. Sử dụng sampling rules để tối ưu chi phí sau khi map đầy đủ.
📘 Nguồn bổ sung: AWS X-Ray Developer Guide (2026 edition, nhấn mạnh SDK instrumentation cho service maps).

Câu 1124 Chọn nhiều đáp án
A developer is building a containerized application on AWS. The application communicates with a third-party service by using API keys. The developer needs a secure way to store the API keys and pass the API keys to the containerized application.

Which solutions will meet these requirements? (Choose two.)
  1. A Store the API keys as a SecureString parameter in AWS Systems Manager Parameter Store. Grant the application access to retrieve the value from Parameter Store.
  2. B Store the API keys in AWS CloudFormation templates by using base64 encoding. Pass the API keys to the application through container definition environment variables.
  3. C Add a new AWS CloudFormation parameter to the CloudFormation template. Pass the API keys to the application by using the container definition environment variables.
  4. D Embed the API keys in the application. Build the container image on-premises. Upload the container image to Amazon Elastic Container Registry (Amazon ECR).
  5. E Store the API keys as a SecretString parameter in AWS Secrets Manager. Grant the application access to retrieve the value from Secrets Manager.
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 lưu trữ và truyền API keys một cách an toàn cho ứng dụng container hóa (containerized application) chạy trên AWS. Ứng dụng này giao tiếp với dịch vụ bên thứ ba qua API keys, nên cần tránh hardcode hoặc lưu trữ không an toàn để giảm rủi ro lộ thông tin nhạy cảm.

Yêu cầu chính:

  • Lưu trữ an toàn: Sử dụng dịch vụ AWS chuyên quản lý bí mật (secrets).
  • Truyền vào container: Cho phép ứng dụng truy xuất động (runtime) mà không embed trực tiếp.
  • Chọn TWO giải pháp phù hợp nhất theo best practices AWS (cập nhật đến 2026, với Secrets Manager và Parameter Store hỗ trợ tích hợp sâu với ECS/ECR/Fargate qua IAM roles và sidecar injection).

Vấn đề phổ biến: Tránh lưu secrets trong image, env vars tĩnh, hoặc CloudFormation plain text để tuân thủ nguyên tắc least privilege và zero trust.

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

Hai phương án đúng là lựa chọn đầu tiên và lựa chọn cuối cùng, vì chúng sử dụng dịch vụ AWS chuyên biệt để mã hóa và quản lý secrets, kết hợp IAM policies để cấp quyền truy xuất động cho container (qua ECS task role hoặc EKS IRSA). Điều này đảm bảo rotation tự động, audit logs (CloudTrail), và tích hợp native với container orchestrators như ECS/Fargate/EKS mà không expose secrets trong image hoặc config tĩnh.

📋 Phân tích chi tiết từng phương án

Dưới đây là phân tích TẤT CẢ các phương án, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá ✅ (Đúng - đáp ứng yêu cầu an toàn) hoặc ❌ (Sai - có lỗ hổng bảo mật hoặc không best practice).

  • Store the API keys as a SecureString parameter in AWS Systems Manager Parameter Store. Grant the application access to retrieve the value from Parameter Store.
    ✅ Đúng. AWS Systems Manager (SSM) Parameter Store hỗ trợ SecureString được mã hóa tự động bằng KMS (miễn phí cho standard tier). Container có thể retrieve qua AWS SDK/API với IAM role (ví dụ: ECS task role gọi GetParameter), hỗ trợ caching và rotation. Đây là giải pháp cost-effective cho secrets đơn giản, tích hợp tốt với ECS/ECR (cập nhật 2026: hỗ trợ hierarchical paths và advanced tier với VPC endpoints). 🛡️

  • Store the API keys in AWS CloudFormation templates by using base64 encoding. Pass the API keys to the application through container definition environment variables.
    ❌ Sai. Base64 chỉ là encoding, không phải mã hóa (dễ decode), nên secrets lộ trong CloudFormation template (lưu trong S3 hoặc console). Env vars trong container definition (ECS task def) cũng lưu tĩnh, dễ expose qua DescribeTaskDefinition API hoặc logs. Vi phạm AWS Well-Architected Security Pillar (không dùng cho production secrets). 🚫

  • Add a new AWS CloudFormation parameter to the CloudFormation template. Pass the API keys to the application by using the container definition environment variables.
    ❌ Sai. CloudFormation parameters yêu cầu input thủ công lúc stack creation/update, nhưng vẫn lưu plain text hoặc pseudo-params (NoEcho chỉ ẩn console, không mã hóa). Truyền qua env vars container làm secrets tĩnh và readable (qua API/CLI), không hỗ trợ rotation động. Rủi ro cao nếu stack export params. Không an toàn so với secrets managers. 🔓

  • Embed the API keys in the application. Build the container image on-premises. Upload the container image to Amazon Elastic Container Registry (Amazon ECR).
    ❌ Sai. Embed secrets vào code/image là anti-pattern lớn nhất (secrets "baked in"), dễ lộ khi scan image (ECR image scanning phát hiện nhưng không ngăn). Build on-premises thiếu AWS-native scanning/encryption (ECR private repos dùng KMS nhưng không protect embedded secrets). Vi phạm immutable infrastructure và dễ supply-chain attack. AWS khuyến cáo KHÔNG làm vậy từ 2018 đến 2026. 🕳️

  • Store the API keys as a SecretString parameter in AWS Secrets Manager. Grant the application access to retrieve the value from Secrets Manager.
    ✅ Đúng. Secrets Manager chuyên cho secrets phức tạp (JSON/multi-value), mã hóa KMS mặc định, auto-rotation (Lambda), versioning, và tích hợp sâu với ECS (secrets as env vars động qua task def), EKS (CSI driver), Lambda. Container retrieve qua IAM policy secretsmanager:GetSecretValue. Best practice 2026: Hỗ trợ cross-region replication và audit qua CloudTrail. 💎

🛠️ Lý do chọn đáp án đúng & lưu ý triển khai

  • SSM Parameter Store vs Secrets Manager: SSM rẻ hơn cho simple strings, Secrets Manager mạnh hơn cho rotation/multi-secrets. Cả hai đều retrieve at runtime qua IAM, tránh bake-in.
  • Triển khai mẫu (ECS): Sử dụng aws ssm get-parameter hoặc ECS secrets integration trong task definition.
  • Best practice 2026: Kết hợp với ECR Image Scanning, IAM Roles for Tasks (IRSA), và KMS customer-managed keys.

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

Câu 1125
A company runs an application on AWS. The application stores data in an Amazon DynamoDB table. Some queries are taking a long time to run. These slow queries involve an attribute that is not the table's partition key or sort key.

The amount of data that the application stores in the DynamoDB table is expected to increase significantly. A developer must increase the performance of the queries.

Which solution will meet these requirements?
  1. A Increase the page size for each request by setting the Limit parameter to be higher than the default value. Configure the application to retry any request that exceeds the provisioned throughput.
  2. B Create a global secondary index (GSI). Set query attribute to be the partition key of the index.
  3. C Perform a parallel scan operation by issuing individual scan requests. In the parameters, specify the segment for the scan requests and the total number of segments for the parallel scan.
  4. D Turn on read capacity auto scaling for the DynamoDB table. Increase the maximum read capacity units (RCUs).
Xem giải thích

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

Câu hỏi mô tả một ứng dụng chạy trên AWS sử dụng Amazon DynamoDB để lưu trữ dữ liệu. Vấn đề chính là một số truy vấn (queries) đang chạy chậm, đặc biệt là những truy vấn liên quan đến một thuộc tính (attribute) không phải là partition key hoặc sort key của bảng DynamoDB. Dự kiến lượng dữ liệu trong bảng sẽ tăng đáng kể, và developer cần tăng hiệu suất truy vấn để đáp ứng yêu cầu.

🛠️ Phân tích vấn đề cốt lõi:

  • Trong DynamoDB, truy vấn hiệu quả nhất chỉ có thể thực hiện trên partition key (hoặc partition key + sort key). Nếu truy vấn trên attribute khác, DynamoDB buộc phải dùng Scan (quét toàn bộ bảng), dẫn đến thời gian chậm và tiêu tốn RCU lớn (1MB/s giới hạn).
  • Với dữ liệu tăng mạnh, Scan sẽ càng kém hiệu quả, có thể gây timeout hoặc chi phí cao.
  • Giải pháp cần tối ưu hóa truy vấn cụ thể mà không ảnh hưởng toàn bộ bảng, phù hợp với kiến trúc serverless của DynamoDB (cập nhật đến 2026: DynamoDB vẫn ưu tiên index cho query non-key).

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

Đáp án đúng: Create a global secondary index (GSI). Set query attribute to be the partition key of the index.

Lý do chi tiết 🏆:

  • GSI (Global Secondary Index) cho phép tạo index riêng với partition key mới dựa trên attribute cần query, giúp truy vấn O(1) nhanh chóng mà không cần Scan toàn bảng.
  • GSI hỗ trợ query độc lập với bảng chính, scale riêng (provisioned hoặc on-demand capacity), phù hợp dữ liệu tăng (có thể auto scaling RCU/ WCUs cho GSI).
  • Theo best practices AWS 2026: GSI là giải pháp chuẩn cho truy vấn trên non-key attributes, giảm latency từ giây xuống ms, tiết kiệm chi phí so với Scan.
  • Không ảnh hưởng dữ liệu hiện tại, chỉ thêm index (payload tối đa 400KB/item).

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

Dưới đây là phân tích từng phương án (giữ nguyên văn bản gốc bằng tiếng Anh). Tôi đánh dấu ✅ đúng hoặc ❌ sai, kèm lý do cụ thể bằng tiếng Việt dựa trên docs AWS mới nhất:

  • ❌ Phương án A: Increase the page size for each request by setting the Limit parameter to be higher than the default value. Configure the application to retry any request that exceeds the provisioned throughput.
    Lý do sai 🚫: Parameter Limit chỉ kiểm soát số item trả về mỗi request (pagination), không cải thiện tốc độ query trên non-key (vẫn dùng Scan chậm). Tăng Limit làm request lớn hơn, dễ throttle (vượt RCU), và retry chỉ che giấu vấn đề chứ không giải quyết gốc rễ. Với dữ liệu tăng, tình trạng tệ hơn, không scalable.

  • ✅ Phương án B: Create a global secondary index (GSI). Set query attribute to be the partition key of the index.
    Lý do đúng 🎯: Như đã giải thích ở trên, GSI biến attribute chậm thành partition key mới, cho phép Query nhanh (không Scan). Hỗ trợ projection attributes để tiết kiệm storage/RCU. AWS khuyến nghị cho trường hợp này (GSI có thể có 20/index/table, unlimited GSI/table từ 2023+).

  • ❌ Phương án C: Perform a parallel scan operation by issuing individual scan requests. In the parameters, specify the segment for the scan requests and the total number of segments for the parallel scan.
    Lý do sai ⏳: Parallel Scan chỉ phân chia Scan toàn bảng thành segments (tối đa 1MB/s/segment), vẫn quét toàn bộ dữ liệu nên chậm với bảng lớn (dữ liệu tăng sẽ nhân latency lên). Không hiệu quả cho query specific attribute, tiêu tốn RCU cao (Eventual Consistency), và AWS khuyên tránh Scan cho production queries.

  • ❌ Phương án D: Turn on read capacity auto scaling for the DynamoDB table. Increase the maximum read capacity units (RCUs).
    Lý do sai 📈: Auto scaling RCU tăng throughput tổng thể (min-max RCU), giúp tránh throttle nhưng không giảm thời gian Scan (vẫn quét toàn bảng). Với non-key query, RCU tăng chỉ làm chi phí cao hơn mà latency vẫn dài (giây/phút). Không giải quyết gốc rễ, chỉ là "băng cá nhân" cho vấn đề scale.

📘 Tài liệu tham khảo

  • AWS DynamoDB Developer Guide (2026): GSI Best Practices – Chi tiết về Query vs Scan.
  • DynamoDB Best Practices: Improving Query Performance.
  • AWS Well-Architected Framework - Reliability Pillar: Khuyến nghị index cho access patterns.
  • Exam Prep DOP-C02: Chủ đề DynamoDB Optimization (GSI là đáp án chuẩn tương tự).

Hy vọng phân tích này giúp bạn ôn thi hiệu quả! 🚀 Nếu cần thêm ví dụ code SDK, hãy hỏi nhé!

Câu 1126
A company runs a payment application on Amazon EC2 instances behind an Application Load Balance. The EC2 instances run in an Auto Scaling group across multiple Availability Zones. The application needs to retrieve application secrets during the application startup and export the secrets as environment variables. These secrets must be encrypted at rest and need to be rotated every month.

Which solution will meet these requirements with the LEAST development effort?
  1. A Save the secrets in a text file and store the text file in Amazon S3. Provision a customer managed key. Use the key for secret encryption in Amazon S3. Read the contents of the text file and read the export as environment variables. Configure S3 Object Lambda to rotate the text file every month.
  2. B Save the secrets as strings in AWS Systems Manager Parameter Store and use the default AWS Key Management Service (AWS KMS) key. Configure an Amazon EC2 user data script to retrieve the secrets during the startup and export as environment variables. Configure an AWS Lambda function to rotate the secrets in Parameter Store every month.
  3. C Save the secrets as base64 encoded environment variables in the application properties. Retrieve the secrets during the application startup. Reference the secrets in the application code. Write a script to rotate the secrets saved as environment variables.
  4. D Store the secrets in AWS Secrets Manager. Provision a new customer master key. Use the key to encrypt the secrets. Enable automatic rotation. Configure an Amazon EC2 user data script to programmatically retrieve the secrets during the startup and export as environment variables.
Xem giải thích

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

Câu hỏi mô tả một ứng dụng xử lý thanh toán (payment application) 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 Auto Scaling Group (ASG) trải rộng qua nhiều Availability Zones (AZs) để đảm bảo tính sẵn sàng cao. 📈

Yêu cầu chính của ứng dụng:

  • Lấy secrets (bí mật ứng dụng) trong quá trình khởi động (startup).
  • Xuất secrets dưới dạng environment variables để ứng dụng sử dụng.
  • Secrets phải được mã hóa tại chỗ nghỉ (encrypted at rest).
  • Xoay vòng (rotate) secrets mỗi tháng.
  • Giải pháp phải có ÍT NHIỆU CÔNG SỨC PHÁT TRIỂN NHẤT (LEAST development effort). 🛠️

Mục tiêu là chọn dịch vụ AWS phù hợp nhất, tận dụng tính năng tự động hóa cao để giảm thiểu code tùy chỉnh, script phức tạp hoặc quản lý thủ công. Điều này phù hợp với best practice DevOps trên AWS, ưu tiên dịch vụ managed như AWS Secrets Manager hoặc Parameter Store. 🔒

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

Đáp án đúng: Store the secrets in AWS Secrets Manager. Provision a new customer master key. Use the key to encrypt the secrets. Enable automatic rotation. Configure an Amazon EC2 user data script to programmatically retrieve the secrets during the startup and export as environment variables.

Lý do chọn đáp án này (tiêu chí LEAST development effort):

  • AWS Secrets Manager được thiết kế chuyên biệt cho secrets: hỗ trợ mã hóa at rest bằng AWS KMS customer managed key (CMK) (phiên bản mới nhất 2026 vẫn giữ nguyên, nay gọi là KMS key). 🔐
  • Tự động xoay vòng (automatic rotation) mỗi tháng chỉ cần enable một cú click – Secrets Manager tự tạo Lambda function để rotate với RDS, Redshift, hoặc custom (không cần dev Lambda riêng). ⏰
  • User data script trên EC2 đơn giản gọi AWS SDK/CLI để retrieve secrets và export env vars (ví dụ: aws secretsmanager get-secret-value), tích hợp dễ với ASG launch template. 🚀
  • Least effort: Không cần code rotation thủ công, scale tự động qua AZs, phù hợp payment app nhạy cảm. Hoàn hảo với AWS Well-Architected Framework (Security Pillar). 🌟

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

Dưới đây là phân tích từng lựa chọn, giữ nguyên nội dung gốc bằng tiếng Anh. Mỗi phương án được đánh giá dựa trên yêu cầu: mã hóa at rest, rotation hàng tháng, và least development effort. Sử dụng kiến thức AWS cập nhật 2026 (Secrets Manager hỗ trợ rotation lambda-less cho một số engine, Parameter Store yêu cầu Lambda manual).

  • ❌ [SAI] Save the secrets in a text file and store the text file in Amazon S3. Provision a customer managed key. Use the key for secret encryption in Amazon S3. Read the contents of the text file and read the export as environment variables. Configure S3 Object Lambda to rotate the text file every month.
    Giải thích sai: S3 hỗ trợ mã hóa SSE-KMS với customer managed key, nhưng S3 Object Lambda chỉ transform object khi đọc (không rotate tự động secrets). Rotation text file cần script/Lambda tùy chỉnh phức tạp, dễ lỗi, không an toàn cho payment secrets (file dễ leak). Development effort cao: code read/export + cronjob rotate. Không phải best practice. 🚫

  • ❌ [SAI] Save the secrets as strings in AWS Systems Manager Parameter Store and use the default AWS Key Management Service (AWS KMS) key. Configure an Amazon EC2 user data script to retrieve the secrets during the startup and export as environment variables. Configure an AWS Lambda function to rotate the secrets in Parameter Store every month.
    Giải thích sai: Parameter Store (Standard strings) dùng default KMS (AWS-managed, không customer-managed như yêu cầu ngầm). Retrieve/export bằng user data OK, nhưng rotation không tự động – phải dev Lambda riêng + IAM roles + schedule (hàng tháng), effort cao hơn Secrets Manager. SecureString hỗ trợ rotation nhưng vẫn cần Lambda template manual (không "automatic" one-click). Phù hợp less critical, nhưng không least effort cho secrets rotate. ⏳

  • ❌ [SAI] Save the secrets as base64 encoded environment variables in the application properties. Retrieve the secrets during the application startup. Reference the secrets in the application code. Write a script to rotate the secrets saved as environment variables.
    Giải thích sai: Env vars base64 không encrypted at rest đúng chuẩn (EC2 instance storage không tự mã hóa secrets). Phải hardcode vào app properties/code + script rotate thủ công (cronjob/EC2), rủi ro cao (leak qua AMI/logs), scale kém với ASG. Development effort cực cao: refactor code + manage script toàn bộ lifecycle. Vi phạm Security best practices. 💥

  • ✅ [ĐÚNG] Store the secrets in AWS Secrets Manager. Provision a new customer master key. Use the key to encrypt the secrets. Enable automatic rotation. Configure an Amazon EC2 user data script to programmatically retrieve the secrets during the startup and export as environment variables.
    Giải thích đúng: Như phần trên – toàn diện, tự động, least effort. Secrets Manager retrieve qua API nhanh (cacheable), integrate ASG/ALB seamless. ✅

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

Giải pháp này đảm bảo zero-downtime rotation và audit trail đầy đủ qua CloudTrail! 🚀

Câu 1127
A company is using Amazon API Gateway to invoke a new AWS Lambda function. The company has Lambda function versions in its PROD and DEV environments. In each environment, there is a Lambda function alias pointing to the corresponding Lambda function version. API Gateway has one stage that is configured to point at the PROD alias.

The company wants to configure API Gateway to enable the PROD and DEV Lambda function versions to be simultaneously and distinctly available.

Which solution will meet these requirements?
  1. A Enable a Lambda authorizer for the Lambda function alias in API Gateway. Republish PROD and create a new stage for DEV. Create API Gateway stage variables for the PROD and DEV stages. Point each stage variable to the PROD Lambda authorizer to the DEV Lambda authorizer.
  2. B Set up a gateway response in API Gateway for the Lambda function alias. Republish PROD and create a new stage for DEV. Create gateway responses in API Gateway for PROD and DEV Lambda aliases.
  3. C Use an environment variable for the Lambda function alias in API Gateway. Republish PROD and create a new stage for development. Create API gateway environment variables for PROD and DEV stages. Point each stage variable to the PROD Lambda function alias to the DEV Lambda function alias.
  4. D Use an API Gateway stage variable to configure the Lambda function alias. Republish PROD and create a new stage for development. Create API Gateway stage variables for PROD and DEV stages. Point each stage variable to the PROD Lambda function alias and to the DEV Lambda function alias.
Xem giải thích

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

Câu hỏi xoay quanh việc cấu hình Amazon API Gateway để gọi AWS Lambda function với các version và alias khác nhau cho môi trường PROD và DEV.

  • Công ty đang sử dụng API Gateway để kích hoạt một Lambda function mới.
  • Lambda có các version riêng cho PROD và DEV, mỗi version được trỏ bởi một alias tương ứng (ví dụ: alias "PROD" trỏ version PROD, alias "DEV" trỏ version DEV).
  • Hiện tại, API Gateway chỉ có một stage (giai đoạn triển khai) được cấu hình trỏ đến alias PROD.
  • Yêu cầu: Cấu hình API Gateway để cả PROD và DEV Lambda versions có thể được truy cập đồng thời và phân biệt rõ ràng (simultaneously and distinctly available). Nghĩa là, không thay đổi code hay integration cố định, mà phải linh hoạt switch giữa hai môi trường qua các stage riêng biệt.

🛠️ Giải pháp cốt lõi: Sử dụng stage variables của API Gateway trong phần integration URI với Lambda. Stage variables cho phép thay thế động phần alias của Lambda (ví dụ: arn:aws:lambda:...:function:myfunction:${stageVariables.lambdaAlias}), giúp mỗi stage (PROD/DEV) trỏ đến alias khác nhau mà không cần republish toàn bộ API nhiều lần. Đây là best practice theo tài liệu AWS mới nhất (2024-2026), hỗ trợ canary deployments và multi-stage environments.

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

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

Đáp án đúng:
Use an API Gateway stage variable to configure the Lambda function alias. Republish PROD and create a new stage for development. Create API Gateway stage variables for PROD and DEV stages. Point each stage variable to the PROD Lambda function alias and to the DEV Lambda function alias.

Lý do chi tiết:

  • Stage variables là tính năng native của API Gateway, cho phép định nghĩa biến động (như lambdaAlias) và sử dụng trong integration URI của Lambda (ví dụ: arn:aws:lambda:region:account:function:name:${stageVariables.lambdaAlias}).
  • Quy trình: Republish stage PROD (để apply biến), tạo stage mới DEV. Set lambdaAlias=PROD cho stage PROD và lambdaAlias=DEV cho stage DEV → Hai stage có URL riêng (e.g., prod-api.execute-api... và dev-api.execute-api...), gọi Lambda alias tương ứng đồng thời và phân biệt.
  • ✅ Đúng yêu cầu: Không thay đổi code Lambda hay API method, hỗ trợ traffic splitting/blue-green deployment. Hoạt động với Lambda versions/aliases theo AWS 2026 (hỗ trợ Provisioned Concurrency).

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

  • Phương án 1 (SAI):
    Enable a Lambda authorizer for the Lambda function alias in API Gateway. Republish PROD and create a new stage for DEV. Create API Gateway stage variables for the PROD and DEV stages. Point each stage variable to the PROD Lambda authorizer to the DEV Lambda authorizer.
    ❌ Sai vì: Lambda authorizer chỉ dùng để xác thực/authorize request (như token validation), không dùng để switch backend Lambda alias. Stage variables ở đây bị lạm dụng sai mục đích (authorizer không phải integration target). Không giải quyết việc gọi PROD/DEV versions distinctly.

  • Phương án 2 (SAI):
    Set up a gateway response in API Gateway for the Lambda function alias. Republish PROD and create a new stage for DEV. Create gateway responses in API Gateway for PROD and DEV Lambda aliases.
    ❌ Sai vì: Gateway responses chỉ custom HTTP responses cho errors/4xx/5xx (như static messages), không liên quan đến routing Lambda alias. Không thể dùng để invoke Lambda versions khác nhau, dẫn đến PROD/DEV không available distinctly.

  • Phương án 3 (SAI):
    Use an environment variable for the Lambda function alias in API Gateway. Republish PROD and create a new stage for development. Create API gateway environment variables for PROD and DEV stages. Point each stage variable to the PROD Lambda function alias to the DEV Lambda function alias.
    ❌ Sai vì: API Gateway không hỗ trợ "environment variables" như Lambda (Lambda mới có env vars cho runtime). Nó dùng stage variables, không phải env vars. Cú pháp lẫn lộn ("stage variable" ở cuối nhưng mở đầu sai), không work thực tế.

🛠️ Tóm tắt lợi ích giải pháp đúng: Tiết kiệm chi phí (không duplicate API), dễ promote code qua stages, tích hợp CI/CD (CodePipeline + API Gateway Deployments). Test ngay trên AWS Console để verify! 🚀

Câu 1128
A developer is working on an ecommerce platform that communicates with several third-party payment processing APIs. The third-party payment services do not provide a test environment.

The developer needs to validate the ecommerce platform's integration with the third-party payment processing APIs. The developer must test the API integration code without invoking the third-party payment processing APIs.

Which solution will meet these requirements?
  1. A Set up an Amazon API Gateway REST API with a gateway response configured for status code 200. Add response templates that contain sample responses captured from the real third-party API.
  2. B Set up an AWS AppSync GraphQL API with a data source configured for each third-party API. Specify an integration type of Mock. Configure integration responses by using sample responses captured from the real third-party API.
  3. C Create an AWS Lambda function for each third-party API. Embed responses captured from the real third-party API. Configure Amazon Route 53 Resolver with an inbound endpoint for each Lambda function's Amazon Resource Name (ARN).
  4. D Set up an Amazon API Gateway REST API for each third-party API. Specify an integration request type of Mock. Configure integration responses by using sample responses captured from the real third-party API.
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi mô tả một lập trình viên đang phát triển nền tảng thương mại điện tử (ecommerce platform) cần tích hợp với các API xử lý thanh toán từ bên thứ ba (third-party payment processing APIs). Vấn đề chính: Các dịch vụ bên thứ ba không cung cấp môi trường test (test environment), nên lập trình viên phải kiểm tra (validate) mã tích hợp API mà KHÔNG gọi thật đến các API bên thứ ba để tránh rủi ro như giao dịch thật hoặc chi phí không mong muốn.
Yêu cầu giải pháp: Cần một cách mock (giả lập) các phản hồi API từ bên thứ ba, sử dụng các mẫu phản hồi (sample responses) đã capture từ API thật trước đó. Giải pháp phải đơn giản, đáng tin cậy và phù hợp với AWS để test integration code một cách an toàn.
🛠️ Mục tiêu: Mock backend responses mà không invoke real APIs, tập trung vào REST API integration phổ biến cho payment gateways.

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

Đáp án đúng:
Set up an Amazon API Gateway REST API for each third-party API. Specify an integration request type of Mock. Configure integration responses by using sample responses captured from the real third-party API.

Lý do lựa chọn (theo tài liệu AWS mới nhất 2025-2026):

  • Amazon API Gateway hỗ trợ Mock Integration chính thức cho REST APIs (không phải HTTP APIs), cho phép định nghĩa integration request type = Mock và cấu hình integration responses bằng Velocity Template Language (VTL) với sample JSON từ API thật.
  • Giải pháp này hoàn hảo cho test integration: Client code gọi API Gateway như gọi API thật, nhưng Gateway trả mock responses mà không invoke backend.
  • Ưu điểm: Dễ setup, scale tự động, hỗ trợ CORS, authentication (như API keys), và logging qua CloudWatch. Không cần code Lambda hay dịch vụ khác.
  • Phù hợp DOP-C02 (DevOps Pro): Tích hợp CI/CD với CodePipeline, test local với SAM/Postman. ✅ Đây là best practice cho unit/integration testing third-party APIs không có sandbox.

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

Dưới đây là phân tích từng lựa chọn giữ nguyên văn bản gốc bằng tiếng Anh. Tôi đánh dấu ✅ (đúng) hoặc ❌ (sai), kèm giải thích hoàn toàn bằng tiếng Việt dựa trên tính khả thi, chính xác và best practice AWS.

  • Set up an Amazon API Gateway REST API with a gateway response configured for status code 200. Add response templates that contain sample responses captured from the real third-party API.
    ❌ Sai: Gateway responses chỉ dùng cho error handling (như 4xx/5xx) hoặc default responses, không mock full integration flow. Không hỗ trợ integration request mapping hay mock request/response đầy đủ. Nếu dùng, client vẫn cần backend integration (không phải Mock), dẫn đến gọi thật API nếu không config đúng. Không meet yêu cầu "without invoking".

  • Set up an AWS AppSync GraphQL API with a data source configured for each third-party API. Specify an integration type of Mock. Configure integration responses by using sample responses captured from the real third-party API.
    ❌ Sai: AppSync hỗ trợ MOCK resolver cho GraphQL, nhưng câu hỏi là về REST APIs từ third-party payment (không phải GraphQL). Developer cần test REST client code (như fetch/axios), không rewrite sang GraphQL schema. AppSync thêm complexity (schema/resolvers), không phù hợp ecommerce REST integration.

  • Create an AWS Lambda function for each third-party API. Embed responses captured from the real third-party API. Configure Amazon Route 53 Resolver with an inbound endpoint for each Lambda function's Amazon Resource Name (ARN).
    ❌ Sai: Lambda có thể embed responses (dùng API Gateway + Lambda proxy), nhưng Route 53 Resolver là cho DNS resolution hybrid cloud/VPC (inbound/outbound endpoints), KHÔNG liên quan đến mock API. Config ARN vào Resolver vô nghĩa, gây lỗi và complexity cao. Không phải giải pháp mock chuẩn.

  • Set up an Amazon API Gateway REST API for each third-party API. Specify an integration request type of Mock. Configure integration responses by using sample responses captured from the real third-party API.
    ✅ Đúng: Như giải thích trên, Mock integration là feature native của API Gateway REST API (docs AWS xác nhận). Setup: Tạo resource/method → Integration type = MOCK → Mapping templates cho request/response với sample data. Test ngay bằng Invoke URL, integrate với frontend/backend dễ dàng. Hoàn hảo cho dev/test phase.

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

🛠️ Lời khuyên DevOps: Kết hợp với LocalStack/SAM CLI để test local, rồi deploy via CDK/Terraform. Nếu scale, dùng HTTP APIs (nhưng Mock chỉ REST). Hy vọng phân tích giúp bạn ôn thi DOP-C02! 🚀

Câu 1129
A developer is storing many objects in a single Amazon S3 bucket. The developer needs to optimize the S3 bucket for high request rates.

How should the developer store the objects to meet this requirement?
  1. A Store the objects by using S3 Intelligent-Tiering.
  2. B Store the objects at the root of the S3 bucket.
  3. C Store the objects by using object key names distributed across multiple prefixes.
  4. D Store each object with an object tag named "prefix" that contains a unique value.
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi tập trung vào việc tối ưu hóa Amazon S3 bucket cho request rates cao khi một developer lưu trữ nhiều objects trong một bucket duy nhất.

  • Vấn đề chính: S3 có giới hạn throughput (số lượng requests/giây) cho mỗi prefix (phần đầu của object key). Nếu tất cả objects nằm ở cùng một vị trí (như root), bucket sẽ bị "hotspot" dẫn đến throttling (giới hạn tốc độ).
  • Mục tiêu: Cần cách tổ chức object key names để phân tán requests đều, tận dụng khả năng scale của S3 (mỗi prefix hỗ trợ lên đến 3,500 PUT/COPY/POST/DELETE requests/s và 5,500 GET/HEAD requests/s theo tài liệu AWS mới nhất 2024-2026).
  • Ngữ cảnh: Đây là best practice cho high-throughput workloads, không liên quan đến storage classes hay metadata.

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

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

Đáp án đúng: Store the objects by using object key names distributed across multiple prefixes.

Lý do 🛠️:

  • S3 tự động scale throughput dựa trên prefixes (phần đầu object key như prefix1/, prefix2/). Phân tán objects qua nhiều prefixes (ví dụ: user1/2024/file.jpg, user2/abcd/file.jpg hoặc dùng hash/random) giúp bucket xử lý hàng nghìn requests/s mà không bị giới hạn.
  • Đây là best practice chính thức của AWS cho high request rates, tránh "prefix explosion" hoặc hotspot ở root.

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

  • ❌ Store the objects by using S3 Intelligent-Tiering.
    Sai vì: S3 Intelligent-Tiering là storage class tự động chuyển objects giữa tiers (IA, Glacier) để tối ưu chi phí, không ảnh hưởng đến request rates hay partitioning. Nó chỉ quản lý lifecycle, không scale throughput.

  • ❌ Store the objects at the root of the S3 bucket.
    Sai vì: Lưu tất cả ở root (không có prefix) tạo hotspot, giới hạn toàn bucket chỉ 3,500 PUT/s và 5,500 GET/s. Với "many objects" và high rates, sẽ gây throttling ngay lập tức.

  • ✅ Store the objects by using object key names distributed across multiple prefixes.
    Đúng vì: Như đã giải thích ở phần đáp án. Phân tán prefixes (ít nhất 100-1,000 prefixes khuyến nghị) tận dụng parallel throughput của S3, scale vô hạn theo số prefixes. Ví dụ: random-hash/object.jpg.

  • ❌ Store each object with an object tag named "prefix" that contains a unique value.
    Sai vì: Object tags là metadata cho access control/billing (max 10 tags/object), không ảnh hưởng đến partitioning hay request rates. S3 chỉ dùng object key structure để phân bổ throughput, tags chỉ query/filter sau.

Kết luận 🚀: Luôn dùng prefix distribution cho S3 high-performance. Test với S3 Performance Toolkit nếu cần!

Câu 1130
A company deploys a new application to AWS. The company is streaming application logs to Amazon CloudWatch Logs. The company's development team must receive notification by email when the word "ERROR" appears in any log lines. A developer sets up an Amazon Simple Notification Service (Amazon SNS) topic and subscribes the development team to the topic.

What should the developer do next to meet the requirements?
  1. A Select the appropriate log group. Create a CloudWatch metric filter with "ERROR" as the search term. Create an alarm on this metric that notifies the SNS topic when the metric is 1 or higher.
  2. B In CloudWatch Logs Insights, select the appropriate log group. Create a metric query to search for the term "ERROR" in the logs. Create an alarm on this metric that notifies the SNS topic when the metric is 1 or higher.
  3. C Select the appropriate log group. Create an SNS subscription filter with "ERROR" as the filter pattern. Select the SNS topic as the destination.
  4. D Create a CloudWatch alarm that includes "ERROR" as a filter pattern, a log group dimension that defines the appropriate log group, and a destination that notifies the SNS topic.
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 đã triển khai ứng dụng mới lên AWS và đang stream các log ứng dụng vào Amazon CloudWatch Logs. Nhóm phát triển (development team) cần nhận thông báo qua email ngay khi từ khóa "ERROR" xuất hiện trong bất kỳ dòng log nào. Họ đã thiết lập một Amazon SNS topic và subscribe email của team vào topic đó.

📌 Yêu cầu chính: Developer cần thực hiện bước tiếp theo để kích hoạt thông báo realtime (thời gian thực) dựa trên nội dung log cụ thể ("ERROR"). Đây là kịch bản phổ biến trong monitoring logs trên AWS, sử dụng các tính năng của CloudWatch Logs để phát hiện pattern và trigger alert qua SNS. Kiến thức này dựa trên các tính năng cốt lõi của CloudWatch, không thay đổi lớn đến năm 2026 (AWS re:Invent 2025 vẫn nhấn mạnh Metric Filters cho log-based alerting).

🛠️ Quy trình chuẩn AWS:

  • Sử dụng CloudWatch Logs Metric Filter để trích xuất metric từ log pattern ("ERROR").
  • Tạo CloudWatch Alarm trên metric đó.
  • Alarm trigger gửi thông báo đến SNS topic → email.

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

Đáp án đúng: Select the appropriate log group. Create a CloudWatch metric filter with "ERROR" as the search term. Create an alarm on this metric that notifies the SNS topic when the metric is 1 or higher.

Lý do:

  • Đây là quy trình chuẩn xác và realtime theo tài liệu AWS mới nhất (2025-2026). Metric Filter trên CloudWatch Logs quét log theo pattern ("ERROR"), tạo metric tùy chỉnh (ví dụ: số lần "ERROR" xuất hiện). Khi metric ≥1, Alarm trigger ngay lập tức gửi đến SNS.
  • Đảm bảo thông báo tức thì cho mọi dòng log chứa "ERROR", không cần query thủ công.
  • ✅ Hoàn hảo cho yêu cầu: realtime, scalable, chi phí thấp.

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

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

  • ✅ Phương án ĐÚNG: Select the appropriate log group. Create a CloudWatch metric filter with "ERROR" as the search term. Create an alarm on this metric that notifies the SNS topic when the metric is 1 or higher.
    🟢 Giải thích đúng: Chọn log group đúng → Tạo Metric Filter với pattern { $.message = "*ERROR*" } (hoặc đơn giản "?ERROR?") để đếm số lần xuất hiện → Metric tăng khi có "ERROR" → Alarm trên metric threshold ≥1 → notify SNS. Đây là cách chuẩn AWS cho log-based alerting realtime, hỗ trợ pattern matching mạnh mẽ và tích hợp trực tiếp với SNS mà không cần middleware.

  • ❌ Phương án SAI: In CloudWatch Logs Insights, select the appropriate log group. Create a metric query to search for the term "ERROR" in the logs. Create an alarm on this metric that notifies the SNS topic when the metric is 1 or higher.
    🔴 Giải thích sai: CloudWatch Logs Insights dùng cho query phân tích lịch sử/ad-hoc (interactive queries), không phải realtime alerting. Metric từ Insights query chỉ là scheduled (ví dụ: mỗi 5 phút), không trigger ngay khi log mới đến. Không phù hợp cho yêu cầu "khi xuất hiện" tức thì; AWS khuyến nghị Metric Filters cho alerting realtime.

  • ❌ Phương án SAI: Select the appropriate log group. Create an SNS subscription filter with "ERROR" as the filter pattern. Select the SNS topic as the destination.
    🔴 Giải thích sai: SNS subscription filter policies chỉ filter dựa trên message attributes (JSON metadata) của message gửi đến SNS, không quét nội dung log từ CloudWatch Logs. CloudWatch Logs không stream trực tiếp log lines đến SNS với filter như vậy; subscription filter của Logs chỉ hỗ trợ Lambda/Kinesis/Firehose. Sai hoàn toàn luồng dữ liệu.

  • ❌ Phương án SAI: Create a CloudWatch alarm that includes "ERROR" as a filter pattern, a log group dimension that defines the appropriate log group, and a destination that notifies the SNS topic.
    🔴 Giải thích sai: CloudWatch Alarm chỉ hoạt động trên metrics (không có filter pattern trực tiếp trên log content). "Filter pattern" là tính năng của Metric Filter hoặc Logs subscription, không phải Alarm. Alarm cần metric trước; không thể set "destination" trực tiếp trong Alarm (phải qua SNS action). Sai về kiến trúc AWS cơ bản.

🧠 Tóm tắt nhanh: Chỉ Metric Filter + Alarm mới đảm bảo realtime detection và notify SNS chính xác. Các cách khác thiếu realtime hoặc sai dịch vụ! 🚀