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

Tìm thấy 1356 câu.

Câu 1001
A company has an application that stores data in Amazon RDS instances. The application periodically experiences surges of high traffic that cause performance problems. During periods of peak traffic, a developer notices a reduction in query speed in all database queries.

The team’s technical lead determines that a multi-threaded and scalable caching solution should be used to offload the heavy read traffic. The solution needs to improve performance.

Which solution will meet these requirements with the LEAST complexity?
  1. A Use Amazon ElastiCache for Memcached to offload read requests from the main database.
  2. B Replicate the data to Amazon DynamoDSet up a DynamoDB Accelerator (DAX) cluster.
  3. C Configure the Amazon RDS instances to use Multi-AZ deployment with one standby instance. Offload read requests from the main database to the standby instance.
  4. D Use Amazon ElastiCache for Redis to offload read requests from the main database.
Xem giải thích

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

Câu hỏi mô tả một ứng dụng lưu trữ dữ liệu trên Amazon RDS (cơ sở dữ liệu quan hệ SQL), thường gặp tình trạng surge traffic cao dẫn đến giảm tốc độ query (đặc biệt là read queries) trong giờ cao điểm. Đội ngũ xác định cần giải pháp caching đa luồng (multi-threaded) và có khả năng scale để offload read traffic từ database chính, nhằm cải thiện hiệu suất. Yêu cầu chính là giải pháp ít phức tạp nhất (LEAST complexity).

🔑 Yêu cầu cốt lõi:

  • Multi-threaded: Hỗ trợ xử lý đa luồng để tận dụng CPU tốt hơn cho high throughput reads.
  • Scalable: Dễ dàng mở rộng theo traffic.
  • Caching layer: Lưu cache kết quả queries phổ biến, giảm tải RDS.
  • Least complexity: Triển khai đơn giản, không cần thay đổi lớn kiến trúc (ví dụ: không migrate database).

✅ Đáp án đúng: Use Amazon ElastiCache for Memcached to offload read requests from the main database.

Lý do chọn đáp án này (theo kiến thức AWS cập nhật đến 2026):
🛠️ Amazon ElastiCache for Memcached là giải pháp caching multi-threaded tự nhiên (Memcached được thiết kế với multi-threading core, tận dụng đa CPU cores hiệu quả cho read-heavy workloads). Nó scalable qua cluster mode (sharding tự động, auto-scaling).
📈 Least complexity: Chỉ cần tích hợp client-side (như libmemcached) vào app để cache reads từ RDS, không cần persistence, replication phức tạp hay thay đổi DB engine. Hoạt động như key-value store đơn giản, offload >90% reads phổ biến.
✅ Phù hợp hoàn hảo với RDS (SQL), giảm latency xuống sub-ms, xử lý surges tốt mà không cần read replicas RDS (phức tạp hơn).

📋 Giải thí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 văn bản gốc tiếng Anh), đánh giá đúng/sai kèm lý do chi tiết bằng tiếng Việt:

  • Use Amazon ElastiCache for Memcached to offload read requests from the main database.
    ✅ ĐÚNG. Như đã giải thích ở trên: Multi-threaded native, scalable cluster, triển khai nhanh (one-click qua console/CLI), ít config nhất cho pure caching reads từ RDS. Theo AWS Well-Architected Framework (2024+), Memcached lý tưởng cho high-throughput, stateless caching.

  • Replicate the data to Amazon DynamoDSet up a DynamoDB Accelerator (DAX) cluster.
    ❌ SAI. Việc replicate dữ liệu từ RDS (SQL relational) sang DynamoDB (NoSQL key-value) đòi hỏi ETL phức tạp (sử dụng DMS, Lambda, hoặc custom scripts), thay đổi schema dữ liệu lớn → high complexity. DAX chỉ cache cho DynamoDB, không trực tiếp offload RDS. Không multi-threaded ở mức app-level, và surges RDS vẫn tồn tại nếu replicate không real-time.

  • Configure the Amazon RDS instances to use Multi-AZ deployment with one standby instance. Offload read requests from the main database to the standby instance.
    ❌ SAI. Multi-AZ standby chỉ dùng cho failover (sync replication async, không phục vụ reads). Không thể offload reads đến standby (chỉ primary xử lý reads/writes). Phải dùng Read Replicas (khác Multi-AZ) mới offload reads, nhưng vẫn không phải caching multi-threaded, lag replication ~giây, và complexity cao hơn ElastiCache (provision replicas, promote, etc.). RDS Multi-AZ không scalable horizontally như cache cluster.

  • Use Amazon ElastiCache for Redis to offload read requests from the main database.
    ❌ SAI. Redis dùng single-threaded event loop (dù Redis 7+ có multi-thread I/O và Cluster mode scalable), không multi-threaded core như Memcached → kém hiệu quả cho CPU-bound, high-concurrency reads (có thể bottleneck 1 core/node). Complexity tương đương Memcached nhưng không khớp yêu cầu "multi-threaded", Redis còn hỗ trợ persistence/pub-sub (overkill cho pure caching, tăng config).

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

  • AWS Documentation: ElastiCache for Memcached – Nhấn multi-threaded cho throughput cao.
  • ElastiCache for Redis vs Memcached: Comparison – Memcached cho multi-threaded simple caching.
  • RDS Best Practices: Read Traffic Offloading – Khuyến nghị ElastiCache trước read replicas.
  • Well-Architected Framework (2024): Performance Pillar – Caching với least complexity cho RDS workloads.

🛡️ Lời khuyên DevOps: Test với CloudWatch metrics (CPUUtilization, CacheMiss), enable auto-scaling cho ElastiCache để handle surges!

Câu 1002
A developer must provide an API key to an AWS Lambda function to authenticate with a third-party system. The Lambda function will run on a schedule. The developer needs to ensure that the API key remains encrypted at rest.

Which solution will meet these requirements?
  1. A Store the API key as a Lambda environment variable by using an AWS Key Management Service (AWS KMS) customer managed key.
  2. B Configure the application to prompt the user to provide the password to the Lambda function on the first run.
  3. C Store the API key as a value in the application code.
  4. D Use Lambda@Edge and only communicate over the HTTPS protocol.
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 bảo mật API key trong AWS Lambda function. Cụ thể:

  • Một developer cần cung cấp API key cho Lambda để xác thực (authenticate) với hệ thống bên thứ ba (third-party system).
  • Lambda function chạy theo lịch trình (on a schedule), nghĩa là nó tự động kích hoạt mà không có tương tác người dùng thời gian thực.
  • Yêu cầu cốt lõi: API key phải được mã hóa tại chỗ nghỉ (encrypted at rest), tức là khi lưu trữ trên AWS (không bị lộ plaintext).
    🛠️ Mục tiêu: Tìm giải pháp an toàn, tuân thủ best practices AWS (như nguyên tắc least privilege, secrets management), tránh hardcode hoặc lộ key. Đây là tình huống phổ biến trong DevOps, liên quan đến Lambda và KMS (kiến thức cập nhật đến 2026: AWS Lambda hỗ trợ encryption env vars với KMS customer managed keys mặc định, với cải tiến rotation tự động qua Lambda console).

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

