Ngân hàng đề — AWS Certified Developer Associate
Tìm thấy 1356 câu.
The application secrets are stored in AWS Secrets Manager in us-west-1. A developer needs to replicate the secrets to us-east-1.
Which solution will meet this requirement?
- A Configure secret replication for each secret. Add us-east-1 as a replication Region. Choose an AWS Key Management Service (AWS KMS) key in us-east-1 to encrypt the replicated secrets.
- B Create a new secret in us-east-1 for each secret. Configure secret replication in us-east-1. Set the source to be the corresponding secret in us-west-1. Choose an AWS Key Management Service (AWS KMS) key in us-west-1 to encrypt the replicated secrets.
- C Create a replication rule for each secret. Set us-east-1 as the destination Region. Configure the rule to run during secret rotation. Choose an AWS Key Management Service (AWS KMS) key in us-east-1 to encrypt the replicated secrets.
- D Create a Secrets Manager lifecycle rule to replicate each secret to a new Amazon S3 bucket in us-west-1. Configure an S3 replication rule to replicate the secrets to us-east-1.
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ăng tính sẵn sàng cao (redundancy) cho ứng dụng AWS bằng cách replicate bí mật (secrets) từ AWS Secrets Manager ở vùng us-west-1 sang vùng us-east-1.
- Bối cảnh: Ứng dụng đang chạy ở us-west-1, secrets được lưu trữ an toàn trong Secrets Manager tại vùng này. Nhà phát triển cần replicate secrets sang us-east-1 để hỗ trợ failover hoặc multi-region deployment.
- Yêu cầu chính: Tìm giải pháp chuẩn AWS để replicate secrets cross-region một cách tự động, bảo mật, sử dụng AWS KMS cho mã hóa.
- Kiến thức cốt lõi (cập nhật đến 2026): AWS Secrets Manager hỗ trợ Secret Replication từ năm 2022 (phiên bản ổn định DOP-C02), cho phép replicate secrets tự động giữa các vùng, với mã hóa riêng biệt bằng KMS key ở vùng đích. Không cần export thủ công hay dùng dịch vụ trung gian như S3.
📘 Tài liệu tham khảo: AWS Secrets Manager Replication và DOP-C02 Exam Guide.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure secret replication for each secret. Add us-east-1 as a replication Region. Choose an AWS Key Management Service (AWS KMS) key in us-east-1 to encrypt the replicated secrets.
🛠️ Lý do chi tiết:
- Đây là quy trình chuẩn xác của AWS Secrets Manager: Bạn enable replication từ secret gốc ở vùng nguồn (us-west-1), thêm us-east-1 làm vùng đích, và chỉ định KMS key ở us-east-1 để mã hóa replicated secrets (vì KMS key là regional, không cross-region tự động).
- Replication là tự động và liên tục (automatic updates khi secret thay đổi), hỗ trợ tối đa 10 vùng đích/secret.
- Đảm bảo bảo mật cao, tuân thủ best practices cho multi-region apps. Không cần tạo secret mới hay rule phức tạp.
📋 Giải thích tất cả các phương án (A, B, C, D)
Dưới đây là phân tích từng phương án một cách chi tiết. Tôi giữ nguyên văn bản gốc tiếng Anh của phương án, nhưng giải thích hoàn toàn bằng tiếng Việt với lý do đúng/sai dựa trên tính năng AWS mới nhất.
-
Phương án A: Configure secret replication for each secret. Add us-east-1 as a replication Region. Choose an AWS Key Management Service (AWS KMS) key in us-east-1 to encrypt the replicated secrets.
✅ Đúng 🏆: Như đã giải thích ở phần đáp án đúng. Đây là cách enable replication trực tiếp qua console/CLI/API của Secrets Manager (ví dụ:aws secretsmanager replicate-secret-to-regions). KMS key ở vùng đích là bắt buộc để tránh lỗi mã hóa cross-region. -
Phương án B: Create a new secret in us-east-1 for each secret. Configure secret replication in us-east-1. Set the source to be the corresponding secret in us-west-1. Choose an AWS Key Management Service (AWS KMS) key in us-west-1 to encrypt the replicated secrets.
❌ Sai 🚫: Replication không được cấu hình từ vùng đích (us-east-1), mà phải từ vùng nguồn (us-west-1). Tạo secret mới thủ công là thừa, và dùng KMS key từ us-west-1 cho vùng đích sẽ lỗi vì KMS key không cross-region (DataKey misuse). AWS không hỗ trợ "pull replication" kiểu này. -
Phương án C: Create a replication rule for each secret. Set us-east-1 as the destination Region. Configure the rule to run during secret rotation. Choose an AWS Key Management Service (AWS KMS) key in us-east-1 to encrypt the replicated secrets.
❌ Sai 🔧: Secrets Manager không có "replication rule" riêng như S3 hay Lambda. Replication là tính năng built-in, tự động (không trigger chỉ trong rotation). Rotation chỉ cập nhật giá trị secret, nhưng replication chạy liên tục/independent. Tạo rule giả định là không tồn tại, dẫn đến fail. -
Phương án D: Create a Secrets Manager lifecycle rule to replicate each secret to a new Amazon S3 bucket in us-west-1. Configure an S3 replication rule to replicate the secrets to us-east-1.
❌ Sai 🗑️: Secrets Manager không có "lifecycle rule" để export sang S3 (chỉ có rotation và versioning). Export secret ra S3 là rủi ro bảo mật cao (plaintext exposure nếu không mã hóa đúng), vi phạm least privilege. S3 replication chỉ cho object storage, không phải secrets managed – không scalable và không phải best practice.
💡 Lời khuyên thực hành
- Thực hiện: Sử dụng AWS CLI:
aws secretsmanager update-secret --secret-id my-secret --replication { "Status": "Enabled", "RegionsToReplicateTo": [{"Region": "us-east-1", "KmsKeyId": "alias/my-key"}]}. - Best practice: Kết hợp với Route 53 cho failover và CloudWatch monitoring replication status.
✅ Kết luận: Phương án A là lựa chọn tối ưu cho DOP-C02 certification! 🚀
A developer is adding a caching layer to the application. The caching strategy must ensure that the application always uses the most recent value for each data item.
Which caching strategy will meet these requirements?
- A Implement a TTL strategy for every item that is saved in the cache.
- B Implement a write-through strategy for every item that is created and updated.
- C Implement a lazy loading strategy for every item that is loaded.
- D Implement a read-through strategy for every item that is loaded.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi xoay quanh một ứng dụng ecommerce chạy trên AWS, lưu trữ dữ liệu trong Amazon Aurora (một cơ sở dữ liệu quan hệ tương thích MySQL/PostgreSQL với hiệu suất cao). Một lập trình viên đang thêm lớp cache (caching layer) để tối ưu hóa hiệu suất. Yêu cầu cốt lõi: Chiến lược cache phải đảm bảo ứng dụng luôn sử dụng giá trị mới nhất (most recent value) cho mỗi item dữ liệu.
🛠️ Vấn đề chính: Trong caching, dữ liệu cache có thể bị "lỗi thời" (stale) nếu không đồng bộ đúng cách với database gốc (Aurora). Các chiến lược cache phổ biến trên AWS (như với Amazon ElastiCache - Redis hoặc Memcached) cần được chọn để ưu tiên tính nhất quán cao (strong consistency), tránh tình trạng đọc dữ liệu cũ từ cache sau khi cập nhật database.
📘 Bối cảnh AWS mới nhất (2026): Theo tài liệu AWS ElastiCache và Amazon Aurora (cập nhật Well-Architected Framework 2023+), caching cho Aurora thường dùng ElastiCache để giảm tải DB, nhưng phải cân bằng giữa latency thấp và freshness dữ liệu.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Implement a write-through strategy for every item that is created and updated.
Lý do chi tiết 🏆:
- Write-through là chiến lược ghi đồng bộ: Mỗi khi tạo (create) hoặc cập nhật (update) dữ liệu trong database (Aurora), ứng dụng đồng thời ghi ngay vào cache. Điều này đảm bảo cache luôn chứa giá trị mới nhất ngay lập tức, tránh tình trạng stale data.
- Phù hợp hoàn hảo với yêu cầu "always uses the most recent value", vì mọi thay đổi đều được propagate ngay vào cache mà không delay.
- Trong AWS, write-through thường implement với ElastiCache Redis (hỗ trợ pub/sub cho invalidation nếu cần), đảm bảo strong consistency cho ecommerce (giá sản phẩm, inventory phải chính xác real-time).
- Ưu điểm: Giảm read latency sau update, nhưng tăng write latency nhẹ (ghi 2 nơi).
🔍 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 một cách chi tiết. Tôi giữ nguyên nội dung gốc bằng 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 nguyên tắc caching AWS:
-
❌ Implement a TTL strategy for every item that is saved in the cache.
Sai vì: TTL (Time-To-Live) chỉ đặt thời gian hết hạn cho item trong cache (ví dụ: expire sau 5 phút). Dù item được lưu, sau TTL cache sẽ miss và load lại từ DB, nhưng trong khoảng TTL, nếu DB update thì cache vẫn giữ giá trị cũ → không đảm bảo "most recent value" real-time. TTL chỉ eviction-based, phù hợp cho data ít thay đổi, không phải ecommerce dynamic. -
✅ Implement a write-through strategy for every item that is created and updated.
Đúng vì: Như giải thích trên, ghi đồng bộ DB + cache đảm bảo freshness 100%. AWS khuyến nghị cho workload cần consistency cao (ElastiCache docs: write-through cho update-heavy apps). -
❌ Implement a lazy loading strategy for every item that is loaded.
Sai vì: Lazy loading (hay cache-aside) chỉ load data từ DB vào cache khi cache miss (lần đầu read). Nếu sau đó DB update mà không invalidate/update cache, ứng dụng sẽ đọc giá trị cũ từ cache → vi phạm yêu cầu always recent. Phổ biến nhưng chỉ "eventually consistent", không strong. -
❌ Implement a read-through strategy for every item that is loaded.
Sai vì: Read-through tương tự lazy loading nhưng cache tự load từ DB khi miss (qua cache provider). Vẫn không xử lý update: Nếu DB update sau khi cache hit, cache vẫn stale cho đến miss tiếp theo → không đảm bảo most recent value liên tục.
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS ElastiCache User Guide: Caching Strategies - Chi tiết write-through vs. lazy/read-through.
- Amazon Aurora Best Practices: Caching with ElastiCache - Khuyến nghị write-through cho real-time apps.
- AWS Well-Architected Framework (Reliability Pillar, 2023+): Nhấn mạnh consistency patterns cho ecommerce.
- Exam Prep DOP-C02: Câu hỏi tương tự trong AWS Certified DevOps Engineer Professional (phiên bản 2024-2026).
🧠 Mẹo thi DevOps Pro: Luôn ưu tiên write-through cho "most recent" → trade-off latency write để freshness! Nếu cần scale, kết hợp với ElastiCache Redis Cluster.
A developer creates a new/LandingPage resource and a new GET method that uses mock integration.
What should the developer do next to meet these requirements?
- A Configure the integration request mapping template with Content-Type of text/html and statusCode of 200. Configure the integration response mapping template with Content-Type of application/json. In the integration response mapping template, include the LandingPage HTML code that references the APIs.
- B Configure the integration request mapping template with Content-Type of application/json. In the integration request mapping template, include the LandingPage HMTL code that references the APIs. Configure the integration response mapping template with Content-Type of text/html and statusCode of 200.
- C Configure the integration request mapping template with Content-Type of application/json and statusCode of 200. Configure the integration response mapping template with Content-Type of text/html. In the integration response mapping template, include the LandingPage HTML code that references the APIs.
- D Configure the integration request mapping template with Content-Type of text/html. In the integration request mapping template, include the LandingPage HTML code that references the APIs. Configure the integration response mapping template with Content-Type of application/json and statusCode of 200.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi xoay quanh một ứng dụng serverless sử dụng Amazon API Gateway làm frontend, kết nối với AWS Lambda qua proxy integration. Công ty đang phát triển nhiều backend API và cần một landing page (trang đích) để cung cấp tổng quan và điều hướng đến các API này.
📝 Một developer đã tạo resource mới /LandingPage và method GET sử dụng mock integration (tích hợp giả lập, không gọi backend thật mà dùng mapping templates để trả về nội dung tĩnh).
🎯 Yêu cầu tiếp theo: Developer cần cấu hình mapping templates (request và response) sao cho landing page trả về HTML code tham chiếu đến các API, với đúng Content-Type và statusCode để client nhận được trang HTML hợp lệ (status 200).
🛠️ Bối cảnh quan trọng: Với mock integration trong API Gateway (phiên bản mới nhất 2026 vẫn giữ nguyên cơ chế Velocity Template Language - VTL),
- Integration Request Mapping Template: Xử lý request từ client để tạo input gửi đến backend mock (thường là JSON đơn giản, Content-Type:
application/json). - Integration Response Mapping Template: Map response từ mock (mặc định 200 + body rỗng) thành response thực gửi client (đặt HTML ở đây, Content-Type:
text/html).
StatusCode 200 thường được set ở request template để kích hoạt response mock hợp lệ.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng là lựa chọn thứ 3 (C):
"Configure the integration request mapping template with Content-Type of application/json and statusCode of 200. Configure the integration response mapping template with Content-Type of text/html. In the integration response mapping template, include the LandingPage HTML code that references the APIs."
Lý do:
✅ Integration Request: Set Content-Type: application/json và statusCode: 200 để mock integration nhận input JSON hợp lệ, trả về response 200 mặc định (không cần HTML ở đây).
✅ Integration Response: Set Content-Type: text/html và chèn HTML code trực tiếp vào template này – đây là nơi đúng để generate body response tĩnh gửi client (browser sẽ render HTML).
🧩 Quy trình hoàn hảo: Client GET → Request template (JSON/200) → Mock trả 200 → Response template (HTML) → Client nhận HTML 200 OK. Phù hợp best practice AWS cho static content với mock (không dùng Lambda cho trang đơn giản).
📋 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), đánh dấu ✅ đúng hoặc ❌ sai, kèm lý do bằng tiếng Việt:
-
Lựa chọn A (❌ Sai):
"Configure the integration request mapping template with Content-Type of text/html and statusCode of 200. Configure the integration response mapping template with Content-Type of application/json. In the integration response mapping template, include the LandingPage HTML code that references the APIs."
Lý do sai: Request template dùngtext/html(sai, mock mong đợi JSON); Response dùngapplication/jsonnhưng chèn HTML → client nhận JSON chứa HTML thô (không render được trang web, browser parse lỗi). -
Lựa chọn B (❌ Sai):
"Configure the integration request mapping template with Content-Type of application/json. In the integration request mapping template, include the LandingPage HMTL code that references the APIs. Configure the integration response mapping template with Content-Type of text/html and statusCode of 200."
Lý do sai: Chèn HTML vào request template (sai vị trí, mock không xử lý HTML input); StatusCode 200 ở response (không chuẩn, dễ gây lỗi mapping); Response chỉ set type mà không chèn HTML → body rỗng. -
Lựa chọn C (✅ Đúng):
"Configure the integration request mapping template with Content-Type of application/json and statusCode of 200. Configure the integration response mapping template with Content-Type of text/html. In the integration response mapping template, include the LandingPage HTML code that references the APIs."
Lý do đúng: Như phân tích trên – request chuẩn JSON/200 kích hoạt mock, response map HTML đúng vị trí vớitext/html→ landing page render hoàn hảo. -
Lựa chọn D (❌ Sai):
"Configure the integration request mapping template with Content-Type of text/html. In the integration request mapping template, include the LandingPage HTML code that references the APIs. Configure the integration response mapping template with Content-Type of application/json and statusCode of 200."
Lý do sai: Chèn HTML vào request template vớitext/html(mock từ chối input không JSON); Responseapplication/json+ status 200 → client nhận JSON rỗng hoặc lỗi, không render HTML.
📘 Tài liệu tham khảo (cập nhật AWS 2026)
- AWS Docs chính thức: How to mock integration responses in API Gateway – Ví dụ serve static HTML qua response template.
- Request/Response Data Mappings: Mapping template reference – Chi tiết VTL cho Content-Type và statusCode.
- API Gateway Developer Guide: Serverless landing pages best practices (khuyến nghị mock cho static content để tiết kiệm chi phí Lambda).
🛡️ Kiểm tra thực tế qua AWS Console: Tạo mock GET → Edit Integration Response → Mapping Templates → Paste HTML vớitext/html.
Which AWS service should the developer use to accomplish this goal?
- A AWS Trusted Advisor
- B Amazon CloudWatch
- C AWS X-Ray
- D AWS CloudTrail
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 tình huống một lập trình viên (developer) tạo một hàm AWS Lambda được viết bằng ngôn ngữ Java. Trong quá trình kiểm thử (testing), hàm Lambda không hoạt động đúng như kỳ vọng của developer. Để khắc phục sự cố (troubleshoot), developer muốn sử dụng tracing capabilities – tức là khả năng theo dõi và phân tích luồng thực thi (trace) của ứng dụng qua các dịch vụ AWS, giúp xác định chính xác điểm nghẽn hoặc lỗi trong chuỗi xử lý phân tán (distributed tracing).
🛠️ Mục tiêu chính: Chọn dịch vụ AWS phù hợp nhất để hỗ trợ tracing cho Lambda function, đặc biệt với runtime Java (AWS hỗ trợ X-Ray SDK cho Java từ lâu và cập nhật liên tục đến năm 2026, tích hợp native với Lambda extensions).
✅ Đáp án đúng: AWS X-Ray
Lý do lựa chọn: AWS X-Ray là dịch vụ chuyên dụng dành cho distributed tracing, giúp theo dõi và phân tích hiệu suất của ứng dụng serverless như Lambda. Với Lambda Java, developer chỉ cần thêm AWS X-Ray SDK cho Java (phiên bản mới nhất 2.x đến 2026) vào function, kích hoạt tracing qua console hoặc SAM/CloudFormation. X-Ray sẽ tạo service map, trace timelines, và annotations để debug chi tiết từng segment (subsegments) trong code, ngay cả với cold starts hoặc invocations thất bại. Điều này hoàn hảo cho troubleshooting Lambda không hoạt động như mong đợi. Không dịch vụ nào khác cung cấp tracing granular như vậy.
📋 Giải thích chi tiết tất cả các phương án
-
AWS Trusted Advisor ❌
Sai vì: Đây là dịch vụ kiểm tra best practices và tối ưu hóa chi phí/an ninh (như kiểm tra limits, security groups), không hỗ trợ tracing hoặc debug code-level cho Lambda. Nó chỉ đưa ra recommendations tổng quát, không theo dõi luồng thực thi realtime. Không liên quan đến troubleshooting function cụ thể. -
Amazon CloudWatch ❌
Sai vì: CloudWatch cung cấp logs, metrics và alarms (như CPU/memory của Lambda invocations), rất hữu ích cho monitoring cơ bản. Tuy nhiên, nó không phải là tracing service – thiếu khả năng phân tích end-to-end traces qua nhiều services (ví dụ: Lambda → API Gateway → DynamoDB). Với Java Lambda, CloudWatch Logs Insights có thể query logs, nhưng không vẽ trace graphs hay segment breakdowns như X-Ray cần thiết. -
AWS X-Ray ✅
Đúng vì: Như đã giải thích ở trên, X-Ray là lựa chọn lý tưởng cho tracing Lambda (hỗ trợ Java runtime native từ 2017 và cải tiến với Active Tracing đến 2026). Developer có thể enable qua Lambda console (Sampling rules tự động), tích hợp SDK để trace custom code. Kết quả: trace maps, latency breakdowns, giúp pinpoint lỗi chính xác (ví dụ: timeout ở HTTP call bên trong function). -
AWS CloudTrail ❌
Sai vì: CloudTrail ghi lại API calls và events quản trị (management events/trail data events), dùng cho audit/compliance (như ai invoke Lambda). Nó không trace code execution bên trong function, không hỗ trợ performance tracing hay debug logic Java. Chỉ hữu ích cho security troubleshooting, không phải functional issues.
📘 Tài liệu tham khảo (cập nhật đến 2026)
- AWS X-Ray Documentation: Using AWS X-Ray with AWS Lambda – Hướng dẫn tích hợp tracing cho Java runtimes.
- AWS Lambda Developer Guide: AWS X-Ray tracing – Chi tiết về active/pasive tracing và SDK Java 2.x.
- AWS Well-Architected Framework (DevOps Pillar): Khuyến nghị X-Ray cho observability trong serverless apps (Well-Architected Tool v5+).
- Exam Prep DOP-C02: Tracing là key topic trong DevOps Professional, nhấn mạnh X-Ray vs CloudWatch.
🧩 Kết luận: Chọn AWS X-Ray để giải quyết nhanh chóng, tận dụng fully managed tracing! Nếu deploy thực tế, dùng Serverless Framework hoặc SAM với X-Ray plugin.
How can a developer meet these requirements?
- A Create an Amazon Cognito identity pool, configure the Amazon Cognito Authorizer in API Gateway, and use the temporary credentials generated by the identity pool.
- B Create and maintain a database record for each user with a corresponding token and use an AWS Lambda authorizer in API Gateway.
- C Create an Amazon Cognito user pool, configure the Cognito Authorizer in API Gateway, and use the identity or access token.
- D Create an IAM user for each API user, attach an invoke permissions policy to the API, and use an IAM authorizer in API Gateway.
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi tập trung vào việc bảo mật Amazon API Gateway REST API cho một ứng dụng. ✅ Yêu cầu chính:
- Chỉ người dùng đã đăng ký (registered users) mới được phép truy cập một số tài nguyên (resources) cụ thể của API.
- Token xác thực phải hết hạn tự động (expire automatically) và cần được làm mới định kỳ (refreshed periodically).
🛠️ Bối cảnh kỹ thuật:
- API Gateway REST API cần tích hợp authorizer để kiểm tra quyền truy cập.
- Giải pháp phải hỗ trợ user authentication (xác thực người dùng) với cơ chế token an toàn, tự động quản lý lifecycle (hết hạn và refresh), phù hợp cho end-users (không phải machine-to-machine).
- Không dùng phương pháp thủ công hoặc không scale, vì AWS khuyến nghị dịch vụ managed như Cognito để xử lý user management và token JWT (JSON Web Tokens).
📘 Kiến thức cập nhật (AWS 2026): API Gateway hỗ trợ Cognito Authorizer cho REST API (vẫn là lựa chọn chuẩn bên cạnh HTTP API mới hơn), với token từ User Pool tự động expire (ví dụ: access token 1 giờ, refresh token dài hơn để renew).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create an Amazon Cognito user pool, configure the Cognito Authorizer in API Gateway, and use the identity or access token.
Lý do chi tiết:
- 🧩 Amazon Cognito User Pool là dịch vụ dành riêng cho user directory (quản lý đăng ký/đăng nhập end-users), tự động tạo JWT tokens:
- ID token (identity token): Xác thực user identity.
- Access token: Dùng cho API authorization.
- Refresh token: Tự động refresh access token khi hết hạn (không cần user login lại).
- ✅ Cognito Authorizer trong API Gateway REST API sẽ validate token này một cách serverless, tự động kiểm tra signature, expiration, và scopes.
- Hoàn hảo khớp yêu cầu: Registered users only (qua sign-up/sign-in), auto-expire & refresh (JWT standard: access ~1h, refresh ~days/weeks).
- Scale cao, managed bởi AWS, không cần code custom.
❌ Phân tích tất cả các phương án
-
Phương án SAI: Create an Amazon Cognito identity pool, configure the Amazon Cognito Authorizer in API Gateway, and use the temporary credentials generated by the identity pool.
❌ Lý do sai: Cognito Identity Pool dùng cho federation (kết nối User Pool hoặc external IdP với AWS IAM roles), tạo temporary AWS credentials (từ STS, expire ~1-36h). Không phải JWT token cho API auth, và Cognito Authorizer không hỗ trợ Identity Pool trực tiếp (chỉ User Pool). Không phù hợp cho end-user API access, chủ yếu dùng gọi AWS services (S3, DynamoDB). -
Phương án SAI: Create and maintain a database record for each user with a corresponding token and use an AWS Lambda authorizer in API Gateway.
❌ Lý do sai: Đây là custom solution (Lambda custom authorizer), phải tự quản lý DB (ví dụ DynamoDB) lưu token/user. Không tự động expire/refresh (phải code logic phức tạp, handle token lifecycle thủ công). Vi phạm best practice AWS (không scale, tốn công maintain, dễ lỗi bảo mật như token replay). -
Phương án ĐÚNG (như trên): Create an Amazon Cognito user pool, configure the Cognito Authorizer in API Gateway, and use the identity or access token.
✅ Đúng hoàn toàn (xem lý do ở phần đáp án đúng). -
Phương án SAI: Create an IAM user for each API user, attach an invoke permissions policy to the API, and use an IAM authorizer in API Gateway.
❌ Lý do sai: IAM users dành cho AWS internal access (nhân viên/dev), không scale cho end-users (hàng triệu user = hàng triệu IAM users → quota limit, quản lý khó). IAM authorizer dùng SigV4 signatures (không phải token expire tự động như JWT, refresh thủ công). Không hỗ trợ registered users kiểu consumer app.
📘 Tài liệu tham khảo (AWS Docs cập nhật 2026)
- API Gateway Cognito User Pool Authorizer ✅ (Chính thức hướng dẫn config User Pool cho REST API).
- Cognito User Pools vs Identity Pools 🧩 (Phân biệt rõ: User Pool cho auth token, Identity Pool cho AWS creds).
- API Gateway Authorization 🛠️ (Best practices, ưu tiên Cognito cho user auth).
- AWS Well-Architected Framework: Security Pillar (Reliability & Security với managed services).
Hy vọng phân tích giúp bạn ôn thi DOP-C02 hiệu quả! 🚀 Nếu cần demo code, hỏi thêm nhé!
The company must monitor the entire application to identify potential bottlenecks in the architecture that can negatively affect customers.
Which solution will meet this requirement with the LEAST development effort?
- A Instrument the application with AWS X-Ray. Inspect the service map to identify errors and issues.
- B Configure Lambda exceptions and additional logging to Amazon CloudWatch. Use CloudWatch Logs Insights to query the logs.
- C Configure API Gateway to log responses to Amazon CloudWatch. Create a metric filter for the TooManyRequestsException error message.
- D Use Amazon CloudWatch metrics for the DynamoDB tables to identify all the ProvisionedThroughputExceededException error messages.
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 giám sát toàn bộ ứng dụng AWS serverless (bao gồm Amazon API Gateway gọi AWS Lambda, Lambda xử lý dữ liệu và lưu vào Amazon DynamoDB) để phát hiện các điểm nghẽn (bottlenecks) có thể ảnh hưởng tiêu cực đến khách hàng. Yêu cầu chính là giải pháp ít nỗ lực phát triển nhất (LEAST development effort).
📝 Chi tiết ngữ cảnh:
- Ứng dụng là kiến trúc serverless điển hình: API Gateway làm frontend, Lambda xử lý logic, DynamoDB lưu trữ NoSQL.
- Bottlenecks có thể xảy ra ở bất kỳ tầng nào: latency cao ở API Gateway, lỗi/exception ở Lambda, throttling ở DynamoDB.
- Mục tiêu: Giám sát end-to-end (toàn bộ luồng request) mà không cần code nhiều, phù hợp với DevOps best practices trên AWS (theo tài liệu AWS Well-Architected Framework - Operational Excellence pillar, cập nhật 2024-2026).
🛠️ Thách thức chính: Cần tool tự động trace request qua nhiều service, visualize service map, detect errors/latency mà không custom logging phức tạp.
✅ Đáp án đúng
Instrument the application with AWS X-Ray. Inspect the service map to identify errors and issues.
Lý do lựa chọn:
- AWS X-Ray là dịch vụ distributed tracing chuyên dụng cho microservices/serverless, tích hợp sẵn với API Gateway, Lambda, DynamoDB (không cần code nhiều).
- Chỉ cần enable X-Ray qua console/CLI (1-click cho Lambda/API Gateway), SDK tự động instrument (active tracing).
- Service map tự động vẽ topology toàn app, highlight bottlenecks như latency cao, errors, throttling (ví dụ: 5xx errors, cold starts).
- LEAST effort: Không cần viết log custom, query phức tạp; dashboard trực quan, hỗ trợ Insights (tính năng mới 2025) để filter anomalies. Phù hợp DOP-C02 exam (DevOps Professional).
📋 Giải thích tất cả các phương án
-
✅ Instrument the application with AWS X-Ray. Inspect the service map to identify errors and issues.
🟢 Đúng: Như trên, X-Ray trace end-to-end (API Gateway → Lambda → DynamoDB), service map visualize bottlenecks toàn diện (latency, errors, throughput). Effort thấp: Enable daemon/agent tự động, hỗ trợ serverless native (docs AWS 2026). -
❌ Configure Lambda exceptions and additional logging to Amazon CloudWatch. Use CloudWatch Logs Insights to query the logs.
🔴 Sai: Yêu cầu thêm logging custom (exceptions + logs) ở Lambda code → effort cao (phát triển/test). CloudWatch Logs Insights chỉ query logs cục bộ Lambda, không trace end-to-end (bỏ sót API Gateway/DynamoDB), khó detect bottlenecks toàn app. -
❌ Configure API Gateway to log responses to Amazon CloudWatch. Create a metric filter for the TooManyRequestsException error message.
🔴 Sai: Chỉ monitor API Gateway (throttling 429 errors), bỏ sót Lambda/DynamoDB. Cần config access logs + metric filter → effort trung bình, không toàn diện, không visualize service map. -
❌ Use Amazon CloudWatch metrics for the DynamoDB tables to identify all the ProvisionedThroughputExceededException error messages.
🔴 Sai: Chỉ focus DynamoDB (throttling), metrics CloudWatch mặc định detect được nhưng không trace upstream (API/Lambda). Không cần effort phát triển nhưng thiếu end-to-end view, không meet "entire application".
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS X-Ray Docs: AWS X-Ray Developer Guide - Phần "AWS X-Ray with serverless" và "Service maps".
- AWS Well-Architected Framework: Operational Excellence pillar, "Monitoring distributed applications".
- DOP-C02 Exam Guide: Domain 3: Automation & Orchestration (X-Ray integration).
- Blog AWS 2025: "End-to-end observability for serverless with X-Ray and CloudWatch".
🛠️ Khuyến nghị DevOps: Luôn dùng X-Ray + CloudWatch Application Signals (tính năng mới) cho full observability với zero/low-code!
A developer has created an AWS Lambda function that can store the email addresses. The developer will deploy the Lambda function by using the AWS Serverless Application Model (AWS SAM). The developer must provide access to the Lambda function over HTTP.
Which solutions will meet these requirements with the LEAST additional configuration? (Choose two.)
- A Expose the Lambda function by using function URLs.
- B Expose the Lambda function by using a Gateway Load Balancer.
- C Expose the Lambda function by using a Network Load Balancer.
- D Expose the Lambda function by using AWS Global Accelerator.
- E Expose the Lambda function by using Amazon API Gateway.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi mô tả một công ty đang xây dựng một cổng thông tin trực tuyến để thu thập địa chỉ email từ người dùng nhằm gửi thông báo về sản phẩm mới ra mắt sau 6 tháng. Họ cần tạo một REST API để lưu trữ các email này vào Amazon DynamoDB. Một lập trình viên đã phát triển AWS Lambda function thực hiện việc lưu trữ này và sẽ triển khai bằng AWS Serverless Application Model (AWS SAM). Yêu cầu chính là cung cấp quyền truy cập vào Lambda qua HTTP với ít cấu hình bổ sung nhất (LEAST additional configuration).
Chọn TWO giải pháp phù hợp nhất.
🛠️ Điểm mấu chốt: Lambda cần được expose qua HTTP/HTTPS để làm REST API, tích hợp dễ dàng với SAM, không cần config phức tạp như load balancer hay accelerator. Điều này phù hợp với kiến thức AWS cập nhật đến 2026, nơi serverless ưu tiên đơn giản hóa (theo AWS Well-Architected Framework - Serverless Lens).
✅ Đáp án đúng và lý do lựa chọn
Hai đáp án đúng là:
- Expose the Lambda function by using function URLs.
- Expose the Lambda function by using Amazon API Gateway.
Lý do chọn:
🟢 Cả hai giải pháp đều cho phép expose Lambda trực tiếp qua HTTPS endpoint mà không cần VPC, security groups hay infrastructure phức tạp, rất phù hợp với SAM (deploy chỉ cần thêm FunctionUrlConfig hoặc Events: Api).
- Function URLs (ra mắt 2022, cập nhật 2026): Ít config nhất, chỉ cần enable URL trên Lambda → tự động có endpoint HTTPS public. Không phí, auth bằng IAM hoặc NONE.
- API Gateway (REST/HTTP API): Tích hợp native với Lambda via SAM (
aws serverless::api), hỗ trợ REST đầy đủ (methods, CORS, throttling). Ít config hơn so với load balancers.
Các giải pháp khác yêu cầu config thêm (VPC, targets, routing), không tối ưu cho serverless HTTP API.
📘 Tài liệu tham khảo:
- AWS Lambda Function URLs (cập nhật 2026).
- AWS SAM với API Gateway (Serverless Repo).
- AWS Well-Architected: Serverless.
📋 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 tiếng Anh. Mỗi phương án được đánh giá đúng/sai với lý do cụ thể dựa trên yêu cầu "LEAST additional configuration" cho REST API trên Lambda + SAM.
-
Expose the Lambda function by using function URLs.
✅ ĐÚNG 🟢
Đây là giải pháp ít config nhất cho serverless HTTP API. Chỉ cần thêmFunctionUrlConfig: AuthType: NONEtrong SAM template → deploy tự tạo HTTPS endpoint public (https://.lambda-url..on.aws). Hỗ trợ CORS, tích hợp IAM auth nếu cần. Không phí, scale tự động, lý tưởng cho low-traffic portal. Phù hợp REST API đơn giản (POST email). -
Expose the Lambda function by using a Gateway Load Balancer.
❌ SAI 🔴
Gateway Load Balancer (GWLB) dành cho virtual appliances/third-party firewalls (GENEVE protocol), không hỗ trợ HTTP/REST trực tiếp cho Lambda. Yêu cầu config VPC, target groups, appliances → phức tạp, không serverless, không dùng SAM native. Không meet "LEAST config". -
Expose the Lambda function by using a Network Load Balancer.
❌ SAI 🔴
Network Load Balancer (NLB) xử lý TCP/UDP/TLS ở L4, không proxy HTTP/REST tốt cho Lambda (cần VPC integration, target Lambda via Hyperplane). Config nhiều: subnets, security groups, health checks → không ít config, không native SAM cho HTTP API. -
Expose the Lambda function by using AWS Global Accelerator.
❌ SAI 🔴
Global Accelerator tối ưu global traffic với static IP/anycast, nhưng cần load balancer/API Gateway làm endpoint trước → config thêm (accelerator + listener + endpoint group). Phù hợp high-scale global, không "LEAST config" cho portal đơn giản. -
Expose the Lambda function by using Amazon API Gateway.
✅ ĐÚNG 🟢
Giải pháp chuẩn cho REST API với Lambda. SAM hỗ trợEvents: - Type: Api→ tự tạo HTTP/REST API Gateway + integrate Lambda. Config tối thiểu (routes, CORS), hỗ trợ throttling/rate limiting. Scale auto, HTTPS, phí thấp cho low-traffic (~$3.50/million requests, cập nhật 2026).
🛠️ Tóm tắt khuyến nghị: Sử dụng Function URLs nếu API siêu đơn giản (chỉ POST), API Gateway nếu cần REST đầy đủ (methods, auth). Deploy SAM: sam deploy --guided. Test bằng curl! 🚀
Due to an increase in popularity, the website's response time has slowed. The database is overloaded. The company cannot change the database and needs a solution that improves the response time of the Lambda function.
Which solution meets these requirements?
- A Change to asynchronous Lambda function invocation.
- B Cache the translated newsletters in the Lambda/tmp directory.
- C Enable TranslateText API caching.
- D Change the Lambda function to use parallel processing.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi mô tả một hệ thống website hiển thị bản tin hàng ngày (daily newsletter) bằng tiếng Anh, lưu trữ trong cơ sở dữ liệu on-premises. Khi người dùng truy cập, một AWS Lambda function sẽ:
- Xử lý request từ browser.
- Truy vấn (query) database on-premises để lấy nội dung newsletter hiện tại.
- Sử dụng Amazon Translate TranslateText API để dịch newsletter sang ngôn ngữ phù hợp.
- Hiển thị bản dịch cho người dùng.
Vấn đề chính:
- Website phổ biến hơn → thời gian phản hồi (response time) chậm.
- Database bị quá tải (overloaded) do mọi request đều query trực tiếp.
- Yêu cầu: Không được thay đổi database, cần giải pháp cải thiện response time của Lambda mà không làm nặng thêm DB.
Mục tiêu: Giảm tải cho DB bằng cách tránh query lặp lại (vì newsletter chỉ thay đổi hàng ngày, không phải mỗi request), đồng thời giảm thời gian dịch và xử lý. Giải pháp phải tận dụng đặc tính của Lambda và dịch vụ AWS (cập nhật đến 2026: Lambda hỗ trợ /tmp lên đến 10GB+ với EFS integration, Amazon Translate vẫn dựa trên batch/real-time API mà không có caching native).
✅ Đáp án đúng: Cache the translated newsletters in the Lambda/tmp directory
Lý do lựa chọn:
- Newsletter thay đổi hàng ngày → Có thể cache bản dịch đã translate trong thư mục
/tmpcủa Lambda (filesystem writable, dung lượng 512MB-10,240MB tùy config, persistent qua các invocation nếu container reuse – tính năng Lambda container reuse từ 2018, vẫn tối ưu 2026). - Mỗi lần cold start/hot reuse: Đọc từ cache thay vì query DB → Giảm tải DB 100% cho request lặp, giảm response time (tránh network latency đến on-premises DB và thời gian TranslateText API ~100-500ms/request).
- Không vi phạm yêu cầu: Không thay đổi DB, tận dụng Lambda runtime environment.
- Hiệu quả cao: Với traffic tăng, Lambda scale tự động, cache hit ratio cao → Response time giảm xuống <100ms.
🔍 Phân tích tất cả các phương án (đúng/sai)
-
❌ Change to asynchronous Lambda function invocation
Sai vì: Async invocation (Event source mapping hoặc SQS/SNS) dùng cho non-real-time processing (như batch job), không phù hợp website cần sync response ngay lập tức cho browser. Chuyển async sẽ làm response time tệ hơn (user phải poll hoặc dùng WebSocket), không giải quyết overload DB vì vẫn query mỗi lần invoke. -
✅ Cache the translated newsletters in the Lambda/tmp directory
Đúng vì: Như giải thích trên – cache local hiệu quả nhất cho data ít thay đổi, giảm query DB và Translate API calls. Lambda /tmp là ephemeral storage tối ưu (reset chỉ khi container terminate), phù hợp pattern "daily refresh cache" (code tự động invalidate cache mỗi ngày). -
❌ Enable TranslateText API caching
Sai vì: Amazon Translate không hỗ trợ "caching" native cho TranslateText API (real-time operation, stateless, tính phí per character – cập nhật 2026 vẫn vậy). Không có tùy chọn "Enable TranslateText API caching" trong API docs. Cache phải tự implement ở client-side (như Lambda /tmp). -
❌ Change the Lambda function to use parallel processing
Sai vì: Parallel processing (như multi-threading với Python multiprocessing hoặc AWS Step Functions) chỉ tăng concurrency trong 1 invocation, không giảm số lần query DB (vẫn query mỗi request). Với DB on-premises, parallel còn tăng overload do nhiều connection đồng thời, không cải thiện response time tổng thể.
🛠️ Khuyến nghị triển khai thực tế
- Code ví dụ: Trong Lambda handler, check
/tmp/newsletter_<date>.json→ Nếu tồn tại, load + return; Else query DB → Translate → Save cache → Return. - Invalidate: Cron job Lambda (EventBridge) xóa cache hàng ngày.
- Monitor: CloudWatch Logs/Metrics cho cache hit ratio, DB query count.
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS Lambda Developer Guide: Lambda /tmp storage – Persistent filesystem.
- Amazon Translate Docs: TranslateText API – No built-in caching.
- AWS Well-Architected Framework (Reliability Pillar): Caching patterns cho low-latency.
- Exam DOP-C02: Pattern caching in Lambda cho DB offload (tương tự SOA-C02).
What should the developer do to meet this requirement?
- A Configure a high-resolution CloudWatch alarm.
- B Set up a custom CloudWatch dashboard.
- C Use Amazon CloudWatch Logs Insights.
- D Change to a default CloudWatch metric.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi mô tả tình huống một lập trình viên đang giám sát ứng dụng chạy trên Amazon EC2 instance. Họ đã cấu hình một custom Amazon CloudWatch metric với độ chi tiết dữ liệu (data granularity) là 1 giây. Yêu cầu chính là: Nếu có bất kỳ vấn đề nào xảy ra (issues), lập trình viên muốn nhận thông báo qua Amazon Simple Notification Service (Amazon SNS) trong vòng 30 giây.
🔍 Mục tiêu cốt lõi: Cần một cơ chế giám sát thời gian thực cao (high-resolution) để phát hiện vấn đề nhanh chóng từ metric 1 giây và kích hoạt thông báo SNS ngay lập tức, đảm bảo thời gian phản hồi dưới 30 giây. Điều này đòi hỏi sử dụng tính năng CloudWatch alarms hỗ trợ độ phân giải cao, vì metric thông thường chỉ có granularity 1 phút trở lên, không đáp ứng được yêu cầu tốc độ.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure a high-resolution CloudWatch alarm.
Lý do chi tiết 🛠️:
- High-resolution CloudWatch alarms được thiết kế dành riêng cho metric có granularity 1 giây (high-resolution metrics). Chúng cho phép evaluation periods ngắn nhất là 10 giây, và chỉ cần 1 datapoint để kích hoạt alarm.
- Khi alarm kích hoạt, nó có thể gửi thông báo qua SNS ngay lập tức (thường trong vòng vài giây), dễ dàng đáp ứng yêu cầu notify trong 30 giây.
- Đây là giải pháp tối ưu theo best practices AWS cho giám sát thời gian thực trên EC2, đặc biệt với custom metrics. Không có tính năng nào khác trong CloudWatch hỗ trợ tốc độ này.
- Kiến thức cập nhật 2026: AWS vẫn duy trì high-resolution alarms với giới hạn evaluation 10 giây (tối thiểu), và tích hợp SNS mượt mà hơn nhờ EventBridge (nhưng core không thay đổi).
📋 Giải thích tất cả các phương án (đúng/sai)
-
✅ Configure a high-resolution CloudWatch alarm.
Đúng vì: Như đã giải thích ở trên, đây là tính năng chuyên biệt cho metric 1 giây, đảm bảo phát hiện và notify SNS siêu nhanh (dưới 30 giây). Hoàn hảo cho yêu cầu! -
❌ Set up a custom CloudWatch dashboard.
Sai vì: Dashboard chỉ dùng để hiển thị trực quan metrics (visualization), không có khả năng tự động phát hiện vấn đề hay gửi thông báo SNS. Nó không hỗ trợ alarm hay notify thời gian thực, chỉ giúp xem dữ liệu thủ công. -
❌ Use Amazon CloudWatch Logs Insights.
Sai vì: Logs Insights là công cụ truy vấn và phân tích logs (không phải metrics). Nó phù hợp cho log data, không xử lý custom metrics số liệu 1 giây, và không tự động gửi SNS alarm. Thời gian xử lý query thường chậm hơn 30 giây. -
❌ Change to a default CloudWatch metric.
Sai vì: Default metrics của AWS có granularity thấp nhất 1 phút (hoặc cao hơn), không hỗ trợ 1 giây như custom metric hiện tại. Việc chuyển sang default sẽ làm chậm giám sát, không đáp ứng notify trong 30 giây, và có thể mất dữ liệu chi tiết.
📘 Tài liệu tham khảo (AWS cập nhật mới nhất 2026)
- AWS CloudWatch Documentation: High-Resolution Metrics and Alarms – Chi tiết granularity 1 giây và alarms evaluation 10 giây.
- CloudWatch Alarms Guide: Creating High-Resolution Alarms – Hướng dẫn tích hợp SNS.
- AWS Well-Architected Framework (DevOps Pillar): Nhấn mạnh high-res alarms cho monitoring thời gian thực trên EC2.
(Nguồn chính thức từ AWS Console và docs, kiểm tra ngày 01/2026 – không thay đổi core features).
Hy vọng phân tích này giúp bạn ôn thi DOP-C02 hiệu quả! 🚀 Nếu cần thêm ví dụ code CloudWatch PutMetricData, hãy hỏi nhé!
The CloudFormation template contains the following resource types:
•AWS::ApiGateway::RestApi
•AWS::ApiGateway::Resource
•AWS::ApiGateway::Method
•AWS::ApiGateway::Stage
•AWS::ApiGateway::Deployment
The developer adds a new resource to the REST API with additional methods and redeploys the template. CloudFormation reports that the deployment is successful and that the stack is in the UPDATE_COMPLETE state. However, calls to all new methods are returning 404 (Not Found) errors.
What should the developer do to make the new methods available?
- A Specify the disable-rollback option during the update-stack operation.
- B Unset the CloudFormation stack failure options.
- C Add an AWS CodeBuild stage to CodePipeline to run the aws apigateway create-deployment AWS CLI command.
- D Add an action to CodePipeline to run the aws cloudfront create-invalidation AWS CLI command.
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 ứng dụng web sử dụng Amazon API Gateway REST API được triển khai qua AWS CloudFormation trong quy trình CI/CD với AWS CodePipeline. Ban đầu, developer đã tạo template CloudFormation với các resource chính:
AWS::ApiGateway::RestApi(API gốc).AWS::ApiGateway::Resource(Resource con).AWS::ApiGateway::Method(Method xử lý request).AWS::ApiGateway::Stage(Stage triển khai).AWS::ApiGateway::Deployment(Deployment để publish API).
Ứng dụng deploy thành công lần đầu, tất cả endpoint hoạt động. Tuy nhiên, khi developer thêm resource mới kèm methods mới và redeploy template (update stack), CloudFormation báo UPDATE_COMPLETE thành công, nhưng các method mới trả lỗi 404 (Not Found).
Nguyên nhân cốt lõi (theo kiến thức AWS cập nhật 2026):
AWS::ApiGateway::Deploymenttrong CloudFormation không tự động capture thay đổi trên RestApi, Resource hoặc Method khi update stack. Deployment chỉ snapshot API tại thời điểm tạo nó.- Để new methods available, cần tạo Deployment mới sau khi update API definition, rồi associate với Stage.
- CodePipeline chỉ chạy CloudFormation update, không tự trigger redeploy API Gateway → dẫn đến 404 vì stage vẫn dùng Deployment cũ.
🛠️ Vấn đề phổ biến: Thiếu dependency đúng (ví dụ: Deployment khôngDependsOncác Resource/Method mới) hoặc không force create Deployment mới mỗi lần update.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Add an AWS CodeBuild stage to CodePipeline to run the aws apigateway create-deployment AWS CLI command.
Lý do:
- Sau CloudFormation update, cần tạo Deployment mới thủ công để snapshot API với resource/methods mới.
- Thêm stage CodeBuild vào CodePipeline, chạy lệnh CLI
aws apigateway create-deployment --rest-api-id <id> --stage-name <stage>sẽ tạo deployment mới và update stage → new methods available ngay lập tức. - Đây là best practice cho CI/CD với API Gateway (AWS khuyến nghị kết hợp CloudFormation + CLI cho dynamic deployment). Không ảnh hưởng stack state.
📝 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 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á đúng/sai dựa trên logic AWS API Gateway + CloudFormation (cập nhật 2026).
-
❌ [SAI] Specify the disable-rollback option during the update-stack operation.
Phương án này chỉ vô hiệu hóa rollback tự động nếu stack update thất bại (mặc định CloudFormation rollback on failure). Nó không liên quan đến việc redeploy API Gateway hay fix 404. Stack đã UPDATE_COMPLETE rồi, disable-rollback chỉ dùng cho debug failure, không giải quyết vấn đề snapshot Deployment cũ. -
❌ [SAI] Unset the CloudFormation stack failure options.
Tương tự phương án trên, đây là config xử lý failure (nhưOnFailure: DELETE), không ảnh hưởng đến Deployment lifecycle của API Gateway. Stack thành công rồi, unset options chỉ thay đổi hành vi failure tương lai, không làm new methods available. -
✅ [ĐÚNG] Add an AWS CodeBuild stage to CodePipeline to run the aws apigateway create-deployment AWS CLI command.
Như đã giải thích: Thêm CodeBuild chạy CLI tạo Deployment mới post-CloudFormation, update stage endpoint → fix 404. Hoàn hảo cho CI/CD, scalable và idempotent (CLI check tồn tại). -
❌ [SAI] Add an action to CodePipeline to run the aws cloudfront create-invalidation AWS CLI command.
Lệnh này dùng để invalidate cache CloudFront (CDN), không liên quan vì câu hỏi không đề cập CloudFront. API Gateway 404 là do Deployment thiếu, không phải cache → chạy lệnh này vô ích, có thể lỗi nếu không có distribution.
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS API Gateway Developer Guide: Deploying an API in API Gateway – Giải thích Deployment lifecycle và CLI create-deployment.
- CloudFormation API Gateway Resources: AWS::ApiGateway::Deployment – Lưu ý về snapshot và DependsOn.
- CodePipeline + API Gateway CI/CD: Automating API Gateway deployments – Best practice với CodeBuild CLI.
- Troubleshoot 404: API Gateway troubleshooting.
🛠️ Mẹo DevOps: Để tránh vấn đề, thêm property "dummy" (như Timestamp) vào Deployment YAML để force create new mỗi update, hoặc dùng AWS SAM/CDK cho auto-deployment!