Ngân hàng đề — AWS Certified Developer Associate
Tìm thấy 1356 câu.
The developer has already successfully deployed the application stacks to the alpha environment in the first account by using the AWS CDK CLI's cdk deploy command. The developer is preparing to deploy to the beta environment in a second account for the first time. The developer makes no significant changes to the CDK code between deployments, but the initial deployment in the second account is unsuccessful and returns a NoSuchBucket error.
Which command should the developer run before redeployment to resolve this error?
- A cdk synth
- B cdk bootstrap
- C cdk init
- D cdk destroy
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 triển khai ứng dụng bằng AWS Cloud Development Kit (AWS CDK), cụ thể là deploy các stack chứa code cho nhiều AWS Lambda functions dưới dạng assets (tài nguyên như code zip được upload lên S3).
- 👨💻 Tình huống: Developer đã deploy thành công stack vào môi trường alpha (account đầu tiên) bằng lệnh
cdk deploy. - 🚀 Vấn đề: Khi deploy lần đầu vào môi trường beta (account thứ hai), gặp lỗi NoSuchBucket (không tìm thấy S3 bucket).
- ❓ Nguyên nhân gốc rễ: AWS CDK khi xử lý assets (như code Lambda) cần một S3 bucket staging để lưu trữ tạm thời các file trước khi deploy. Bucket này được tạo tự động qua quá trình bootstrapping CDK cho từng account và region. Account alpha đã bootstrap sẵn (có thể từ lần deploy trước), nhưng account beta chưa bootstrap lần đầu, dẫn đến thiếu bucket → lỗi NoSuchBucket.
- 🎯 Mục tiêu: Tìm lệnh CDK cần chạy trước khi redeploy để khắc phục, đảm bảo môi trường beta sẵn sàng cho CDK deployments với assets.
Lưu ý cập nhật 2026: Với AWS CDK v2 (phiên bản hiện hành), bootstrapping là bước bắt buộc cho cross-account deployments sử dụng assets, IAM roles, và pipelines. Không có thay đổi lớn từ 2023-2026 theo AWS CDK docs.
✅ Đáp án đúng: cdk bootstrap
Lý do lựa chọn:
- Lệnh
cdk bootstrapsẽ tạo ra các tài nguyên cần thiết cho CDK trong account beta, bao gồm:- 🛡️ S3 bucket để lưu assets (giải quyết trực tiếp lỗi NoSuchBucket).
- 🔑 IAM roles cho CDK execution (như cdk-hnb659fds-upload-assets-...).
- 📦 ECR repositories nếu cần container assets.
- 🖥️ CloudFormation roles cho deployments.
- Đây là bước one-time setup cho mỗi account/region. Sau bootstrap,
cdk deploysẽ thành công mà không thay đổi code. - Cách chạy:
cdk bootstrap aws://<account-id>/us-east-1(chỉ định account beta và region). - ✅ Kết quả: Deploy beta thành công ngay lần redeploy sau.
📋 Phân tích tất cả các phương án (đúng/sai)
-
❌ cdk synth
Lệnh này chỉ synthesize (tạo CloudFormation templates từ CDK code) mà không tạo tài nguyên thực tế như S3 bucket. Nó hữu ích để kiểm tra code trước deploy, nhưng không giải quyết thiếu bucket → vẫn lỗi NoSuchBucket. -
✅ cdk bootstrap
Như đã giải thích ở trên: Tạo đầy đủ infrastructure cần thiết cho CDK (S3 bucket cho assets, roles), khắc phục lỗi ngay lập tức cho lần deploy đầu tiên vào account mới. Đây là best practice cho multi-account setups. -
❌ cdk init
Lệnh này khởi tạo project CDK mới (tạo cấu trúc thư mục, files cơ bản như app.ts). Không liên quan đến deployment hay bootstrapping account → vô hiệu ở đây vì project đã tồn tại và deploy alpha thành công. -
❌ cdk destroy
Lệnh này xóa toàn bộ stack đã deploy (nếu có), dùng để cleanup. Chạy nó sẽ làm tệ hơn (xóa resources ở alpha nếu nhầm), không tạo bucket mới → không giải quyết lỗi ở beta.
📘 Tài liệu tham khảo
- AWS CDK Bootstrapping Guide (v2, cập nhật 2026): docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html – Giải thích chi tiết NoSuchBucket và assets.
- AWS CDK Assets: docs.aws.amazon.com/cdk/v2/guide/assets.html – Lý do cần S3 cho Lambda code.
- Troubleshooting CDK: docs.aws.amazon.com/cdk/v2/guide/troubleshooting.html#no-such-bucket – Xác nhận lỗi phổ biến với bootstrap.
- Exam Tip (DevOps Pro DOP-C02): Multi-account CDK thường kiểm tra bootstrapping!
🛠️ Khuyến nghị thực tế: Luôn chạy cdk bootstrap --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess cho full permissions ở test env, và dùng --qualifier cho multi-env isolation.
How should the developer configure AWS SAM to grant the necessary read privilege to the S3 bucket?
- A Reference a second Lambda authorizer function.
- B Add a custom S3 bucket policy to the Lambda function.
- C Create an Amazon Simple Queue Service (SQS) topic for only S3 object reads. Reference the topic in the template.
- D Add the S3ReadPolicy template to the Lambda function's execution role.
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 tự động hóa triển khai ứng dụng serverless bằng AWS Serverless Application Model (AWS SAM). Ứng dụng bao gồm một AWS Lambda function và một Amazon S3 bucket. Yêu cầu cụ thể là Lambda function chỉ cần quyền đọc (read) các objects trong S3 bucket, không cần quyền ghi hoặc các quyền khác.
Developer cần cấu hình AWS SAM template (thường là file YAML) để cấp quyền này một cách an toàn, đơn giản và tuân thủ nguyên tắc least privilege. AWS SAM hỗ trợ khai báo các IAM managed policy templates sẵn có cho execution role của Lambda, giúp tránh viết policy thủ công phức tạp. Đây là kiến thức cốt lõi trong AWS SAM CLI và template specifications (cập nhật đến phiên bản mới nhất năm 2026, với SAM CLI v1.120+ và hỗ trợ các policy templates mở rộng).
📘 Tài liệu tham khảo chính:
- AWS SAM Developer Guide: Configuring permissions with SAM
- AWS SAM policy templates reference
- AWS::Serverless::Function documentation
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Add the S3ReadPolicy template to the Lambda function's execution role.
Lý do 🛠️:
- AWS SAM cung cấp S3ReadPolicy là một policy template managed sẵn, cấp quyền read-only (s3:GetObject, s3:ListBucket) cho Lambda execution role.
- Trong SAM template, bạn khai báo dưới phần
Policiescủa resourceAWS::Serverless::Functionnhư sau:MyLambdaFunction: Type: AWS::Serverless::Function Properties: Policies: - S3ReadPolicy: BucketName: !Ref MyS3Bucket - Điều này tự động attach IAM policy vào execution role của Lambda, đảm bảo Lambda chỉ đọc được objects từ bucket cụ thể. Phù hợp least privilege, dễ quản lý và scale theo best practices AWS (cập nhật 2026 với hỗ trợ fine-grained control hơn).
❌ Phân tích tất cả các phương án (đúng/sai)
-
Reference a second Lambda authorizer function.
❌ Sai hoàn toàn: Lambda authorizer dùng cho API Gateway authorization (custom auth), không liên quan đến quyền truy cập S3 từ Lambda. Tạo thêm function thứ hai chỉ làm phức tạp hóa, không giải quyết IAM permissions cho S3 read. -
Add a custom S3 bucket policy to the Lambda function.
❌ Sai: Bucket policy là policy trên S3 bucket (resource-based policy), không attach trực tiếp vào Lambda function. Lambda dùng IAM role-based policy (execution role). Custom bucket policy có thể cấp quyền nhưng không phải cách chuẩn trong SAM, dễ gây lỗi và không tuân thủ SAM conventions. -
Create an Amazon Simple Queue Service (SQS) topic for only S3 object reads. Reference the topic in the template.
❌ Sai và nhầm lẫn khái niệm: SQS là queue service, không có "topic" (SNS mới có topic). SQS dùng cho message queuing, không cấp quyền S3 read. Không có cơ chế nào trong SAM dùng SQS để "only S3 object reads" – đây là giải pháp lệch lạc, không tồn tại. -
Add the S3ReadPolicy template to the Lambda function's execution role.
✅ Đúng: Như giải thích trên, đây là cách chuẩn, ngắn gọn nhất trong AWS SAM. Policy template này tự động generate IAM policy chính xác cho read-only access, tích hợp seamless vớisam deploy. Hỗ trợ đầy đủ trong phiên bản SAM mới nhất (2026).
🛡️ Lời khuyên DevOps: Luôn ưu tiên SAM policy templates để tránh custom IAM policy thủ công, giảm rủi ro security và dễ audit qua AWS IAM Access Analyzer!
Which approaches could be used to trigger the deployment? (Choose two.)
- A Store the source code in an Amazon S3 bucket. Configure AWS CodePipeline to start whenever a file in the bucket changes.
- B Store the source code in an encrypted Amazon EBS volume. Configure AWS CodePipeline to start whenever a file in the volume changes.
- C Store the source code in an AWS CodeCommit repository. Configure AWS CodePipeline to start whenever a change is committed to the repository.
- D Store the source code in an Amazon S3 bucket. Configure AWS CodePipeline to start every 15 minutes.
- E Store the source code in an Amazon EC2 instance’s ephemeral storage. Configure the instance to start AWS CodePipeline whenever there are changes to the source code.
Xem giải thích
🧩 Phân tích câu hỏi trắc nghiệm AWS DevOps
📖 Nội dung câu hỏi được giải thích chi tiết:
Câu hỏi tập trung vào quy trình CI/CD (Continuous Integration/Continuous Deployment) trên AWS, cụ thể là cách kích hoạt (trigger) pipeline tự động để build và deploy ứng dụng ngay lập tức mỗi khi có thay đổi trong source code. Nhóm phát triển cần các phương pháp sử dụng AWS CodePipeline làm công cụ chính để phát hiện thay đổi và khởi chạy pipeline. Yêu cầu chọn hai cách đúng (Choose TWO), nhấn mạnh vào tính immediate (ngay lập tức), không phải polling định kỳ hay thủ công. Đây là kiến thức cốt lõi trong chứng chỉ AWS Certified DevOps Engineer - Professional (DOP-C02), liên quan đến tích hợp source control với CodePipeline sử dụng các dịch vụ AWS native như Amazon S3 và AWS CodeCommit. Theo tài liệu AWS cập nhật đến năm 2026, CodePipeline hỗ trợ trigger qua Amazon EventBridge cho sự kiện thời gian thực (real-time events), đảm bảo pipeline chạy ngay khi code thay đổi mà không cần polling thủ công.
✅ Đáp án đúng (Chọn TWO):
Hai phương án đúng là:
- Store the source code in an Amazon S3 bucket. Configure AWS CodePipeline to start whenever a file in the bucket changes.
- Store the source code in an AWS CodeCommit repository. Configure AWS CodePipeline to start whenever a change is committed to the repository.
🛠️ Lý do lựa chọn đáp án đúng:
Cả hai cách đều hỗ trợ trigger thời gian thực (event-driven) qua Amazon EventBridge hoặc webhook tích hợp sẵn trong CodePipeline (phiên bản mới nhất DOP-C02, cập nhật 2025-2026). Với S3, khi file được upload/update (PUT/POST events), EventBridge tự động kích hoạt pipeline ngay lập tức. Với CodeCommit, mỗi commit/push sẽ gửi webhook đến CodePipeline, đảm bảo build/deploy immediate mà không delay. Điều này phù hợp hoàn hảo với yêu cầu "immediately" của câu hỏi, tối ưu chi phí và hiệu suất cho DevOps workflow.
🔍 Phân tích chi tiết TẤT CẢ các phương án (Đúng/Sai)
-
✅ Đúng:
Store the source code in an Amazon S3 bucket. Configure AWS CodePipeline to start whenever a file in the bucket changes.
Giải thích: S3 hỗ trợ S3 Object Events qua EventBridge, cho phép CodePipeline detect thay đổi file (như upload ZIP source code) ngay lập tức. Đây là source provider chính thức của CodePipeline, event-driven 100%, không polling. Lý tưởng cho artifact storage hoặc source đơn giản. (Tích hợp mới nhất: EventBridge Pipes cho low-latency trigger từ 2024). -
❌ Sai:
Store the source code in an encrypted Amazon EBS volume. Configure AWS CodePipeline to start whenever a file in the volume changes.
Giải thích: EBS là block storage gắn với EC2, không hỗ trợ event trigger cho file changes. CodePipeline không tích hợp EBS làm source provider; không có cơ chế monitor file system level như FSx hay EFS events. Sử dụng EBS encrypted chỉ phù hợp lưu trữ persistent data, không cho CI/CD trigger. -
✅ Đúng:
Store the source code in an AWS CodeCommit repository. Configure AWS CodePipeline to start whenever a change is committed to the repository.
Giải thích: CodeCommit là Git repository managed bởi AWS, hỗ trợ webhook triggers trực tiếp với CodePipeline. Mỗi commit/push (branch/reference changes) kích hoạt pipeline immediate qua EventBridge. Đây là best practice cho source control trong AWS ecosystem, scalable và secure (IAM integration). -
❌ Sai:
Store the source code in an Amazon S3 bucket. Configure AWS CodePipeline to start every 15 minutes.
Giải thích: Đây là polling mechanism (Kinesis hoặc scheduled), không "immediate" mà chỉ check mỗi 15 phút, gây delay và lãng phí (chi phí polling cao). CodePipeline với S3 hỗ trợ event-based (như phương án đầu), không cần polling định kỳ – vi phạm yêu cầu "whenever there is a change". -
❌ Sai:
Store the source code in an Amazon EC2 instance’s ephemeral storage. Configure the instance to start AWS CodePipeline whenever there are changes to the source code.
Giải thích: Ephemeral storage (instance store) là temporary, non-persistent (mất dữ liệu khi stop/reboot), không có event trigger native cho file changes. CodePipeline không monitor EC2 file system; phải tự code script (như inotify + CLI), phức tạp, không scalable, và không "immediate" tự động theo chuẩn AWS.
📘 Tài liệu tham khảo (AWS cập nhật 2026):
- AWS CodePipeline User Guide: CodePipeline Source Actions & CodeCommit Integration.
- Amazon EventBridge: S3 Events & CodeCommit Events.
- DOP-C02 Exam Guide: Domain 4 - Automation (Triggers & CI/CD Pipelines).
(Nguồn: AWS Documentation, kiểm tra ngày 01/2026 – không thay đổi core features từ 2024).
Wed Nov 08 01:13:00 UTC 2017 : Method completed with status: 502
What should the developer do to resolve the error?
- A Change the HTTP endpoint of the API to an HTTPS endpoint.
- B Change the format of the payload sent to the API Gateway.
- C Change the format of the Lambda function response to the API call.
- D Change the authorization header in the API call to access the Lambda function.
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 tình huống mà nhà phát triển đang xây dựng ứng dụng tích hợp Amazon API Gateway với AWS Lambda. Khi gọi API, họ nhận lỗi 502 Bad Gateway với log cụ thể:Wed Nov 08 01:13:00 UTC 2017 : Method completed with status: 502.
🔍 Ý nghĩa lỗi 502: Đây là lỗi Bad Gateway từ API Gateway, xảy ra khi integration backend (Lambda) trả về phản hồi không hợp lệ hoặc không thể xử lý được. Nguyên nhân phổ biến bao gồm:
- Lambda function trả về response không đúng định dạng mà API Gateway yêu cầu (ví dụ: thiếu
statusCode,bodykhông phải string JSON, hoặc headers không đúng). - Lambda timeout (nhưng log này nhấn mạnh "Method completed", thường chỉ integration error).
- Không liên quan đến endpoint HTTP/HTTPS, payload input, hay authorization (trừ khi cụ thể).
Mục tiêu: Tìm hành động đúng để khắc phục, dựa trên AWS best practices mới nhất (2024-2026), nơi API Gateway vẫn yêu cầu Lambda proxy integration phải tuân thủ strict response format.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Change the format of the Lambda function response to the API call.
Lý do:
🛠️ Lỗi 502 thường xuất phát từ response của Lambda không khớp định dạng proxy integration của API Gateway. Lambda phải trả về object JSON với cấu trúc:
{
"statusCode": 200,
"body": "{\"message\": \"Hello\"}", // Phải là STRING JSON
"headers": { ... } // Tùy chọn
}
Nếu body là object trực tiếp hoặc thiếu statusCode, API Gateway sẽ reject và trả 502. Đây là fix trực tiếp và phổ biến nhất, theo troubleshooting guide AWS (không thay đổi đến 2026).
📋 Phân tích tất cả các phương án (đúng/sai)
Dưới đây là phân tích từng lựa chọn một, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá với lý do chi tiết bằng tiếng Việt dựa trên kiến thức AWS cập nhật.
-
❌ Change the HTTP endpoint of the API to an HTTPS endpoint.
Sai vì: API Gateway luôn hỗ trợ HTTPS cho public endpoints (mặc định), và lỗi 502 không liên quan đến protocol (HTTP/HTTPS). Log chỉ rõ integration failure nội bộ, không phải endpoint mismatch. Thay đổi này vô ích và không giải quyết gốc rễ. -
❌ Change the format of the payload sent to the API Gateway.
Sai vì: Lỗi 502 xảy ra sau khi Lambda xử lý (method completed), nghĩa là input payload đã được forward thành công đến Lambda. Vấn đề nằm ở output response từ Lambda, không phải input format từ client. Nếu payload sai, sẽ là 400 Bad Request thay vì 502. -
✅ Change the format of the Lambda function response to the API call.
Đúng vì: Như đã giải thích ở trên, đây là nguyên nhân chính của 502 trong Lambda integration. AWS yêu cầu response strict format cho proxy/non-proxy mode. Fix bằng cách chỉnh sửa Lambda code để return đúng structure (statusCode + stringified body). -
❌ Change the authorization header in the API call to access the Lambda function.
Sai vì: Authorization (IAM, Cognito, API Key) gây lỗi 401/403 Unauthorized nếu sai, không phải 502. Lambda access qua API Gateway integration role (execution role), không phụ thuộc client header trực tiếp. Log không đề cập auth failure.
📘 Tài liệu tham khảo (AWS Docs cập nhật 2024-2026)
- Troubleshooting API Gateway Errors: AWS Docs - Handle Lambda Errors – Chi tiết 502 do invalid response format.
- Lambda Proxy Integration: AWS Docs - Set up Lambda Proxy – Yêu cầu response format chính xác.
- Error Codes Reference: API Gateway Troubleshooting – Xác nhận 502 từ Lambda malformatted response.
Hy vọng phân tích này giúp bạn ôn thi DOP-C02 hiệu quả! 🚀 Nếu cần ví dụ code Lambda fix, hãy hỏi thêm.
What should the developer do to accomplish these tasks?
- A Use Amazon CloudWatch to aggregate the microservices' logs and metrics, and build the monitoring dashboard.
- B Use AWS CloudTrail to aggregate the microservices' logs and metrics, and build the monitoring dashboard.
- C Use the AWS X-Ray SDK to add instrumentation in all the microservices, and monitor using the X-Ray service map.
- D Use AWS Health to monitor the health of all the microservices.
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 một lập trình viên đang xây dựng các microservices chạy trên Amazon EC2 instances cho một ứng dụng. Yêu cầu chính là giám sát toàn diện (end-to-end view) các yêu cầu (requests) giữa các microservices và debug (gỡ lỗi) các vấn đề trong từng microservice riêng lẻ.
📌 Chi tiết vấn đề:
- Microservices thường phân tán, giao tiếp phức tạp qua mạng, nên cần công cụ distributed tracing để theo dõi luồng request từ đầu đến cuối (trace toàn bộ đường đi).
- Không chỉ metrics/logs thông thường, mà cần service map để visualize mối quan hệ và bottlenecks.
- Mục tiêu: Monitor và debug hiệu quả, phù hợp với kiến trúc serverless/microservices trên AWS (cập nhật đến 2026, AWS X-Ray hỗ trợ tích hợp sâu với EC2, Lambda, ECS, EKS...).
🛠️ Giải pháp lý tưởng: Sử dụng công cụ chuyên biệt cho tracing, không phải monitoring tổng quát.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Use the AWS X-Ray SDK to add instrumentation in all the microservices, and monitor using the X-Ray service map.
Lý do chi tiết:
- AWS X-Ray là dịch vụ chuyên distributed tracing cho ứng dụng microservices, hỗ trợ theo dõi end-to-end requests qua các service (bao gồm EC2).
- Developer thêm X-Ray SDK vào code (hỗ trợ nhiều ngôn ngữ như Java, Node.js, Python...) để instrument (ghi trace segments).
- Service map tự động visualize graph các service, latency, lỗi, giúp debug nhanh chóng (ví dụ: xác định service chậm hoặc fail).
- Cập nhật 2026: X-Ray tích hợp SAM (Service Analyzer Maps), hỗ trợ trace qua API Gateway, ALB, RDS... hoàn hảo cho EC2 microservices.
- ✅ Hoàn thành đúng yêu cầu: End-to-end view + debug issues.
📋 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 bằng tiếng Anh, kèm giải thích sai/đúng bằng tiếng Việt. Tôi đánh dấu ✅ đúng, ❌ sai để dễ theo dõi.
-
Use Amazon CloudWatch to aggregate the microservices' logs and metrics, and build the monitoring dashboard.
❌ Sai vì: CloudWatch giỏi aggregate logs/metrics (như CPU, memory) và dashboard (CloudWatch Dashboards), nhưng không hỗ trợ end-to-end tracing giữa microservices. Không có service map để visualize requests path, chỉ monitor tổng quát, khó debug sâu issues phân tán. Phù hợp bổ sung, không thay thế X-Ray. -
Use AWS CloudTrail to aggregate the microservices' logs and metrics, and build the monitoring dashboard.
❌ Sai vì: CloudTrail là audit trail cho API calls AWS (management events), không aggregate logs/metrics microservices hay build dashboard cho app-level. Không trace requests giữa services, chỉ ghi API AWS (như EC2 start/stop). Không liên quan đến debug microservices runtime. -
Use the AWS X-Ray SDK to add instrumentation in all the microservices, and monitor using the X-Ray service map.
✅ Đúng vì: Như giải thích trên, X-Ray SDK instrument code để trace segments, service map visualize end-to-end flow. Hoàn hảo cho EC2 microservices, hỗ trợ debug latency/errors chính xác. Cập nhật 2026: Tích hợp Insights cho anomaly detection tự động. -
Use AWS Health to monitor the health of all the microservices.
❌ Sai vì: AWS Health (Personal Health Dashboard) monitor health AWS services (như EC2 outages), không monitor app-level microservices hay trace requests. Chỉ thông báo events AWS, không dashboard end-to-end hay debug code issues.
📘 Tài liệu tham khảo (AWS Docs cập nhật 2026)
- AWS X-Ray: docs.aws.amazon.com/xray/latest/devguide/aws-xray.html – Hướng dẫn SDK & service map.
- So sánh X-Ray vs CloudWatch: aws.amazon.com/xray/features/ – Tracing vs metrics.
- DevOps Best Practices: AWS Well-Architected Framework (Observability Pillar, 2024+ updates).
- Exam Prep: AWS Certified DevOps Engineer Professional (DOP-C02) – Domain 5: Automation & Orchestration.
🛠️ Lời khuyên: Kết hợp X-Ray + CloudWatch Logs Insights cho monitoring toàn diện! Nếu cần demo code, hỏi thêm nhé! 🚀
During initial testing, the Lambda function repeatedly inserted duplicate data into the Amazon Redshift table. The duplicate data led to a problem with data analysis. All duplicate messages were submitted to the queue within 1 minute of each other.
How should the developer resolve this issue?
- A Create an SQS FIFO queue. Enable message deduplication on the SQS FIFO queue.
- B Reduce the maximum Lambda concurrency that the SQS queue can invoke.
- C Use Lambda's temporary storage to keep track of processed message identifiers
- D Configure a message group ID for every sent message. Enable message deduplication on the SQS standard queue.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi mô tả một developer đang xây dựng microservice sử dụng AWS Lambda để xử lý message từ Amazon SQS standard queue. Lambda sẽ gọi external APIs để enrich (làm phong phú) dữ liệu message, sau đó load vào Amazon Redshift data warehouse. Queue phải xử lý tối đa 1.000 messages/giây.
Trong quá trình testing ban đầu, Lambda lặp lại insert duplicate data vào bảng Redshift, gây vấn đề cho phân tích dữ liệu. Tất cả duplicate messages đều được submit vào queue trong vòng 1 phút so với nhau.
Vấn đề cốt lõi: SQS standard queue không có cơ chế deduplication (loại bỏ trùng lặp) native, dẫn đến Lambda xử lý nhiều lần cùng một message (có thể do retry hoặc at-least-once delivery của SQS standard). Duplicate xảy ra trong thời gian ngắn (1 phút), cần giải pháp loại bỏ trùng lặp ngay tại queue mà không phụ thuộc vào logic ứng dụng.
Mục tiêu: Tìm cách resolve duplicate hiệu quả, đảm bảo tính nhất quán dữ liệu trong Redshift, phù hợp với throughput cao (1.000 msg/s) 🛠️.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create an SQS FIFO queue. Enable message deduplication on the SQS FIFO queue.
Lý do chi tiết:
- SQS FIFO queue hỗ trợ exactly-once processing và native deduplication dựa trên message deduplication ID (explicit hoặc content-based hashing), với deduplication window 5 phút – hoàn hảo khớp với tình huống duplicate trong 1 phút ✅.
- Chuyển từ standard sang FIFO không ảnh hưởng throughput (FIFO hỗ trợ lên đến 3.000 msg/s với batching), và bắt buộc ordering giúp tránh race condition khi Lambda xử lý.
- Giải quyết gốc rễ tại queue level, không cần thay đổi code Lambda, đảm bảo scalability cho 1.000 msg/s 📈.
- Theo AWS best practices (cập nhật 2024-2026), FIFO là lựa chọn chuẩn cho deduplication trong high-throughput scenarios với Lambda triggers.
📋 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. Mỗi phương án được đánh giá đúng/sai với lý do cụ thể dựa trên kiến thức AWS mới nhất:
-
Create an SQS FIFO queue. Enable message deduplication on the SQS FIFO queue.
✅ Đúng tuyệt đối! Như đã giải thích ở trên, FIFO queue cung cấp deduplication ID (hỗ trợ explicit ID hoặc content-based từ 2020), window 5 phút loại bỏ duplicate ngay khi enqueue. Lambda trigger FIFO hoạt động mượt mà, throughput batch lên 300 msg/batch. Không cần code thêm, resolve hoàn toàn vấn đề duplicate trong 1 phút 🛡️. -
Reduce the maximum Lambda concurrency that the SQS queue can invoke.
❌ Sai! Giảm concurrency (qua reserved concurrency hoặc SQS trigger config) chỉ giới hạn số Lambda invocation song song, giảm throttling nhưng không ngăn duplicate từ queue. SQS standard vẫn deliver at-least-once, duplicate đã enqueue sẽ vẫn được xử lý lặp lại. Không giải quyết gốc rễ, có thể làm chậm throughput xuống dưới 1.000 msg/s 🚫. -
Use Lambda's temporary storage to keep track of processed message identifiers.
❌ Sai! /tmp storage của Lambda chỉ ephemeral (tạm thời, max 10GB), bị xóa sau mỗi invocation. Không persistent across cold starts hoặc instances khác nhau, dẫn đến không track được ID đã process đáng tin cậy ở scale (1.000 msg/s). Phức tạp, dễ fail với high concurrency, vi phạm best practices (nên dùng queue-level dedup thay vì app-level) 💥. -
Configure a message group ID for every sent message. Enable message deduplication on the SQS standard queue.
❌ Sai! SQS standard queue KHÔNG hỗ trợ message group ID (chỉ có ở FIFO) và KHÔNG có native deduplication. Message group ID chỉ dùng cho FIFO ordering. Áp dụng sẽ fail ngay khi tạo queue/config, không resolve duplicate mà còn lỗi config ngay lập tức 🔒.
📘 Tài liệu tham khảo (AWS cập nhật mới nhất đến 2026)
- AWS SQS FIFO Documentation: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html (Deduplication window 5 phút, content-based dedup từ 2020).
- Lambda with SQS Triggers: https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html (Hỗ trợ FIFO triggers, exactly-once với dedup).
- SQS Standard vs FIFO: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/standard-and-fifo-queues.html (Standard: at-least-once; FIFO: exactly-once).
- AWS Well-Architected Framework - Reliability Pillar: Khuyến nghị FIFO cho deduplication trong event-driven apps (Reliability whitepaper 2024).
Giải pháp này đảm bảo zero-downtime migration (tạo FIFO mới, redirect producer) và cost-effective cho workload cao! 🚀
A developer needs to configure the Lambda function to reduce the cold start time that is associated with default scaling.
What should the developer do to meet these requirements?
- A Publish a new version of the Lambda function. Configure provisioned concurrency. Set the provisioned concurrency limit to meet the company requirements.
- B Increase the Lambda function's memory to the maximum amount. Increase the Lambda function's reserved concurrency limit.
- C Increase the reserved concurrency of the Lambda function to a number that matches the current production load.
- D Use Service Quotas to request an increase in the Lambda function's concurrency limit for the AWS account where the function is deployed.
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 giảm thời gian cold start của AWS Lambda function trong một ứng dụng sử dụng Amazon API Gateway để gọi Lambda. Ứng dụng này nhạy cảm với độ trễ (latency-sensitive), nghĩa là cần phản hồi nhanh chóng và ổn định.
- Vấn đề chính: Với cơ chế default scaling (mở rộng mặc định) của Lambda, khi có yêu cầu mới mà không có execution environment sẵn sàng (cold start), thời gian khởi tạo sẽ lâu hơn (có thể vài giây), ảnh hưởng đến hiệu suất.
- Yêu cầu: Developer cần cấu hình Lambda để giảm cold start liên quan đến default scaling, đảm bảo instances luôn "warm" (sẵn sàng) cho tải trọng mong muốn.
- Bối cảnh AWS cập nhật đến 2026: Lambda hỗ trợ Provisioned Concurrency (từ 2019, vẫn là tính năng cốt lõi mới nhất) để pre-warm instances. Không có thay đổi lớn ở phiên bản sau; SnapStart (cho Java) hoặc Arm-based runtimes giúp thêm, nhưng không phải giải pháp chính cho trường hợp này. API Gateway tích hợp tốt với Provisioned Concurrency để tránh cold starts.
📘 Tài liệu tham khảo:
- AWS Lambda Provisioned Concurrency (cập nhật 2024).
- Lambda Scaling & Concurrency.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Publish a new version of the Lambda function. Configure provisioned concurrency. Set the provisioned concurrency limit to meet the company requirements.
Lý do 🛠️:
- Đây là giải pháp chính thức và hiệu quả nhất để giảm cold start cho Lambda với default scaling. Provisioned Concurrency pre-provisions số lượng execution environments cố định (warm instances) dựa trên phiên bản Lambda cụ thể, đảm bảo latency thấp và ổn định cho ứng dụng latency-sensitive.
- Quy trình: Publish version mới → Alias → Config Provisioned Concurrency trên alias → Set limit phù hợp với yêu cầu công ty (ví dụ: 100 concurrent executions luôn sẵn sàng).
- Kết quả: Giảm cold start gần như về 0, phù hợp với API Gateway (hỗ trợ alias routing).
📋 Giải thích tất cả các phương án (đúng/sai)
-
✅ Publish a new version of the Lambda function. Configure provisioned concurrency. Set the provisioned concurrency limit to meet the company requirements.
Đúng 🏆: Như đã giải thích, đây là cách trực tiếp giải quyết cold start bằng pre-warming. Phải publish version mới vì Provisioned Concurrency chỉ áp dụng cho non-$LATEST version. Hiệu quả cao, chi phí dự đoán được (pay-per-provisioned). -
❌ Increase the Lambda function's memory to the maximum amount. Increase the Lambda function's reserved concurrency limit.
Sai 🚫: Tăng memory (max 10GB) giúp cold start nhanh hơn gián tiếp vì CPU tăng tỷ lệ (power scaling), nhưng không giải quyết cold start từ default scaling (vẫn cần init môi trường). Reserved concurrency chỉ giới hạn tài nguyên cho function, tránh throttling nhưng không pre-warm instances. -
❌ Increase the reserved concurrency of the Lambda function to a number that matches the current production load.
Sai ⚠️: Reserved concurrency đặt giới hạn concurrency tối đa cho function (mặc định 1000/account), giúp ưu tiên tài nguyên nhưng không giảm cold start. Nó chỉ đảm bảo function không bị throttle dưới tải hiện tại, vẫn phụ thuộc default scaling (cold starts xảy ra nếu burst traffic). -
❌ Use Service Quotas to request an increase in the Lambda function's concurrency limit for the AWS account where the function is deployed.
Sai 🔒: Tăng account-level quota (mặc định 1000 concurrent executions/region) chỉ cho phép scale lớn hơn, nhưng không ảnh hưởng cold start. Default scaling vẫn init instances mới chậm; quota này là burst limit chung, không pre-provision.
Kết luận 🎯: Chỉ Provisioned Concurrency mới trực tiếp "warm" instances cho latency-sensitive apps. Các phương án sai tập trung concurrency limits thay vì pre-warming!
Which actions should the developer take to provide the application with access to the stream? (Choose two.)
- A Update the instance profile role in Account A with stream read permissions.
- B Create an IAM role with stream read permissions in Account B.
- C Add a trust policy to the instance profile role and IAM role in Account B to allow the instance profile role to assume the IAM role.
- D Add a trust policy to the instance profile role and IAM role in Account B to allow reads from the stream.
- E Add a resource-based policy in Account B to allow read access from the instance profile role.
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 truy cập cross-account (giữa hai tài khoản AWS khác nhau) cho ứng dụng chạy trên Amazon EC2 instances ở Account A, cần đọc dữ liệu từ Amazon Kinesis Data Stream tồn tại sẵn ở Account B.
- Bối cảnh: EC2 sử dụng instance profile role (IAM role gắn với EC2) để xác thực. Để đọc stream cross-account, không thể chỉ dùng permissions thông thường vì AWS yêu cầu cơ chế đặc biệt như assume role hoặc resource-based policy.
- Yêu cầu chọn TWO actions: Developer cần thực hiện hai bước chính để cấp quyền an toàn, theo best practice AWS (sử dụng IAM roles và trust relationships).
- Kiến thức cốt lõi: Kinesis Data Streams hỗ trợ cross-account access qua IAM roles với STS AssumeRole (cách khuyến nghị), hoặc resource policies. Phiên bản AWS mới nhất (2026) vẫn giữ nguyên, nhấn mạnh least privilege và temporary credentials qua STS.
✅ Đáp án đúng (Chọn TWO)
Hai lựa chọn đúng là B và C, vì chúng mô tả quy trình assume IAM role cross-account – cách chuẩn để EC2 ở Account A tạm thời nhận credentials từ role ở Account B, cho phép đọc stream mà không chia sẻ long-term keys.
- Lý do chọn:
- B tạo role ở Account B với permissions đọc stream (kinesis:DescribeStream, kinesis:GetRecords,...).
- C thiết lập trust policy để role ở A có thể assume role ở B (qua STS), kết hợp policy trên role A cho phép sts:AssumeRole. Điều này tuân thủ AWS Shared Responsibility Model và tránh direct access rủi ro.
📋 Phân tích tất cả các phương án
Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Tôi sử dụng ✅ cho đúng, ❌ cho sai, kèm giải thích rõ ràng bằng tiếng Việt dựa trên docs AWS mới nhất.
-
❌ Update the instance profile role in Account A with stream read permissions.
Sai: Chỉ cập nhật permissions đọc stream trên role ở Account A không đủ cho cross-account. Role A thiếu quyền truy cập tài nguyên ở Account B (Kinesis ARN ở B). Cần thêm resource policy hoặc assume role; nếu không, STS từ EC2 sẽ bị từ chối. 🛑 -
✅ Create an IAM role with stream read permissions in Account B.
Đúng: Tạo role ở Account B với policy cho phép đọc stream (ví dụ:kinesis:GetShardIterator,kinesis:GetRecords). Role này sẽ được assume bởi EC2 ở A, cấp temporary credentials. Đây là bước đầu tiên bắt buộc trong quy trình cross-account. 🛠️ -
✅ Add a trust policy to the instance profile role and IAM role in Account B to allow the instance profile role to assume the IAM role.
Đúng:- Trên IAM role ở Account B: Thêm trust policy (Principal: ARN của instance profile role ở A, Action: sts:AssumeRole).
- Trên instance profile role ở Account A: Thêm IAM policy cho phép
sts:AssumeRoletrên role ARN ở B.
Kết quả: EC2 gọi STS để assume role B, nhận creds tạm thời đọc stream. Đây là bước thứ hai hoàn thiện quy trình. 🔄
-
❌ Add a trust policy to the instance profile role and IAM role in Account B to allow reads from the stream.
Sai: Trust policy chỉ dùng cho assume role, không cấp quyền đọc stream (như GetRecords). Nó chỉ định ai được assume role. Nếu dùng để "allow reads", sẽ bị lỗi policy validation vì sai mục đích. Trust policy ≠ permissions policy. 🚫 -
❌ Add a resource-based policy in Account B to allow read access from the instance profile role.
Sai (dù Kinesis hỗ trợ resource policies): Chỉ resource policy thôi không đủ, vì instance role ở A vẫn cần permissions đọc Kinesis (như option A). Hơn nữa, cách này kém an toàn hơn assume role (không dùng temporary creds), và AWS ưu tiên assume role cho EC2 cross-account. Nếu kết hợp A+E thì có thể, nhưng câu hỏi yêu cầu TWO actions chính xác theo best practice. ⚠️
📘 Tài liệu tham khảo (AWS Docs mới nhất 2026)
- Cross-account access cho Kinesis Data Streams – Hướng dẫn assume role.
- IAM Roles for cross-account access – Trust policies và STS.
- Kinesis Resource Policies – Xác nhận hỗ trợ nhưng khuyến nghị role-based.
- Exam guide DOP-C02: Nhấn mạnh IAM cross-account cho services như EC2 + Kinesis.
Hy vọng phân tích này giúp bạn ôn thi hiệu quả! 🚀 Nếu cần ví dụ code Terraform/CloudFormation, hỏi thêm nhé.
Which solution will meet this requirement?
- A Create a custom Amazon CloudWatch alarm that sends a notification to an Amazon SNS topic when the CPU utilization exceeds 80%.
- B Create a custom AWS CloudTrail alarm that sends a notification to an Amazon SNS topic when the CPU utilization exceeds 80%.
- C Create a cron job on the EC2 instance that invokes the --describe-instance-information command on the host instance every 15 minutes and sends the results to an Amazon SNS topic.
- D Create an AWS Lambda function that queries the AWS CloudTrail logs for the CPUUtilization metric every 15 minutes and sends a notification to an Amazon SNS topic when the CPU utilization exceeds 80%.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi mô tả một startup thương mại điện tử đang chuẩn bị cho sự kiện bán hàng hàng năm, khi lưu lượng truy cập (traffic) vào ứng dụng tăng cao. Đội ngũ phát triển muốn nhận thông báo ngay lập tức khi CPU utilization (tỷ lệ sử dụng CPU) của Amazon EC2 instance vượt quá 80%.
🛠️ Yêu cầu chính: Cần một giải pháp giám sát metrics (chỉ số hiệu suất) CPU của EC2 và gửi thông báo qua Amazon SNS topic. Giải pháp phải:
- Tự động, đáng tin cậy, không phụ thuộc vào thủ công.
- Sử dụng các dịch vụ AWS native để scale tốt trong môi trường high-traffic (cập nhật đến 2026, CloudWatch hỗ trợ metrics chi tiết cho EC2 với độ trễ thấp ~1-5 phút).
- Tránh các cách phức tạp, kém hiệu quả hoặc sai mục đích.
Mục tiêu là monitoring và alerting metrics hệ thống, không phải audit API calls.
✅ Đáp án đúng
Phương án A: Create a custom Amazon CloudWatch alarm that sends a notification to an Amazon SNS topic when the CPU utilization exceeds 80%.
Lý do lựa chọn 🏆:
- Amazon CloudWatch là dịch vụ monitoring metrics chuẩn của AWS (từ basic metrics như CPUUtilization của EC2 đến custom metrics). Metric CPUUtilization được CloudWatch thu thập tự động mỗi 5 phút (hoặc 1 phút với detailed monitoring) cho mọi EC2 instance.
- Tạo CloudWatch Alarm trên metric này, đặt threshold >80%, và action là gửi notification đến SNS topic – hoàn hảo, serverless, scale tự động.
- Theo best practices AWS Well-Architected Framework (Operations Pillar, 2026), đây là cách managed, low-latency alerting lý tưởng cho high-traffic events như Black Friday.
📋 Phân tích chi tiết từng phương án
Dưới đây là phân tích tất cả các phương án (giữ nguyên văn bản gốc tiếng Anh). Mỗi phương án được đánh giá ✅ (đúng) hoặc ❌ (sai), kèm giải thích rõ ràng dựa trên kiến thức AWS mới nhất (2026).
-
A. Create a custom Amazon CloudWatch alarm that sends a notification to an Amazon SNS topic when the CPU utilization exceeds 80%.
✅ Đúng hoàn toàn. CloudWatch thu thập metric CPUUtilization native cho EC2 (namespace AWS/EC2), alarm trigger realtime khi vượt threshold, integrate trực tiếp với SNS cho notification (email/SMS/Lambda). Độ chính xác cao, chi phí thấp (~$0.10/alarm/tháng), không cần code custom. Lý tưởng cho production. -
B. Create a custom AWS CloudTrail alarm that sends a notification to an Amazon SNS topic when the CPU utilization exceeds 80%.
❌ Sai. AWS CloudTrail là dịch vụ audit và logging API calls (không phải metrics performance như CPU). CloudTrail không có metric CPUUtilization, không hỗ trợ "CloudTrail alarm" cho metrics hệ thống. Alarm chỉ integrate với CloudWatch Events cho API events, không monitor CPU. Sử dụng sai dịch vụ dẫn đến thất bại. -
C. Create a cron job on the EC2 instance that invokes the --describe-instance-information command on the host instance every 15 minutes and sends the results to an Amazon SNS topic.
❌ Sai.- Lệnh
--describe-instance-informationkhông tồn tại trong AWS CLI (có lẽ nhầm vớidescribe-instance-statushoặcdescribe-instances, nhưng chúng không trả về CPU real-time chính xác). - Cron job trên EC2 là custom scripting, không scalable (phải chạy trên instance, tốn CPU thêm, fail nếu instance down), polling 15 phút kém hiệu quả so với CloudWatch (1-5 phút). Vi phạm single responsibility (instance chỉ chạy app, không monitoring), không fault-tolerant.
- Lệnh
-
D. Create an AWS Lambda function that queries the AWS CloudTrail logs for the CPUUtilization metric every 15 minutes and sends a notification to an Amazon SNS topic when the CPU utilization exceeds 80%.
❌ Sai. CloudTrail logs chỉ ghi API calls (như RunInstances), không chứa CPUUtilization metric (đó là nhiệm vụ của CloudWatch). Lambda query CloudTrail (qua Athena/Logs Insights) sẽ không tìm thấy metric này, dẫn đến false negative. Polling 15 phút tốn kém (Lambda invocations + query costs), phức tạp không cần thiết so với CloudWatch Alarm native.
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- CloudWatch Alarms & Metrics: Amazon CloudWatch User Guide - Creating Alarms (EC2 CPUUtilization metric: AWS/EC2 namespace).
- SNS Integration: CloudWatch Alarms with SNS.
- CloudTrail vs CloudWatch: AWS Well-Architected - Monitoring (phân biệt audit vs metrics).
- EC2 Monitoring Best Practices: Amazon EC2 User Guide - Monitor with CloudWatch.
🛠️ Khuyến nghị thực tế: Kết hợp với CloudWatch Contributor Insights hoặc CloudWatch Synthetics cho monitoring sâu hơn trong sales event. Nếu cần auto-scaling, dùng CloudWatch + Auto Scaling Group!
Users no longer access the PDFs 90 days after the PDFs are generated. The S3 bucket is not versioned and contains many obsolete PDFs.
A developer must reduce the number of files in the S3 bucket by removing PDFs that are older than 90 days.
Which solution will meet this requirement with the LEAST development effort?
- A Update the application code. In the code, add a rule to scan all the objects in the S3 bucket every day and to delete objects after 90 days.
- B Create an AWS Lambda function. Program the Lambda function to scan all the objects in the S3 bucket every day and to delete objects after 90 days.
- C Create an S3 Lifecycle rule for the S3 bucket to expire objects after 90 days.
- D Partition the S3 objects with a // key prefix. Create an AWS Lambda function to remove objects that have prefixes that have reached the expiration date.
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 được triển khai trên AWS Elastic Beanstalk, nơi tạo ra các file PDF cá nhân hóa cho người dùng, lưu trữ chúng vào Amazon S3 bucket (không bật versioning), sau đó gửi qua email bằng Amazon SES. Vấn đề là các file PDF không còn được truy cập sau 90 ngày, dẫn đến bucket chứa nhiều file cũ (obsolete PDFs). Nhiệm vụ của developer là giảm số lượng file bằng cách xóa các PDF cũ hơn 90 ngày, với yêu cầu LEAST development effort (ít nỗ lực phát triển nhất).
🛠️ Mục tiêu chính: Tìm giải pháp tự động hóa việc xóa object cũ mà không cần viết code phức tạp, tận dụng tính năng native của AWS để tiết kiệm thời gian và chi phí vận hành. Bucket không versioned nên việc xóa là vĩnh viễn và an toàn.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create an S3 Lifecycle rule for the S3 bucket to expire objects after 90 days.
Lý do:
- S3 Lifecycle rules là tính năng native của Amazon S3, cho phép tự động expire (xóa vĩnh viễn) objects sau một khoảng thời gian nhất định (ở đây là 90 ngày) mà không cần viết bất kỳ code nào.
- Chỉ cần cấu hình rule qua AWS Management Console, CLI, hoặc SDK với vài dòng lệnh, S3 sẽ tự động xử lý hàng ngày mà không tốn tài nguyên thêm (không cần Lambda hay cron job).
- Đây là giải pháp least development effort vì zero code, scalable, và chi phí thấp (chỉ tính phí storage đến khi xóa). Phù hợp với bucket không versioned, tránh tích tụ data cũ hiệu quả.
- Kiến thức cập nhật 2026: S3 Lifecycle hỗ trợ expire objects sau >=1 ngày, tích hợp với S3 Intelligent-Tiering/Glacier nếu cần, nhưng expire trực tiếp là tối ưu nhất.
📋 Giải thích chi tiết tất cả các phương án
Dưới đây là phân tích từng lựa chọn. Tôi giữ nguyên văn bản 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:
-
❌ Update the application code. In the code, add a rule to scan all the objects in the S3 bucket every day and to delete objects after 90 days.
Sai vì: Phải sửa code ứng dụng (trên Elastic Beanstalk), thêm logic scan toàn bộ bucket hàng ngày (sử dụng ListObjects API), kiểm tra ngày tạo/modified, rồi delete. Điều này tốn nhiều effort phát triển (code, test, deploy), tăng tải cho app, không scalable nếu bucket lớn (giới hạn API calls), và dễ lỗi nếu app crash. Không phải least effort. -
❌ Create an AWS Lambda function. Program the Lambda function to scan all the objects in the S3 bucket every day and to delete objects after 90 days.
Sai vì: Dù tách khỏi app chính, vẫn phải viết code Lambda (scan bằng ListObjectsV2, filter theo LastModified, delete), trigger bằng EventBridge/Cron (hàng ngày), xử lý pagination/error handling. Effort cao hơn Lifecycle (code + test + IAM roles), tốn chi phí invocation nếu bucket lớn, và không native như S3 tự quản lý. -
✅ Create an S3 Lifecycle rule for the S3 bucket to expire objects after 90 days.
Đúng vì: Như đã giải thích ở trên – native, no code, tự động, least effort. S3 tự scan và xóa hàng ngày dựa trên age của object (tính từ creation time), áp dụng cho toàn bucket hoặc prefix/tag. -
❌ Partition the S3 objects with a // key prefix. Create an AWS Lambda function to remove objects that have prefixes that have reached the expiration date.
Sai vì: Phải thay đổi code ứng dụng để lưu object với prefix phân vùng (year/month/day), rồi viết Lambda scan prefix cũ để delete (dùng ListObjects trên prefix). Effort rất cao (refactor app + code Lambda + cron), phức tạp hóa storage layout, không linh hoạt nếu không partition đúng, và vẫn kém hơn Lifecycle (không cần partition vì Lifecycle check age trực tiếp).
📘 Tài liệu tham khảo (cập nhật mới nhất AWS 2026)
- AWS S3 Lifecycle Management: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html (Chi tiết expire rules, ví dụ config 90 days).
- S3 Best Practices: https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html#sc-dynamic-data (Khuyến nghị dùng Lifecycle cho data cũ).
- Elastic Beanstalk & S3 Integration: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.S3.html (Xác nhận S3 là storage lý tưởng cho artifacts như PDF).
🛠️ Lời khuyên DevOps: Luôn ưu tiên serverless native features như S3 Lifecycle để giảm operational overhead. Nếu bucket có versioning sau này, chuyển sang "Permanently delete noncurrent versions". Test rule trên bucket dev trước! 🚀