Đáp án đúng: Store the API key as a Lambda environment variable by using an AWS Key Management Service (AWS KMS) customer managed key.

Lý do chi tiết:

  • Lambda hỗ trợ environment variables (biến môi trường) để lưu secrets như API key, và chúng được tự động mã hóa tại chỗ nghỉ bằng AWS KMS key.
  • Sử dụng customer managed key (CMK) cho phép developer kiểm soát hoàn toàn (rotation, policy, audit), khác với AWS managed key (ít linh hoạt hơn).
  • Hoàn hảo cho Lambda chạy schedule: Key được decrypt tự động lúc runtime mà không cần code thay đổi.
  • ✅ Tuân thủ AWS Well-Architected Framework (Security Pillar): Secrets không lưu plaintext, hỗ trợ rotation mà không downtime. Đây là best practice được khuyến nghị trong AWS docs mới nhất (2026).

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

Dưới đây là phân tích từng phương án một cách chi tiết, giữ nguyên văn bản gốc tiếng Anh. Tôi đánh dấu ✅ cho đúng, ❌ cho sai, kèm lý do bằng tiếng Việt rõ ràng:

  • ✅ [ĐÚNG] Store the API key as a Lambda environment variable by using an AWS Key Management Service (AWS KMS) customer managed key.
    🛡️ Giải thích: Phương án này hoàn toàn đúng vì Lambda env vars được encrypt at rest bằng KMS CMK (plaintext chỉ decrypt in-memory lúc runtime). An toàn cho scheduled Lambda, dễ quản lý qua IAM policies và KMS key policies. Không vi phạm yêu cầu, hỗ trợ audit qua CloudTrail.

  • ❌ [SAI] Configure the application to prompt the user to provide the password to the Lambda function on the first run.
    🚫 Giải thích: Sai hoàn toàn vì Lambda chạy schedule (không interactive), không có "user" để prompt password. Không khả thi, vi phạm yêu cầu encrypted at rest (password vẫn cần lưu đâu đó), và tăng rủi ro (user input dễ lộ).

  • ❌ [SAI] Store the API key as a value in the application code.
    🔓 Giải thích: Sai nghiêm trọng vì hardcode API key vào code (ví dụ ZIP package) không encrypt at rest – code lưu plaintext trong S3 hoặc Lambda storage. Dễ lộ qua git, decompile, hoặc Lambda versions. Vi phạm AWS best practices (secrets không hardcode).

  • ❌ [SAI] Use Lambda@Edge and only communicate over the HTTPS protocol.
    🌐 Giải thích: Sai và không liên quan vì Lambda@Edge chỉ dùng cho CloudFront edge computing (global latency), không giải quyết encrypt API key at rest. HTTPS chỉ bảo vệ in-transit (truyền dữ liệu), không phải at rest. Không áp dụng cho scheduled Lambda thông thường.

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

  • AWS Lambda Developer Guide: Environment Variables – Chi tiết encryption với KMS.
  • AWS KMS Developer Guide: Lambda Integration – Hỗ trợ CMK cho env vars.
  • AWS Well-Architected Framework (Security Pillar): Khuyến nghị secrets management với KMS/SSM/Secrets Manager.
  • Thi DOP-C02 (DevOps Pro 2026): Topic "Secure Secrets" thường test env vars + KMS.

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

Câu 1003
An IT department uses Amazon S3 to store sensitive images. After more than 1 year, the company moves the images into archival storage. The company rarely accesses the images, but the company wants a storage solution that maximizes resiliency. The IT department needs access to the images that have been moved to archival storage within 24 hours.

Which solution will meet these requirements MOST cost-effectively?
  1. A Use S3 Standard-Infrequent Access (S3 Standard-IA) to store the images. Use S3 Glacier Deep Archive with standard retrieval to store and retrieve archived images.
  2. B Use S3 Standard-Infrequent Access (S3 Standard-IA) to store the images. Use S3 Glacier Deep Archive with bulk retrieval to store and retrieve archived images.
  3. C Use S3 Intelligent-Tiering to store the images. Use S3 Glacier Deep Archive with standard retrieval to store and retrieve archived images.
  4. D Use S3 One Zone-Infrequent Access (S3 One Zone-IA) to store the images. Use S3 Glacier Deep Archive with bulk retrieval to store and retrieve archived images.
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 lựa chọn giải pháp lưu trữ trên Amazon S3 cho các hình ảnh nhạy cảm của bộ phận IT. Các yêu cầu chính bao gồm:

  • Ban đầu lưu trữ trên S3, sau hơn 1 năm chuyển sang archival storage (lưu trữ lưu trữ dài hạn).
  • Công ty hiếm khi truy cập các hình ảnh này, nhưng cần tối đa hóa resiliency (khả năng phục hồi dữ liệu cao, thường ngụ ý lưu trữ đa AZ với độ bền 99.999999999% - 11 9's).
  • Thời gian truy cập dữ liệu đã chuyển sang archival phải trong vòng 24 giờ.
  • Giải pháp phải tiết kiệm chi phí nhất (MOST cost-effectively), phù hợp với dữ liệu ít truy cập và lưu trữ dài hạn.

🛠️ Bối cảnh AWS S3 Storage Classes (cập nhật đến 2026): S3 cung cấp các lớp lưu trữ như Standard-IA (ít truy cập, độ trễ thấp, đa AZ), Intelligent-Tiering (tự động tối ưu), One Zone-IA (ít truy cập nhưng chỉ 1 AZ), và Glacier Deep Archive (archival rẻ nhất). Deep Archive có tùy chọn retrieval: Standard (≤12 giờ) và Bulk (≤48 giờ). Giải pháp cần kết hợp lớp lưu trữ chính + archival để đảm bảo resiliency cao và truy cập kịp thời.

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

Đáp án đúng: Use S3 Standard-Infrequent Access (S3 Standard-IA) to store the images. Use S3 Glacier Deep Archive with standard retrieval to store and retrieve archived images.

Lý do:

  • S3 Standard-IA lý tưởng cho dữ liệu ít truy cập sau 1 năm: chi phí thấp hơn Standard thông thường, độ bền cao (11 9's), lưu trữ đa AZ → tối đa hóa resiliency.
  • Glacier Deep Archive với standard retrieval (≤12 giờ) đáp ứng yêu cầu truy cập trong 24 giờ, rẻ nhất cho archival (thấp hơn Glacier Instant/Bulk cho trường hợp này).
  • Tiết kiệm chi phí nhất: Kết hợp IA cho giai đoạn trước archival + Deep Archive rẻ nhất, tránh phí monitoring của Intelligent-Tiering hoặc rủi ro single-AZ của One Zone-IA.
  • Không vi phạm bất kỳ yêu cầu nào, cân bằng hoàn hảo giữa cost, resiliency và thời gian truy cập.

📋 Giải thí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á dựa trên resiliency, thời gian truy cập, chi phí và phù hợp yêu cầu.

  • Use S3 Standard-Infrequent Access (S3 Standard-IA) to store the images. Use S3 Glacier Deep Archive with standard retrieval to store and retrieve archived images.
    ✅ Đúng. Như đã giải thích ở trên: Standard-IA đảm bảo resiliency đa AZ, standard retrieval (≤12 giờ) < 24 giờ, chi phí thấp nhất cho dữ liệu ít truy cập + archival dài hạn.

  • Use S3 Standard-Infrequent Access (S3 Standard-IA) to store the images. Use S3 Glacier Deep Archive with bulk retrieval to store and retrieve archived images.
    ❌ Sai. Standard-IA tốt cho phần lưu trữ chính, nhưng bulk retrieval của Deep Archive mất ≤48 giờ → vượt quá 24 giờ, không đáp ứng yêu cầu truy cập kịp thời. Chi phí rẻ hơn standard retrieval nhưng không phù hợp.

  • Use S3 Intelligent-Tiering to store the images. Use S3 Glacier Deep Archive with standard retrieval to store and retrieve archived images.
    ❌ Sai. Intelligent-Tiering có standard retrieval tốt (≤12 giờ), resiliency cao (đa AZ), nhưng chi phí cao hơn Standard-IA do phí monitoring tự động (dù dữ liệu dự đoán ít truy cập sau 1 năm). Không phải "MOST cost-effectively" vì Intelligent-Tiering phù hợp hơn cho access patterns không dự đoán được.

  • Use S3 One Zone-Infrequent Access (S3 One Zone-IA) to store the images. Use S3 Glacier Deep Archive with bulk retrieval to store and retrieve archived images.
    ❌ Sai kép: One Zone-IA chỉ 1 AZ → resiliency thấp (dữ liệu mất nếu AZ hỏng, dù độ bền vẫn 11 9's nhưng không "maximize"), không đáp ứng yêu cầu. Bulk retrieval ≤48 giờ > 24 giờ. Chi phí thấp nhưng hy sinh resiliency và thời gian truy cập.

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

  • AWS S3 Storage Classes: Amazon S3 Storage Classes – Chi tiết retrieval times Deep Archive.
  • Glacier Deep Archive: S3 Glacier retrieval options – Standard: 12h, Bulk: 48h.
  • Durability & Resiliency: S3 Durability – Standard-IA/Intelligent-Tiering: multi-AZ (11 9's), One Zone-IA: single-AZ.
  • Pricing Calculator: AWS Pricing – Xác nhận Standard-IA rẻ hơn Intelligent-Tiering cho infrequent access.

🛠️ Lời khuyên DevOps: Sử dụng S3 Lifecycle policies để tự động chuyển từ Standard-IA sang Deep Archive sau 1 năm, kết hợp Cross-Region Replication nếu cần resiliency cao hơn nữa!

Câu 1004
A developer is building a serverless application by using the AWS Serverless Application Model (AWS SAM). The developer is currently testing the application in a development environment. When the application is nearly finished, the developer will need to set up additional testing and staging environments for a quality assurance team.

The developer wants to use a feature of the AWS SAM to set up deployments to multiple environments.

Which solution will meet these requirements with the LEAST development effort?
  1. A Add a configuration file in TOML format to group configuration entries to every environment. Add a table for each testing and staging environment. Deploy updates to the environments by using the sam deploy command and the --config-env flag that corresponds to each environment.
  2. B Create additional AWS SAM templates for each testing and staging environment. Write a custom shell script that uses the sam deploy command and the --template-file flag to deploy updates to the environments.
  3. C Create one AWS SAM configuration file that has default parameters. Perform updates to the testing and staging environments by using the --parameter-overrides flag in the AWS SAM CLI and the parameters that the updates will override.
  4. D Use the existing AWS SAM template. Add additional parameters to configure specific attributes for the serverless function and database table resources that are in each environment. Deploy updates to the testing and staging environments by using the sam deploy command.
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 ứng dụng serverless bằng AWS Serverless Application Model (AWS SAM). Một lập trình viên đang phát triển và kiểm thử ứng dụng ở môi trường development (dev). Khi gần hoàn thành, cần thiết lập thêm các môi trường testing và staging dành cho đội ngũ chất lượng (QA team). Yêu cầu chính là sử dụng tính năng có sẵn của AWS SAM để triển khai (deploy) đến nhiều môi trường khác nhau, với ít nỗ lực phát triển nhất (LEAST development effort).
Điều này nhấn mạnh vào việc quản lý cấu hình đa môi trường một cách đơn giản, tránh viết code tùy chỉnh phức tạp, tận dụng CLI của AWS SAM để tự động hóa quy trình deploy mà không cần thay đổi lớn template chính.

✅ Đáp án đúng
Add a configuration file in TOML format to group configuration entries to every environment. Add a table for each testing and staging environment. Deploy updates to the environments by using the sam deploy command and the --config-env flag that corresponds to each environment.

Lý do lựa chọn:
Phương án này sử dụng tính năng SAM config file định dạng TOML (giới thiệu từ AWS SAM CLI phiên bản 1.28.0 trở lên, cập nhật đến 2024-2026), cho phép nhóm các cấu hình (như stack name, parameters, regions) theo từng môi trường trong một file duy nhất (ví dụ: samconfig.toml). Mỗi môi trường có một table riêng (như [default.deploy.parameters.dev], [default.deploy.parameters.testing], [default.deploy.parameters.staging]). Khi deploy, chỉ cần chạy lệnh sam deploy --config-env <env-name> (ví dụ: --config-env testing), AWS SAM CLI sẽ tự động áp dụng cấu hình tương ứng mà không cần chỉnh sửa template hay script tùy chỉnh. Đây là cách tối ưu nhất về effort, hỗ trợ native multi-environment deployment, giảm thiểu lỗi và dễ maintain.

📋 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, đánh dấu ✅ cho đúng và ❌ cho sai, dựa trên tài liệu AWS SAM mới nhất (SAM CLI v1.100+ đến 2026).

  • Add a configuration file in TOML format to group configuration entries to every environment. Add a table for each testing and staging environment. Deploy updates to the environments by using the sam deploy command and the --config-env flag that corresponds to each environment.
    ✅ Đúng 🛠️: Đây là giải pháp chính thức và ít effort nhất của AWS SAM. File TOML cho phép lưu trữ global và per-environment configs (parameters, capabilities, resolve s3, etc.) trong một nơi, hỗ trợ switch env chỉ bằng flag --config-env. Không cần code thêm, phù hợp hoàn hảo với yêu cầu "feature of AWS SAM".

  • Create additional AWS SAM templates for each testing and staging environment. Write a custom shell script that uses the sam deploy command and the --template-file flag to deploy updates to the environments.
    ❌ Sai 📜: Việc tạo nhiều template SAM riêng biệt cho từng env dẫn đến duplicate code lớn, khó maintain khi template chính thay đổi. Phải viết shell script tùy chỉnh với --template-file tăng effort phát triển cao (vi phạm "LEAST development effort"). Không tận dụng native feature của SAM cho multi-env.

  • Create one AWS SAM configuration file that has default parameters. Perform updates to the testing and staging environments by using the --parameter-overrides flag in the AWS SAM CLI and the parameters that the updates will override.
    ❌ Sai 🔧: File config với default parameters chỉ hỗ trợ cơ bản, nhưng dùng --parameter-overrides mỗi lần deploy yêu cầu ghi nhớ và truyền thủ công các overrides (ví dụ: sam deploy --parameter-overrides ParameterKey=Env,ParameterValue=testing), dễ lỗi, không scale cho nhiều env phức tạp. Không phải cách native multi-env, effort lặp lại cao hơn TOML config.

  • Use the existing AWS SAM template. Add additional parameters to configure specific attributes for the serverless function and database table resources that are in each environment. Deploy updates to the testing and staging environments by using the sam deploy command.
    ❌ Sai 🏗️: Chỉ dùng parameters trong template hiện tại yêu cầu chỉnh sửa template để thêm params động (như Env-specific timeouts, memory), sau đó deploy thủ công với --guided hoặc overrides lặp lại. Không hỗ trợ grouping configs per env tự động, dẫn đến effort cao khi manage nhiều env (phải nhớ params mỗi lần), không phải giải pháp least effort.

📘 Tài liệu tham khảo

  • AWS SAM Developer Guide: SAM config file (TOML) – Chi tiết về --config-env và multi-env.
  • AWS SAM CLI docs (cập nhật 2024-2026): Deployment configurations.
  • Best practices: AWS Well-Architected Framework for Serverless (Lens: Operational Excellence).
Câu 1005
A developer is working on an application that processes operating data from IoT devices. Each IoT device uploads a data file once every hour to an Amazon S3 bucket. The developer wants to immediately process each data file when the data file is uploaded to Amazon S3.

The developer will use an AWS Lambda function to process the data files from Amazon S3. The Lambda function is configured with the S3 bucket information where the files are uploaded. The developer wants to configure the Lambda function to immediately invoke after each data file is uploaded.

Which solution will meet these requirements?
  1. A Add an asynchronous invocation to the Lambda function. Select the S3 bucket as the source.
  2. B Add an Amazon EventBridge event to the Lambda function. Select the S3 bucket as the source.
  3. C Add a trigger to the Lambda function. Select the S3 bucket as the source.
  4. D Add a layer to the Lambda function. Select the S3 bucket as the source.
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ử lý dữ liệu thời gian thực từ các thiết bị IoT trên AWS. Cụ thể:

  • Mỗi thiết bị IoT upload một file dữ liệu lên Amazon S3 bucket mỗi giờ một lần.
  • Developer muốn xử lý ngay lập tức (immediately) mỗi file khi nó được upload, sử dụng AWS Lambda function.
  • Lambda đã được cấu hình với thông tin S3 bucket.
  • Yêu cầu: Cấu hình Lambda để tự động invoke ngay sau khi file upload.

🛠️ Mục tiêu chính: Sử dụng cơ chế trigger (kích hoạt) từ S3 để Lambda chạy đồng bộ với sự kiện upload file (ObjectCreated event). Điều này đảm bảo xử lý near real-time mà không cần polling thủ công, tiết kiệm chi phí và hiệu suất cao. AWS hỗ trợ tính năng này qua S3 Event Notifications, gửi event trực tiếp đến Lambda mà không cần middleware.

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

Đáp án đúng: Add a trigger to the Lambda function. Select the S3 bucket as the source.

Lý do:

  • Trong AWS Lambda Console hoặc CDK/Terraform, bạn thêm trigger trực tiếp từ S3 bucket vào function.
  • S3 sẽ gửi event notification (như s3:ObjectCreated:Put) đến Lambda ngay lập tức khi file upload.
  • Đây là cách chuẩn và đơn giản nhất, hỗ trợ event-driven architecture. Lambda xử lý đồng bộ/asynchronous tùy config, phù hợp với yêu cầu "immediately process".
  • ✅ Hoàn hảo cho scenario IoT data processing, scale tự động, không downtime.

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

Dưới đây là phân tích từng lựa chọn một cách chi tiết. Tôi giữ nguyên văn bản gốc bằng tiếng Anh, chỉ giải thích bằng tiếng Việt:

  • ❌ [SAI] Add an asynchronous invocation to the Lambda function. Select the S3 bucket as the source.
    Phương án này sai vì asynchronous invocation là cách gọi Lambda từ code (qua SDK/API như InvokeAsync), không phải cấu hình trigger từ S3. S3 bucket không thể là "source" trực tiếp cho async invocation mà không qua event. Nếu dùng, cần code custom để poll S3 – vi phạm yêu cầu "immediately" và tốn kém.

  • ❌ [SAI] Add an Amazon EventBridge event to the Lambda function. Select the S3 bucket as the source.
    Sai vì EventBridge (trước là CloudWatch Events) có thể route S3 events qua rule, nhưng không phải cách trực tiếp nhất. EventBridge thêm độ trễ nhỏ (dù low latency) và phức tạp hóa (cần tạo rule, target). S3 hỗ trợ trigger Lambda native, không cần EventBridge trừ khi cần filter nâng cao/multiple consumers.

  • ✅ [ĐÚNG] Add a trigger to the Lambda function. Select the S3 bucket as the source.
    Đúng hoàn toàn! Như giải thích ở trên: Trigger S3 là tính năng built-in của Lambda, tự động invoke trên S3 events (PutObject, etc.). Config qua Console (Lambda > Triggers > Add S3), chọn bucket + event type. Hỗ trợ batching nếu cần, scale theo traffic IoT.

  • ❌ [SAI] Add a layer to the Lambda function. Select the S3 bucket as the source.
    Sai vì Lambda Layers chỉ là tầng code reuse (libraries, dependencies) để chia sẻ giữa functions, không liên quan đến trigger/invocation. S3 bucket không thể là "source" cho layer – layer deploy như ZIP, không xử lý events.

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

  • AWS Lambda với S3 Triggers: Using AWS Lambda with Amazon S3 (AWS Docs, version 2024-2026, xác nhận trigger native cho ObjectCreated events).
  • S3 Event Notifications: Configuring Amazon S3 Event Notifications (hỗ trợ Lambda làm destination).
  • AWS DevOps Best Practices: AWS Well-Architected Framework - Reliability Pillar (event-driven cho IoT).
    🛠️ Lời khuyên: Test qua AWS Console hoặc SAM CLI để verify. Nếu traffic cao, enable destination on failure cho Lambda!
Câu 1006
A developer is setting up infrastructure by using AWS CloudFormation. If an error occurs when the resources described in the Cloud Formation template are provisioned, successfully provisioned resources must be preserved. The developer must provision and update the CloudFormation stack by using the AWS CLI.

Which solution will meet these requirements?
  1. A Add an --enable-termination-protection command line option to the create-stack command and the update-stack command.
  2. B Add a --disable-rollback command line option to the create-stack command and the update-stack command.
  3. C Add a --parameters ParameterKey=PreserveResources,ParameterValue=True command line option to the create-stack command and the update-stack command.
  4. D Add a --tags Key=PreserveResources,Value=True command line option to the create-stack command and the update-stack command.
Xem giải thích

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

Câu hỏi tập trung vào việc thiết lập cơ sở hạ tầng bằng AWS CloudFormation 📦. Một lập trình viên đang tạo và cập nhật stack CloudFormation sử dụng AWS CLI. Yêu cầu chính là: Nếu xảy ra lỗi trong quá trình provision (cung cấp) các tài nguyên được mô tả trong template, các tài nguyên đã được provision thành công PHẢI được bảo toàn (preserved) 🔒, thay vì bị rollback (hoàn tác) tự động.

  • Bối cảnh: Mặc định, khi tạo (create-stack) hoặc cập nhật (update-stack) stack CloudFormation gặp lỗi, AWS sẽ rollback toàn bộ stack, xóa hết các tài nguyên đã tạo thành công để stack trở về trạng thái trước đó. Điều này có thể gây mất dữ liệu hoặc tài nguyên không mong muốn.
  • Mục tiêu: Sử dụng tùy chọn CLI để vô hiệu hóa rollback, giữ nguyên các tài nguyên đã thành công, giúp developer dễ dàng debug và sửa lỗi mà không mất công tạo lại từ đầu 🛠️.
  • Phạm vi: Chỉ áp dụng cho lệnh CLI (aws cloudformation create-stack và update-stack), không phải qua Console hoặc SDK.

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

Đáp án đúng: Add a --disable-rollback command line option to the create-stack command and the update-stack command.

Lý do:

  • Tùy chọn --disable-rollback (hoặc viết tắt --no-rollback-on-failure) vô hiệu hóa cơ chế rollback mặc định khi stack creation/update thất bại ❌. Các tài nguyên đã provision thành công sẽ được giữ nguyên trong trạng thái CREATE_FAILED hoặc UPDATE_FAILED, cho phép developer kiểm tra, sửa template và retry mà không mất dữ liệu.
  • Áp dụng cho cả create-stack và update-stack qua AWS CLI, chính xác khớp yêu cầu.
  • Đây là tính năng chuẩn của CloudFormation từ lâu và vẫn được hỗ trợ đầy đủ đến phiên bản AWS CLI mới nhất (2026), giúp quản lý stack an toàn hơn trong môi trường DevOps 🚀.

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

Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên nội dung phương án gốc bằng tiếng Anh. Mỗi phương án được đánh giá với lý do đúng/sai dựa trên tài liệu AWS CloudFormation CLI chính thức 🛠️:

  • [SAI] Add an --enable-termination-protection command line option to the create-stack command and the update-stack command.
    ❌ Sai hoàn toàn: --enable-termination-protection chỉ bật bảo vệ termination cho stack, ngăn không cho xóa stack thủ công (delete-stack) qua CLI/Console. Nó không ảnh hưởng đến rollback khi lỗi provision. Nếu dùng, stack vẫn rollback bình thường khi fail, không preserve resources. Tính năng này dùng cho bảo vệ stack production, không liên quan đến lỗi creation/update.

  • [ĐÚNG] Add a --disable-rollback command line option to the create-stack command and the update-stack command.
    ✅ Đúng: Như giải thích ở trên, tùy chọn này ngăn rollback, giữ nguyên resources đã thành công. Hoàn hảo cho yêu cầu CLI-based deployment và troubleshooting.

  • [SAI] Add a --parameters ParameterKey=PreserveResources,ParameterValue=True command line option to the create-stack command and the update-stack command.
    ❌ Sai: --parameters dùng để truyền tham số động vào template (như giá trị cho !Ref). PreserveResources=True không phải tham số chuẩn của CloudFormation, chỉ là giá trị tùy ý và không có hiệu lực với rollback behavior. Không có tham số built-in nào tên như vậy để control preservation.

  • [SAI] Add a --tags Key=PreserveResources,Value=True command line option to the create-stack command and the update-stack command.
    ❌ Sai: --tags chỉ thêm metadata tags cho stack/resources để tổ chức, billing, hoặc policy (như IAM/Resource Groups). Tags không ảnh hưởng đến logic provision/rollback. PreserveResources=True chỉ là tag tùy chỉnh, vô dụng cho yêu cầu preserve resources khi lỗi.

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

Phân tích này dựa trên kinh nghiệm DevOps Engineer Professional, đảm bảo tuân thủ best practices AWS! Nếu cần ví dụ lệnh CLI cụ thể, hãy hỏi thêm nhé 🚀.

Câu 1007
A developer is building a serverless application that connects to an Amazon Aurora PostgreSQL database. The serverless application consists of hundreds of AWS Lambda functions. During every Lambda function scale out, a new database connection is made that increases database resource consumption.

The developer needs to decrease the number of connections made to the database. The solution must not impact the scalability of the Lambda functions.

Which solution will meet these requirements?
  1. A Configure provisioned concurrency for each Lambda function by setting the ProvisionedConcurrentExecutions parameter to 10.
  2. B Enable cluster cache management for Aurora PostgreSQL. Change the connection string of each Lambda function to point to cluster cache management.
  3. C Use Amazon RDS Proxy to create a connection pool to manage the database connections. Change the connection string of each Lambda function to reference the proxy.
  4. D Configure reserved concurrency for each Lambda function by setting the ReservedConcurrentExecutions parameter to 10.
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 được xây dựng bởi developer, sử dụng hàng trăm AWS Lambda functions kết nối đến cơ sở dữ liệu Amazon Aurora PostgreSQL. Vấn đề chính là: Mỗi khi Lambda scale out (tăng số lượng instance để xử lý tải), một kết nối database mới được tạo ra, dẫn đến tăng tiêu thụ tài nguyên database (như CPU, memory do quá nhiều connections).

Yêu cầu giải pháp:

  • Giảm số lượng connections đến database.
  • Không ảnh hưởng đến khả năng scale của Lambda (vẫn scale tự do theo tải).

Đây là vấn đề phổ biến trong serverless vì Lambda là stateless và cold starts tạo connections mới. Giải pháp cần connection pooling để tái sử dụng connections mà không giới hạn scale. (Kiến thức cập nhật AWS 2024-2026: RDS Proxy hỗ trợ Aurora Serverless v2 và PostgreSQL đầy đủ).

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

Đáp án đúng: Use Amazon RDS Proxy to create a connection pool to manage the database connections. Change the connection string of each Lambda function to reference the proxy.

Lý do:

  • RDS Proxy là dịch vụ connection pooling chuyên dụng cho serverless (Lambda/ECS), giúp tái sử dụng connections đến Aurora PostgreSQL mà không cần thay đổi code Lambda nhiều.
  • Lambda chỉ kết nối đến Proxy (một endpoint duy nhất), Proxy quản lý pool connections đến DB thực → Giảm đáng kể connections (có thể giảm 90% theo AWS benchmarks).
  • Không ảnh hưởng scalability: Lambda vẫn scale tự do, Proxy tự động scale theo tải (hỗ trợ lên đến hàng triệu connections).
  • Hoàn hảo cho Aurora PostgreSQL (hỗ trợ đầy đủ IAM auth, failover, multiplexing).

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

Dưới đây là phân tích từng lựa chọn, giữ nguyên nội dung gốc bằng tiếng Anh, kèm giải thích đúng/sai bằng tiếng Việt:

  • Configure provisioned concurrency for each Lambda function by setting the ProvisionedConcurrentExecutions parameter to 10.
    ❌ Sai: Provisioned Concurrency giữ Lambda "warm" để giảm cold starts, giúp khởi động nhanh hơn. Tuy nhiên, nó không giải quyết connection pooling – mỗi execution vẫn tạo connection mới khi scale out. Hơn nữa, set fixed 10 sẽ giới hạn scale (không linh hoạt), vi phạm yêu cầu. (Không hiệu quả cho hàng trăm Lambda).

  • Enable cluster cache management for Aurora PostgreSQL. Change the connection string of each Lambda function to point to cluster cache management.
    ❌ Sai: "Cluster cache management" không phải tính năng chuẩn của Aurora (có thể nhầm với RDS Proxy reader endpoint hoặc Performance Insights). Aurora không có "cluster cache management" riêng để pooling connections. Thay đổi connection string chỉ redirect, vẫn tạo connections mới từ Lambda → Không giảm connections, và có thể tăng tải nếu cache miss.

  • Use Amazon RDS Proxy to create a connection pool to manage the database connections. Change the connection string of each Lambda function to reference the proxy.
    ✅ Đúng: Như giải thích ở trên. RDS Proxy là giải pháp chuẩn AWS cho vấn đề này, hỗ trợ failover nhanh, IAM authentication, và tích hợp seamless với Lambda/Aurora PostgreSQL (v2). Giảm connections mà scale Lambda bình thường.

  • Configure reserved concurrency for each Lambda function by setting the ReservedConcurrentExecutions parameter to 10.
    ❌ Sai: Reserved Concurrency giới hạn tổng executions (set 10 nghĩa là max 10 concurrent), ngăn scale out vượt quá → Trực tiếp ảnh hưởng scalability. Không liên quan đến connection pooling, chỉ kiểm soát tải Lambda chứ không giảm connections đến DB.

📘 Tài liệu tham khảo

  • AWS RDS Proxy Documentation: RDS Proxy for Aurora (Cập nhật 2024: Hỗ trợ PostgreSQL 15+, multiplexing lên 100x).
  • Lambda Best Practices: Connection Pooling with RDS Proxy (Case study giảm 66% connections).
  • Aurora PostgreSQL Guide: Serverless Scaling (Tích hợp Proxy cho scale).
  • Exam Prep DOP-C02: AWS Certified DevOps Engineer Professional (Phiên bản 2024, Topic: Serverless & Databases).

Giải pháp này là best practice cho production serverless apps! 🚀 Nếu cần demo code, hỏi thêm nhé!

Câu 1008
A developer is preparing to begin development of a new version of an application. The previous version of the application is deployed in a production environment. The developer needs to deploy fixes and updates to the current version during the development of the new version of the application. The code for the new version of the application is stored in AWS CodeCommit.

Which solution will meet these requirements?
  1. A From the main branch, create a feature branch for production bug fixes. Create a second feature branch from the main branch for development of the new version.
  2. B Create a Git tag of the code that is currently deployed in production. Create a Git tag for the development of the new version. Push the two tags to the CodeCommit repository.
  3. C From the main branch, create a branch of the code that is currently deployed in production. Apply an IAM policy that ensures no other users can push or merge to the branch.
  4. D Create a new CodeCommit repository for development of the new version of the application. Create a Git tag for the development of the new version.
Xem giải thích

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

Câu hỏi mô tả tình huống một lập trình viên (developer) đang chuẩn bị phát triển phiên bản mới của ứng dụng. Phiên bản hiện tại đã được triển khai ở môi trường production (sản xuất). Trong quá trình phát triển phiên bản mới (code lưu trữ ở AWS CodeCommit), developer cần triển khai các bản sửa lỗi (bug fixes) và cập nhật cho phiên bản hiện tại đang chạy ở production.

Yêu cầu chính:

  • Duy trì sự ổn định của production (deploy fixes/updates cho version hiện tại).
  • Đồng thời phát triển version mới một cách độc lập.
  • Sử dụng AWS CodeCommit (dịch vụ Git repository của AWS) làm nơi lưu trữ code.

Mục tiêu là chọn giải pháp tốt nhất (best practice) theo mô hình Git branching để tách biệt công việc: maintain production mà không ảnh hưởng đến development mới. Đây là chủ đề liên quan đến Git workflow trong DevOps, đặc biệt với AWS CodeCommit (hỗ trợ đầy đủ Git features như branches, tags, merges đến phiên bản mới nhất 2026). 🛠️

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

Đáp án đúng: From the main branch, create a feature branch for production bug fixes. Create a second feature branch from the main branch for development of the new version.

Lý do (theo best practice Git flow trên AWS CodeCommit):

  • Từ main branch (thường đại diện cho production-ready code), tạo feature branch riêng cho bug fixes của production. Điều này cho phép deploy nhanh fixes mà không làm rối development mới.
  • Tạo feature branch thứ hai từ main cho version mới, đảm bảo isolation (cách ly) hoàn toàn giữa hai luồng công việc.
  • Sau khi hoàn thành, có thể merge từng branch về main qua Pull Request (PR) với approval rules (CodeCommit hỗ trợ từ 2023+).
  • Giải pháp này linh hoạt, scalable, phù hợp DevOps CI/CD (ví dụ: tích hợp CodeBuild/CodePipeline). Không cần repo mới hay lock cứng, tránh downtime production. 📘

🧩 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 theo thứ tự. Mỗi phương án giữ nguyên văn bản gốc bằng tiếng Anh, kèm giải thích đúng/sai bằng tiếng Việt với lý do cụ thể dựa trên AWS CodeCommit docs (cập nhật 2026).

  • From the main branch, create a feature branch for production bug fixes. Create a second feature branch from the main branch for development of the new version.
    ✅ Đúng. Như giải thích ở trên: Sử dụng feature branches từ main là standard Git workflow (GitFlow/Trunk-based). CodeCommit hỗ trợ branch isolation, PR approvals, và merge conflict resolution tự động. Hoàn hảo cho maintain production + develop parallel. Không rủi ro lẫn code.

  • Create a Git tag of the code that is currently deployed in production. Create a Git tag for the development of the new version. Push the two tags to the CodeCommit repository.
    ❌ Sai. Git tags là immutable (không thay đổi), dùng để đánh dấu release version cụ thể (ví dụ: v1.0). Không phù hợp cho ongoing development hoặc bug fixes liên tục – không thể push/update tags dễ dàng. Development version cần branch để commit/merge, tags chỉ reference point-in-time. Vi phạm yêu cầu deploy fixes động.

  • From the main branch, create a branch of the code that is currently deployed in production. Apply an IAM policy that ensures no other users can push or merge to the branch.
    ❌ Sai. Tạo branch cho production là ý tưởng tốt, nhưng IAM policy để lock push/merge không phải best practice. CodeCommit dùng approval rules trên PR (từ 2023) hoặc repository policies để control access, không phải IAM trực tiếp trên branch (IAM chỉ control repo-level). Lock cứng làm giảm collaboration, khó scale team, và không khuyến khích trong AWS DevOps (thay vào đó dùng feature branches linh hoạt).

  • Create a new CodeCommit repository for development of the new version of the application. Create a Git tag for the development of the new version.
    ❌ Sai. Tạo repo mới tách biệt làm khó sync changes giữa production và dev (cần cross-repo merge phức tạp). Không khuyến khích cho single application (AWS recommend single repo với branches). Tag cho dev lại immutable, không hỗ trợ iterative fixes. Gây overhead quản lý, vi phạm principle "one repo per app" trong AWS CodeCommit best practices.

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

  • AWS CodeCommit Developer Guide: Branching and merging & GitFlow integration.
  • AWS Well-Architected Framework - DevOps Pillar: Branching strategies cho CI/CD.
  • Git best practices on AWS: CodeCommit branching models.
  • Kiểm tra thực tế: CodeCommit hỗ trợ branch permissions qua resource-based policies và PR rules (enhanced 2025).

Giải pháp đúng đảm bảo zero-downtime updates và parallel development! 🚀 Nếu cần demo CodeCommit CLI, hỏi thêm nhé!

Câu 1009
A developer is creating an AWS CloudFormation stack. The stack contains IAM resources with custom names. When the developer tries to deploy the stack, they receive an InsufficientCapabilities error.

What should the developer do to resolve this issue?
  1. A Specify the CAPABILITY_AUTO_EXPAND capability in the CloudFormation stack.
  2. B Use an administrators role to deploy IAM resources with CloudFormation.
  3. C Specify the CAPABILITY_IAM capability in the CloudFormation stack.
  4. D Specify the CAPABILITY_NAMED_IAM capability in the CloudFormation stack.
Xem giải thích

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

Câu hỏi mô tả tình huống một lập trình viên (developer) đang tạo một AWS CloudFormation stack chứa các tài nguyên IAM (Identity and Access Management) với tên tùy chỉnh (custom names). Khi deploy stack, họ gặp lỗi InsufficientCapabilities (thiếu quyền capabilities).

🔍 Chi tiết vấn đề:

  • CloudFormation yêu cầu người dùng xác nhận rõ ràng các capabilities trước khi tạo/tạo lại các tài nguyên IAM có thể ảnh hưởng đến quyền truy cập AWS (như role, policy, user).
  • Lỗi này xảy ra vì stack có IAM resources với custom names (tên vật lý được chỉ định thủ công, không dùng logical ID mặc định hoặc Fn::GetAtt), đòi hỏi capability đặc biệt để tránh rủi ro bảo mật.
  • Developer cần thêm capability phù hợp khi gọi create-stack hoặc update-stack qua AWS CLI, SDK, Console, hoặc template để vượt qua lỗi.

🛠️ Ngữ cảnh cập nhật AWS (đến 2026): Theo tài liệu AWS CloudFormation mới nhất, capabilities vẫn là cơ chế bắt buộc cho IAM, với các loại như CAPABILITY_IAM (cơ bản), CAPABILITY_NAMED_IAM (cho tên tùy chỉnh), và CAPABILITY_AUTO_EXPAND (cho macro). Không có thay đổi lớn từ phiên bản 2023-2026.

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

Đáp án đúng: Specify the CAPABILITY_NAMED_IAM capability in the CloudFormation stack.

Lý do lựa chọn ✅:

  • Khi stack chứa IAM resources với custom names (ví dụ: PolicyName: "MyCustomPolicy"), CloudFormation yêu cầu capability CAPABILITY_NAMED_IAM để xác nhận người dùng hiểu rủi ro (IAM có thể ghi đè quyền hiện tại).
  • Capability này khác biệt với CAPABILITY_IAM (chỉ cho IAM thông thường), giúp deploy thành công mà không cần quyền admin cao hơn.
  • Cách thực hiện: Thêm --capabilities CAPABILITY_NAMED_IAM trong AWS CLI, hoặc khai báo trong template/Console.

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

Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá đúng/sai với lý do cụ thể dựa trên docs AWS:

  • ❌ Specify the CAPABILITY_AUTO_EXPAND capability in the CloudFormation stack.
    Sai vì: Capability này chỉ dùng cho macro expansion (tự động mở rộng macro trong template), không liên quan đến IAM resources hay custom names. Sử dụng sẽ không giải quyết lỗi InsufficientCapabilities cho IAM, dẫn đến thất bại deploy. 🧩 (Chỉ áp dụng khi template có AWS::CloudFormation::Macro).

  • ❌ Use an administrators role to deploy IAM resources with CloudFormation.
    Sai vì: Vai trò Administrator (IAM policy full quyền) không bỏ qua yêu cầu capabilities – đây là lớp bảo vệ riêng của CloudFormation để tránh deploy IAM nguy hiểm ngẫu nhiên. Lỗi vẫn xảy ra dù dùng role admin; phải thêm capability thủ công. 🚫 (Permissions và Capabilities là hai khái niệm độc lập).

  • ❌ Specify the CAPABILITY_IAM capability in the CloudFormation stack.
    Sai vì: CAPABILITY_IAM chỉ hỗ trợ IAM resources tiêu chuẩn (dùng logical ID hoặc Fn::GetAtt cho tên). Với custom names, nó không đủ, gây lỗi InsufficientCapabilities. Phải dùng CAPABILITY_NAMED_IAM nâng cao hơn. ⚠️ (AWS phân biệt rõ để bảo mật).

  • ✅ Specify the CAPABILITY_NAMED_IAM capability in the CloudFormation stack.
    Đúng vì: Đây là capability chính xác cho IAM với custom names, cho phép CloudFormation tạo/tạo lại tài nguyên IAM an toàn sau khi user xác nhận. Giải quyết trực tiếp lỗi và là best practice. 🎯

📘 Tài liệu tham khảo

  • AWS Official Docs: AWS CloudFormation IAM Capabilities (Cập nhật 2024-2026, xác nhận CAPABILITY_NAMED_IAM cho custom names).
  • AWS CLI Reference: aws cloudformation create-stack --capabilities CAPABILITY_NAMED_IAM – CLI Docs.
  • Exam Prep: AWS Certified DevOps Engineer Professional (DOP-C02) – Chủ đề CloudFormation IAM Handling.

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

Câu 1010
A company uses Amazon API Gateway to expose a set of APIs to customers. The APIs have caching enabled in API Gateway. Customers need a way to invalidate the cache for each API when they test the API.

What should a developer do to give customers the ability to invalidate the API cache?
  1. A Ask the customers to use AWS credentials to call the InvalidateCache API operation.
  2. B Attach an InvalidateCache policy to the IAM execution role that the customers use to invoke the API. Ask the customers to send a request that contains the Cache-Control:max-age=0 HTTP header when they make an API call.
  3. C Ask the customers to use the AWS SDK API Gateway class to invoke the InvalidateCache API operation.
  4. D Attach an InvalidateCache policy to the IAM execution role that the customers use to invoke the API. Ask the customers to add the INVALIDATE_CACHE query string parameter when they make an API call.
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 Amazon API Gateway với tính năng caching đã được kích hoạt trên các API. Công ty muốn cung cấp cho khách hàng (customers) khả năng invalidate (xóa bỏ) cache dành riêng cho từng API cụ thể khi họ test API.

📌 Chi tiết vấn đề:

  • API Gateway caching giúp cải thiện hiệu suất bằng cách lưu trữ response tạm thời (cache TTL).
  • Khi test, khách hàng cần làm mới cache ngay lập tức cho API đó, không phải xóa toàn bộ cache stage (vì xóa toàn bộ chỉ dành cho owner qua console/CLI).
  • Giải pháp phải an toàn, dễ thực hiện từ phía khách hàng, sử dụng IAM authentication (vì khách hàng invoke API qua IAM role/credentials).
  • Không nên yêu cầu khách hàng truy cập control plane API của AWS (như SDK admin), vì họ chỉ là end-user, không phải admin API.

🛠️ Ngữ cảnh AWS mới nhất (2024-2026): API Gateway hỗ trợ caching với client-side invalidation qua HTTP header, yêu cầu IAM policy execute-api:InvalidateCache. Không có thay đổi lớn ở phiên bản mới (HTTP APIs và REST APIs đều hỗ trợ tương tự).

✅ Đáp án đúng

Đáp án đúng là phương án thứ 2:
Attach an InvalidateCache policy to the IAM execution role that the customers use to invoke the API. Ask the customers to send a request that contains the Cache-Control:max-age=0 HTTP header when they make an API call.

Lý do lựa chọn:

  • ✅ Đây là cách chính thức và an toàn nhất theo AWS docs: Gắn IAM policy execute-api:InvalidateCache vào IAM role/credentials của khách hàng (dùng để invoke API). Khi khách hàng gửi request với header Cache-Control: max-age=0, API Gateway sẽ invalidate cache entry cụ thể cho route/method đó mà không ảnh hưởng cache khác.
  • ✅ Dễ implement: Khách hàng chỉ cần thêm header vào HTTP request (Postman, curl, SDK client).
  • ✅ Bảo mật: Policy giới hạn resource ARN cụ thể (ví dụ: arn:aws:execute-api:*:123456789012:api-id/stage/GET/path/*), tránh xóa toàn bộ.
  • ✅ Phù hợp test scenario, vì chỉ invalidate per-request.

📋 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 tiếng Anh, đánh dấu ✅/❌ và giải thích hoàn toàn bằng tiếng Việt dựa trên docs AWS mới nhất:

  • Ask the customers to use AWS credentials to call the InvalidateCache API operation.
    ❌ Sai: Không tồn tại InvalidateCache API operation trong data plane của API Gateway dành cho khách hàng. Đây là action IAM (execute-api:InvalidateCache), không phải API endpoint công khai. Khách hàng không thể gọi trực tiếp như vậy, chỉ owner mới dùng control plane API (như FlushStageCache qua CLI/SDK admin).

  • Attach an InvalidateCache policy to the IAM execution role that the customers use to invoke the API. Ask the customers to send a request that contains the Cache-Control:max-age=0 HTTP header when they make an API call.
    ✅ Đúng: Như giải thích ở trên. Policy cho phép khách hàng invalidate cache qua header HTTP chuẩn, chỉ ảnh hưởng cache entry của request đó. Đây là best practice cho client-side control.

  • Ask the customers to use the AWS SDK API Gateway class to invoke the InvalidateCache API operation.
    ❌ Sai: AWS SDK (boto3, JS SDK) cho API Gateway chỉ hỗ trợ control plane operations như create/deploy API (cho owner). Không có InvalidateCache method trong SDK class dành cho khách hàng invalidate cache. Việc này yêu cầu quyền admin cao, không phù hợp end-user.

  • Attach an InvalidateCache policy to the IAM execution role that the customers use to invoke the API. Ask the customers to add the INVALIDATE_CACHE query string parameter when they make an API call.
    ❌ Sai: Mặc dù policy đúng, nhưng không có query parameter INVALIDATE_CACHE. AWS chỉ hỗ trợ HTTP header Cache-Control: max-age=0 để trigger invalidation. Query param không được docs công nhận, sẽ bị ignore hoặc lỗi.

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

🧠 Lời khuyên DevOps: Trong production, kết hợp CloudWatch Logs + X-Ray để monitor cache hit/miss sau invalidation. Test ngay với curl: curl -H "Cache-Control: max-age=0" -H "Authorization: AWS4-HMAC-SHA256..." https://api.execute-api.region.amazonaws.com/stage/path.