Ngân hàng đề — AWS Certified Developer Associate
Tìm thấy 1356 câu.
In recent weeks, the application's performance has decreased significantly during a peak period for traffic. A developer suspects that the application issues are related to the memory usage. The developer checks the Elastic Beanstalk console and notices that memory usage is not being tracked.
How should the developer gather more information about the application performance issues?
- A Configure the Amazon CloudWatch agent to push logs to Amazon CloudWatch Logs by using port 443.
- B Configure the Elastic Beanstalk .ebextensions directory to track the memory usage of the instances.
- C Configure the Amazon CloudWatch agent to track the memory usage of the instances.
- D Configure an Amazon CloudWatch dashboard to track the memory usage of the instances.
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 batch processing (xử lý hàng loạt dữ liệu lớn) được triển khai trên AWS Elastic Beanstalk với các instances chạy phiên bản Amazon Linux mới nhất (theo kiến thức cập nhật đến 2026, đây là Amazon Linux 2023 - AL2023 hoặc Amazon Linux 2 - AL2, nơi Elastic Beanstalk mặc định không theo dõi metrics bộ nhớ).
📊 Vấn đề chính:
- Hiệu suất ứng dụng giảm mạnh trong giờ cao điểm do nghi ngờ liên quan đến memory usage (sử dụng bộ nhớ).
- Developer kiểm tra Elastic Beanstalk console nhưng không thấy metrics bộ nhớ được theo dõi (basic monitoring chỉ có CPU, network, disk I/O; memory cần agent bổ sung).
- Mục tiêu: Thu thập thông tin chi tiết hơn về hiệu suất, đặc biệt là memory metrics, để chẩn đoán vấn đề.
🛠️ Bối cảnh AWS: Elastic Beanstalk trên AL2/AL2023 không thu thập memory metrics mặc định qua CloudWatch (chỉ có "Enhanced Health monitoring" với một số metrics cơ bản). Để theo dõi memory (như MemoryUtilization, MemUsedPercent), cần Amazon CloudWatch agent để đẩy custom metrics từ instances lên CloudWatch.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure the Amazon CloudWatch agent to track the memory usage of the instances.
Lý do chi tiết 🏆:
- CloudWatch agent là công cụ chính thức của AWS (cập nhật phiên bản mới nhất 2026) để thu thập custom metrics như memory (RSS, Cache, Swap, etc.) từ EC2 instances trong Elastic Beanstalk.
- Agent được install qua .ebextensions hoặc SSM, config file YAML/JSON để track memory, sau đó đẩy metrics lên CloudWatch mỗi 60s (hoặc tần suất tùy chỉnh).
- Kết quả: Xuất hiện metrics trong CloudWatch Metrics console, giúp phân tích biểu đồ, alarms, và chẩn đoán peak memory causing OOM (Out-Of-Memory).
- Đây là best practice cho EB theo tài liệu AWS mới nhất, hỗ trợ AL2023 đầy đủ.
📋 Giải thích tất cả các phương án (đúng/sai)
Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá dựa trên tính khả thi, best practice AWS 2026:
-
❌ [SAI] Configure the Amazon CloudWatch agent to push logs to Amazon CloudWatch Logs by using port 443.
Phương án này sai vì CloudWatch agent ở đây chỉ dùng để đẩy logs (không phải metrics). Memory usage là metrics số liệu, không phải logs text. Port 443 dùng cho logs an toàn (HTTPS), nhưng không giải quyết tracking memory. Sử dụng sai mục đích, không thu thập được dữ liệu hiệu suất cần thiết. -
❌ [SAI] Configure the Elastic Beanstalk .ebextensions directory to track the memory usage of the instances.
Phương án này sai một phần vì .ebextensions chỉ là công cụ config (files .config để install packages/scripts), không trực tiếp track memory. Để track memory, vẫn cần config CloudWatch agent bên trong .ebextensions (ví dụ: install agent + config.yaml). Lựa chọn mơ hồ, không chỉ rõ agent, nên không phải giải pháp hoàn chỉnh/best practice trực tiếp. -
✅ [ĐÚNG] Configure the Amazon CloudWatch agent to track the memory usage of the instances.
Như đã giải thích ở trên: Đây là cách chính xác nhất, agent thu thập memory metrics chi tiết (procstat, memory metrics plugin), đẩy lên CloudWatch. Hỗ trợ EB multi-container/AL2023, dễ scale, và integrate với dashboards/alarms. -
❌ [SAI] Configure an Amazon CloudWatch dashboard to track the memory usage of the instances.
Phương án này sai vì dashboard chỉ là giao diện visualize metrics đã tồn tại, không thu thập dữ liệu. Nếu không có metrics memory (như tình huống câu hỏi), dashboard sẽ trống. Cần agent trước để có data, sau đó mới tạo dashboard.
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS Elastic Beanstalk Monitoring: docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced-metrics.html – Xác nhận memory cần CloudWatch agent.
- CloudWatch Agent trên EB: docs.aws.amazon.com/elasticbeanstalk/latest/dg/cloudwatchlogs.html & docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html – Hướng dẫn config agent cho memory metrics trên AL2/AL2023.
- EB .ebextensions ví dụ: docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html.
- Best Practices DevOps: AWS Well-Architected Framework – Reliability Pillar: Sử dụng CloudWatch agent cho custom metrics.
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ụ config.yaml agent, hãy hỏi thêm.
How should the developer encrypt this data?
- A Enable Amazon EBS volume encryption with an AWS KMS key in the Lambda function configuration so that all storage attached to the Lambda function is encrypted.
- B Set up the Lambda function with a role and key policy to access an AWS KMS key. Use the key to generate a data key used to encrypt all data prior to writing to /tmp storage.
- C Use OpenSSL to generate a symmetric encryption key on Lambda startup. Use this key to encrypt the data prior to writing to /tmp.
- D Use an on-premises hardware security module (HSM) to generate keys, where the Lambda function requests a data key from the HSM and uses that to encrypt data on all requests to the function.
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 xây dựng ứng dụng y tế bảo mật cao (healthcare application) sử dụng serverless components trên AWS Lambda. Ứng dụng cần ghi dữ liệu tạm thời vào thư mục /tmp trên Lambda function. Thách thức chính là mã hóa dữ liệu này một cách an toàn, vì:
- AWS Lambda là môi trường serverless, ephemeral (tạm thời), không có persistent storage như EBS.
- Thư mục
/tmplà local storage tạm thời (tối đa 10GB, có thể lên 10TB tùy config), được AWS tự động mã hóa tại chỗ (at-rest encryption) bằng AWS-owned keys kể từ năm 2020 (cập nhật mới nhất 2024-2026 vẫn giữ nguyên). - Tuy nhiên, với yêu cầu bảo mật cao (highly secure healthcare), tuân thủ HIPAA/PHI, cần mã hóa dữ liệu trước khi ghi bằng customer-managed keys để kiểm soát đầy đủ (envelope encryption với AWS KMS).
- Mục tiêu: Đảm bảo dữ liệu nhạy cảm được mã hóa symmetric trước khi lưu vào
/tmp, tránh rủi ro chia sẻ execution environment.
🛠️ Kiến thức cốt lõi: Sử dụng AWS KMS envelope encryption để generate data key (symmetric) từ master key, mã hóa dữ liệu plaintext trước khi write. Điều này hiệu quả, scalable và tuân thủ best practices AWS (không làm chậm Lambda cold starts).
📘 Tài liệu tham khảo:
- AWS Lambda /tmp storage (cập nhật 2024: /tmp encrypted at rest mặc định).
- AWS KMS for Lambda encryption & Envelope Encryption (best practice cho data at rest in memory/tmp).
- AWS Well-Architected Framework: Security Pillar (2024 edition).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Set up the Lambda function with a role and key policy to access an AWS KMS key. Use the key to generate a data key used to encrypt all data prior to writing to /tmp storage.
Lý do:
- Đây là best practice chuẩn AWS cho mã hóa dữ liệu tạm thời trong Lambda: Sử dụng IAM role của Lambda attach policy truy cập KMS CMK (Customer Managed Key).
- Quy trình envelope encryption 🛠️:
- Lambda gọi
GenerateDataKeyAPI từ KMS → nhận plaintext data key (symmetric AES-256). - Dùng data key mã hóa dữ liệu trước khi ghi
/tmp. - Lưu ciphertext data key (encrypted by CMK) cùng dữ liệu mã hóa → decrypt khi cần.
- Lambda gọi
- Ưu điểm: An toàn (KMS audit logs, key rotation tự động), scalable (không lưu key lâu dài), tuân thủ HIPAA (key policy kiểm soát access). Không ảnh hưởng performance Lambda (data key reuse trong invocation).
- Cập nhật 2026: KMS hỗ trợ Lambda extensions cho caching data keys, tối ưu hơn.
📋 Giải thích tất cả các phương án
Dưới đây là phân tích từng lựa chọn (giữ nguyên văn bản gốc tiếng Anh), đánh dấu ✅ đúng hoặc ❌ sai, kèm lý do chi tiết bằng tiếng Việt:
-
❌ Enable Amazon EBS volume encryption with an AWS KMS key in the Lambda function configuration so that all storage attached to the Lambda function is encrypted.
Sai vì: Lambda không hỗ trợ attach EBS volumes (serverless, không có EC2 instance persistent)./tmplà ephemeral local storage trong container Lambda, không liên quan EBS. Config EBS encryption không tồn tại trong Lambda settings. (Rủi ro: Không khả thi, gây nhầm lẫn với EC2). -
✅ Set up the Lambda function with a role and key policy to access an AWS KMS key. Use the key to generate a data key used to encrypt all data prior to writing to /tmp storage.
Đúng vì: Như giải thích trên, đây là phương pháp chuẩn AWS KMS envelope encryption cho/tmp. IAM role + KMS key policy đảm bảo least privilege access. Hiệu quả cho healthcare (audit trail đầy đủ via CloudTrail/KMS logs). -
❌ Use OpenSSL to generate a symmetric encryption key on Lambda startup. Use this key to encrypt the data prior to writing to /tmp.
Sai vì: Tạo key bằng OpenSSL không an toàn trong Lambda (execution environment chia sẻ, cold starts tạo key mới/random). Không có key management (rotation, revocation), dễ leak nếu function crash. Vi phạm best practices (AWS khuyến nghị dùng KMS thay vì self-generated keys). Không tuân thủ compliance healthcare. -
❌ Use an on-premises hardware security module (HSM) to generate keys, where the Lambda function requests a data key from the HSM and uses that to encrypt data on all requests to the function.
Sai vì: Lambda là serverless cloud-native, không kết nối on-premises HSM (latency cao, không scalable). Cloud HSM (AWS CloudHSM) tồn tại nhưng phức tạp/unnecessary cho trường hợp này (KMS thay thế tốt hơn, FIPS 140-2 compliant). Không phù hợp serverless architecture.
🛠️ Lời khuyên thực hành: Trong code Lambda (Node.js/Python), dùng AWS SDK: kms.generateDataKey() trước khi crypto.encrypt(). Test với Lambda layers cho crypto libs. Scale lên S3 nếu dữ liệu > /tmp limit!
Which of the following is a possible reason for the Lambda function's inability to launch?
- A The S3 event notification does not activate for files that are larger than 1,000 MB.
- B The resource-based policy for the Lambda function does not have the required permissions to be invoked by Amazon S3.
- C Lambda functions cannot be invoked directly from an S3 event.
- D The S3 bucket needs to be made public.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi mô tả tình huống một lập trình viên đã tạo AWS Lambda function để gửi thông báo qua Amazon SNS mỗi khi có file lớn hơn 50 MB được upload lên Amazon S3. Lambda đã được deploy và test thành công bằng AWS CLI. Tuy nhiên, khi cấu hình S3 event notification trên bucket và upload file 3.000 MB (3 GB), Lambda không được kích hoạt (không launch).
📌 Vấn đề cốt lõi: Tại sao Lambda không chạy dù đã test CLI thành công? Điều này liên quan đến cấu hình quyền truy cập (permissions) giữa S3 và Lambda, vì test CLI sử dụng quyền của user cá nhân, nhưng event từ S3 cần quyền riêng. S3 event notifications hỗ trợ trigger Lambda cho mọi kích thước file (không giới hạn), và quy trình chuẩn yêu cầu resource-based policy trên Lambda để cho phép S3 invoke.
🛠️ Kiến thức AWS cập nhật 2026: Theo tài liệu AWS mới nhất (Lambda v2.x runtime và S3 event filters), S3 có thể trigger Lambda trực tiếp qua event notification, nhưng bắt buộc cần Lambda resource policy với principal "s3.amazonaws.com" và action lambda:InvokeFunction. Không có thay đổi lớn từ 2023-2026.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: The resource-based policy for the Lambda function does not have the required permissions to be invoked by Amazon S3.
Lý do: Khi test bằng CLI, Lambda chạy với quyền IAM của developer, nên thành công. Nhưng S3 event notification invoke Lambda qua service principal s3.amazonaws.com, yêu cầu resource-based policy (permissions trên Lambda resource) phải cho phép rõ ràng. Nếu thiếu policy này (ví dụ: statement với Effect: Allow, Principal: {"Service": "s3.amazonaws.com"}, Action: "lambda:InvokeFunction"), Lambda sẽ từ chối invoke. Đây là nguyên nhân phổ biến nhất, đặc biệt với file lớn (nhưng size không ảnh hưởng).
📘 Nguồn tham khảo:
- AWS Lambda Resource-based Policy (cập nhật 2025).
- Grant Amazon S3 permissions to your Lambda function.
📋 Giải thích tất cả các phương án (đúng/sai)
Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh:
-
❌ The S3 event notification does not activate for files that are larger than 1,000 MB.
Sai vì: S3 event notifications không có giới hạn kích thước file (hỗ trợ lên đến hàng TB). Event kích hoạt dựa trên prefix/suffix hoặc filter size (>50MB như mô tả), file 3GB vẫn trigger bình thường. Không có quy định 1.000 MB trong AWS docs. -
✅ The resource-based policy for the Lambda function does not have the required permissions to be invoked by Amazon S3.
Đúng vì: Như giải thích ở trên, đây là yêu cầu bắt buộc cho cross-service invoke. Developer test CLI không cần policy này, dẫn đến bỏ sót. Có thể fix bằng CLI:aws lambda add-permission --function-name my-function --statement-id s3 --action lambda:InvokeFunction --principal s3.amazonaws.com --source-arn arn:aws:s3:::my-bucket. -
❌ Lambda functions cannot be invoked directly from an S3 event.
Sai vì: Lambda hỗ trợ invoke trực tiếp từ S3 event notifications (tích hợp native từ 2015, ổn định đến 2026). Đây là best practice cho serverless processing, không cần trung gian như EventBridge. -
❌ The S3 bucket needs to be made public.
Sai vì: S3 event notifications hoạt động với private bucket (chỉ cần IAM policy đúng). Public bucket không liên quan đến trigger Lambda, và khuyến nghị giữ private để bảo mật. Upload file lớn vẫn private qua presigned URL hoặc SDK.
🧩 Mẹo DevOps: Để tránh lỗi tương tự, luôn dùng AWS SAM/CloudFormation deploy Lambda với permission tự động, và test end-to-end với file lớn qua S3 console hoặc SDK!
Which service would best accomplish this task?
- A AWS CodeDeploy
- B AWS CloudFormation
- C AWS OpsWorks
- D AWS Elastic Beanstalk
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 một lập trình viên đang phát triển ứng dụng Ruby và cần một dịch vụ AWS để tự động hóa việc triển khai (deployment), mở rộng quy mô (scaling), và quản lý môi trường mà không cần kiến thức về hạ tầng bên dưới (underlying infrastructure).
✅ Yêu cầu chính: Đây là mô tả điển hình của một nền tảng PaaS (Platform as a Service), nơi developer chỉ cần upload code và cấu hình ứng dụng, AWS sẽ xử lý toàn bộ server, load balancer, auto-scaling, monitoring... mà không cần quản lý EC2 instances hay networking thủ công. Ứng dụng Ruby được hỗ trợ tốt trên các PaaS của AWS, phù hợp với DevOps best practices (theo AWS Well-Architected Framework 2023+).
🛠️ Bối cảnh cập nhật 2026: AWS Elastic Beanstalk (và các PaaS tương tự) tiếp tục là lựa chọn hàng đầu cho developer-centric workflows, với tích hợp sâu Amazon Corretto (Ruby runtime cập nhật), enhanced VPC support, và Graviton processors cho hiệu suất cao hơn (AWS re:Invent 2025 announcements).
✅ Đáp án đúng: AWS Elastic Beanstalk
Lý do chọn đáp án này:
AWS Elastic Beanstalk là dịch vụ PaaS lý tưởng cho developer, tự động hóa toàn bộ quy trình deploy, scale, và manage môi trường cho ứng dụng Ruby (hỗ trợ Ruby 3.2+ qua platform versions mới nhất). Developer chỉ cần upload code (zip file hoặc Git), chọn platform Ruby, và Beanstalk sẽ provision EC2, ELB, Auto Scaling Group, RDS... mà không cần biết chi tiết infra. Nó xử lý health checks, rolling updates, và multi-AZ deployments tự động.
📘 Nguồn tham khảo: AWS Elastic Beanstalk Documentation (Ruby Platforms: https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-ruby.html) và AWS DOP-C02 Exam Guide (Domain 2: Deployment).
📋 Giải thích tất cả các phương án (đúng/sai)
Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá dựa trên khả năng đáp ứng tự động hóa mà không cần kiến thức infra:
-
AWS CodeDeploy
❌ Sai: Đây là dịch vụ chỉ tập trung vào deployment code lên các tài nguyên đã tồn tại (như EC2, Lambda, ECS), sử dụng appspec.yml cho hooks. Nó không tự động provision, scale, hay manage infra – developer vẫn phải setup EC2/ASG thủ công trước. Không phù hợp cho Ruby app full-lifecycle mà không biết infra. -
AWS CloudFormation
❌ Sai: Đây là dịch vụ IaC (Infrastructure as Code) để define và provision tài nguyên qua templates (JSON/YAML). Developer phải biết chi tiết infra (EC2, VPC, IAM...) để viết stack, không tự động hóa deployment/scaling app-level. Phù hợp IaC nhưng không phải PaaS cho developer Ruby đơn giản. -
AWS OpsWorks
❌ Sai: Dịch vụ quản lý Chef/Puppet configurations cho stacks (EC2 layers), hỗ trợ auto-scaling nhưng yêu cầu kiến thức infra sâu để setup layers, instances, và cookbooks. Không phải PaaS thuần túy; đã deprecated một phần (OpsWorks Stacks vẫn active nhưng khuyến nghị ECS/Fargate hơn theo AWS 2025 migration guide). -
AWS Elastic Beanstalk
✅ Đúng: Như đã giải thích, đây là PaaS hoàn hảo, tự động hóa toàn bộ (deploy via EB CLI/EB Console, auto-scale dựa metrics, manage via environments). Hỗ trợ Ruby gems, Passenger/Nginx, và tích hợp CodePipeline. Không cần infra knowledge – chỉ focus code!
🛠️ Ưu điểm nổi bật 2026: Tích hợp Amazon Q Developer cho code suggestions và enhanced security (IMDSv2 default).
🔥 Kết luận: Elastic Beanstalk là lựa chọn best fit cho developer Ruby theo nguyên tắc "developer productivity first" trong AWS DevOps Professional (DOP-C02). Nếu cần hybrid, kết hợp với CodePipeline cho CI/CD!
The application recently demonstrated unexpected behavior. A developer examines the Lambda function code, finds an error, and modifies the code to resolve the problem. Before deploying the change to production, the developer needs to run tests to validate that the application operates properly.
The application has only a production environment available. The developer must create a new development environment to test the code changes. The developer must also prevent other developers from overwriting these changes during the test cycle.
Which combination of steps will meet these requirements with the LEAST development effort? (Choose two.)
- A Create a new resource in the current stage. Create a new method with Lambda proxy integration. Select the Lambda function. Add the hotfix alias. Redeploy the current stage. Test the backend.
- B Update the Lambda function in the API Gateway API integration request to use the hotfix alias. Deploy the API Gateway API to a new stage named hotfix. Test the backend.
- C Modify the Lambda function by fixing the code. Test the Lambda function. Create the alias hotfix. Point the alias to the $LATEST version.
- D Modify the Lambda function by fixing the code. Test the Lambda function. When the Lambda function is working as expected, publish the Lambda function as a new version. Create the alias hotfix. Point the alias to the new version.
- E Create a new API Gateway API for the development environment. Add a resource and method with Lambda integration. Choose the Lambda function and the hotfix alias. Deploy to a new stage. Test the backend.
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 ứng dụng web trên AWS sử dụng Amazon API Gateway làm frontend và AWS Lambda làm backend. Ứng dụng gặp lỗi bất ngờ, developer đã sửa code Lambda để khắc phục. Trước khi deploy lên production, cần tạo môi trường development mới để test thay đổi, đồng thời ngăn chặn các developer khác ghi đè (overwrite) thay đổi này trong quá trình test.
📌 Yêu cầu chính:
- Chỉ có môi trường production hiện tại.
- Giải pháp phải dùng ít effort phát triển nhất (LEAST development effort).
- Chọn TWO steps kết hợp.
🛠️ Giải pháp lý tưởng theo best practices AWS (cập nhật đến 2026): Sử dụng Lambda versions và aliases để cô lập code hotfix (không ảnh hưởng $LATEST), kết hợp API Gateway stages để tạo môi trường test riêng (không ảnh hưởng stage production). Điều này đảm bảo tính immutable, an toàn và ít thay đổi nhất.
✅ Đáp án đúng (Chọn TWO)
Hai phương án đúng là:
- Update the Lambda function in the API Gateway API integration request to use the hotfix alias. Deploy the API Gateway API to a new stage named hotfix. Test the backend.
- Modify the Lambda function by fixing the code. Test the Lambda function. When the Lambda function is working as expected, publish the Lambda function as a new version. Create the alias hotfix. Point the alias to the new version.
Lý do lựa chọn 🏆:
- Kết hợp này tạo môi trường test hotfix hoàn chỉnh với least effort: Fix code → Publish version mới (immutable) → Tạo alias
hotfixchỉ point vào version đó (ngăn overwrite từ $LATEST). Sau đó, update integration của API Gateway hiện tại để dùng alias này, deploy sang stage mới "hotfix" (không chạm production). Test độc lập, dễ rollback. - Tuân thủ AWS Well-Architected Framework (Reliability Pillar): Sử dụng versions/aliases cho safe deployment, stages cho multi-env.
📋 Phân tích chi tiết từng phương án
-
❌ Create a new resource in the current stage. Create a new method with Lambda proxy integration. Select the Lambda function. Add the hotfix alias. Redeploy the current stage. Test the backend.
Sai vì: Tạo resource/method mới trong stage hiện tại (production) và redeploy sẽ ảnh hưởng trực tiếp đến production, vi phạm yêu cầu không deploy hotfix lên prod trước khi test. Không tạo môi trường dev riêng, effort cao hơn (thêm resource/method). -
✅ Update the Lambda function in the API Gateway API integration request to use the hotfix alias. Deploy the API Gateway API to a new stage named hotfix. Test the backend.
Đúng vì: Với aliashotfixđã có (từ bước publish version), chỉ cần update integration request của API hiện tại để dùng alias (không tạo API mới), rồi deploy sang stage "hotfix" mới. Tạo env test riêng nhanh chóng, least effort, không ảnh hưởng prod. Test backend qua stage này. -
❌ Modify the Lambda function by fixing the code. Test the Lambda function. Create the alias hotfix. Point the alias to the $LATEST version.
Sai vì: Point alias vào $LATEST (unversioned qualifier) không an toàn – bất kỳ ai update code Lambda sẽ thay đổi $LATEST, dẫn đến overwrite hotfix. Không đảm bảo immutability, vi phạm yêu cầu ngăn chặn overwrite. -
✅ Modify the Lambda function by fixing the code. Test the Lambda function. When the Lambda function is working as expected, publish the Lambda function as a new version. Create the alias hotfix. Point the alias to the new version.
Đúng vì: Fix code → Test → Publish version mới (immutable snapshot) → Tạo aliashotfixpoint chính xác vào version đó. Ngăn overwrite hoàn toàn (vì version không thay đổi), chuẩn bị cho API Gateway integration. Least effort cho Lambda side. -
❌ Create a new API Gateway API for the development environment. Add a resource and method with Lambda integration. Choose the Lambda function and the hotfix alias. Deploy to a new stage. Test the backend.
Sai vì: Tạo API Gateway mới đòi hỏi replicate toàn bộ resources/methods/integrations (effort cao), không cần thiết khi có thể reuse API hiện tại + stages. Không phải "least development effort".
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS Lambda Versions & Aliases: docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html – Giải thích publish version và aliases cho safe testing.
- API Gateway Stages & Deployments: docs.aws.amazon.com/apigateway/latest/developerguide/stages.html – Tạo stage mới để multi-env mà không ảnh hưởng prod.
- AWS Well-Architected: Deployment Strategies: aws.amazon.com/architecture/well-architected – Khuyến nghị aliases + stages cho hotfix/blue-green.
- Exam Topic DOP-C02: Phần Lambda & API Gateway integration (Certified DevOps Engineer Professional).
💡 Mẹo thi: Tập trung immutable deployments (versions/aliases) + stages để least operational overhead! 🚀
How can the developer test a specific Lambda function locally?
- A Run the sam package and sam deploy commands. Create a Lambda test event from the AWS Management Console. Test the Lambda function.
- B Run the cdk synth and cdk deploy commands. Create a Lambda test event from the AWS Management Console. Test the Lambda function.
- C Run the cdk synth and sam local invoke commands with the function construct identifier and the path to the synthesized CloudFormation template.
- D Run the cdk synth and sam local start-lambda commands with the function construct identifier and the path to the synthesized CloudFormation template.
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 test local (trên máy tính cá nhân của developer) một Lambda function cụ thể trong ứng dụng serverless được xây dựng bằng AWS Cloud Development Kit (AWS CDK). Ứng dụng bao gồm nhiều AWS Lambda functions và Amazon API Gateway APIs, được provision qua AWS CloudFormation stack. Workstation của developer đã cài sẵn AWS SAM (Serverless Application Model) và AWS CDK, cho phép kết hợp cả hai công cụ.
🔍 Mục tiêu chính: Không deploy lên AWS mà test local để nhanh chóng debug code Lambda mà không cần tạo stack thực tế. Điều này tận dụng SAM CLI (phần của AWS SAM) để mô phỏng môi trường Lambda local từ CloudFormation template được sinh ra bởi CDK (qua lệnh cdk synth). Đây là best practice cho development workflow hybrid CDK + SAM, giúp tiết kiệm thời gian và chi phí (không cần AWS resources thật).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Run the cdk synth and sam local invoke commands with the function construct identifier and the path to the synthesized CloudFormation template.
Lý do chi tiết 🛠️:
cdk synthsinh ra CloudFormation template (file YAML/JSON, ví dụ:cdk.out/StackName.template.json) chứa định nghĩa đầy đủ các Lambda functions dưới dạng constructs (identifier là tên construct nhưMyStack/MyLambdaFunction).- Sau đó, dùng
sam local invoke <function-name> -t <path-to-template>để invoke Lambda local với event JSON tùy chỉnh, mô phỏng chính xác runtime AWS Lambda (bao gồm layers, env vars, IAM roles từ template). - Workflow này hoàn hảo cho CDK apps vì CDK không có built-in local invoke (như SAM thuần), nhưng kết hợp SAM CLI siêu hiệu quả. Đáp án này test specific function mà không ảnh hưởng toàn stack, phù hợp phiên bản mới nhất CDK v2 (2024-2026) và SAM CLI v1.XX.
📋 Phân tích tất cả các phương án
Dưới đây là phân tích từng lựa chọn một cách chi tiết. Tôi giữ nguyên nội dung văn bản gốc bằng tiếng Anh, chỉ giải thích bằng tiếng Việt với lý do đúng/sai dựa trên docs AWS mới nhất (SAM CLI 1.115.0+, CDK 2.140+ đến 2026).
-
[SAI] Run the sam package and sam deploy commands. Create a Lambda test event from the AWS Management Console. Test the Lambda function.
❌ Phân tích sai: Các lệnhsam packagevàsam deploydùng cho SAM app thuần (template sam.yaml), không phải CDK (CDK dùngcdk deploy). Chúng deploy lên AWS thật, không test local. Test qua Console chỉ chạy trên Lambda thật (sau deploy), vi phạm yêu cầu local test. Không hiệu quả cho CDK workflow. -
[SAI] Run the cdk synth and cdk deploy commands. Create a Lambda test event from the AWS Management Console. Test the Lambda function.
❌ Phân tích sai:cdk synthđúng (tạo template), nhưngcdk deploydeploy toàn stack lên AWS, không local. Test Console yêu cầu resources thật tồn tại trên AWS, tốn thời gian/chi phí và không phải "local" trên workstation. CDK không hỗ trợ local invoke native, nên không phù hợp. -
[ĐÚNG] Run the cdk synth and sam local invoke commands with the function construct identifier and the path to the synthesized CloudFormation template.
✅ Phân tích đúng 🧪: Hoàn hảo!cdk synthtạo template chứa construct IDs (ví dụ:stack-name/function-name).sam local invokedùng-t <template-path> --function-id <construct-id>(nhưMyStack/MyFunction) để chạy Lambda local với event tùy chỉnh (file JSON). Hỗ trợ full features: Docker runtime, VPC, layers, secrets. Ví dụ lệnh:sam local invoke MyFunction -t cdk.out/MyStack.template.json -e event.json. Đây là recommended hybrid approach trong docs AWS 2024-2026. -
[SAI] Run the cdk synth and sam local start-lambda commands with the function construct identifier and the path to the synthesized CloudFormation template.
❌ Phân tích sai:sam local start-lambdadùng cho persistent Lambda container (chạy daemon để invoke nhiều lần qua port, thường cho API Gateway local), không phải single invoke một function cụ thể. Nó yêu cầu thêm flags như--port, phù hợpsam local start-apihơn. Không tối ưu cho test nhanh một Lambda đơn lẻ như yêu cầu.
📘 Tài liệu tham khảo (cập nhật mới nhất đến 2026)
- AWS SAM CLI Local Invoke: docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-local-invoke.html – Chi tiết
--function-idcho CDK templates. - CDK với SAM Local Testing: aws.amazon.com/blogs/compute/using-aws-sam-local-with-aws-cdk/ & CDK Workshop: cdkworkshop.com (phần local testing).
- SAM CLI Release Notes 2026: github.com/aws/aws-sam-cli/releases – Xác nhận hỗ trợ CDK constructs đầy đủ.
- Best Practices DevOps: AWS Well-Architected Framework – Reliability Pillar (local testing giảm MTTR).
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 CDK, hỏi thêm nhé!
What is the SIMPLEST solution for the developer to use for rolling out the new API version to a limited number of users through API Gateway?
- A Create a new API in API Gateway. Direct a portion of the traffic to the new API using an Amazon Route 53 weighted routing policy.
- B Validate the new API version and promote it to production during the window of lowest expected utilization.
- C Implement an Amazon CloudWatch alarm to trigger a rollback if the observed HTTP 500 status code rate exceeds a predetermined threshold.
- D Use the canary release deployment option in API Gateway. Direct a percentage of the API traffic using the canarySettings setting.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi tập trung vào Amazon API Gateway trong bối cảnh một ứng dụng di động (mobile app) của công ty đang phát triển phiên bản API mới. Khi team phát triển hoàn tất release mới, developer cần rollout thay đổi API một cách an toàn (safely) và minh bạch (transparently), cụ thể là triển khai phiên bản API mới chỉ đến một số lượng user hạn chế (limited number of users).
🔍 Yêu cầu chính: Tìm giải pháp đơn giản nhất (SIMPLEST solution) sử dụng API Gateway để thực hiện việc này. Đây là tình huống điển hình trong DevOps, nhằm giảm rủi ro bằng cách kiểm tra dần dần (progressive rollout) mà không ảnh hưởng toàn bộ người dùng. Kiến thức dựa trên phiên bản AWS mới nhất (2026), nơi API Gateway hỗ trợ các tính năng deployment nâng cao như canary releases để đảm bảo blue-green hoặc canary deployments mượt mà.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Use the canary release deployment option in API Gateway. Direct a percentage of the API traffic using the canarySettings setting.
Lý do chi tiết 🛠️:
- Đây là giải pháp đơn giản nhất vì canary release là tính năng built-in của API Gateway (từ năm 2019 và được cập nhật liên tục đến 2026). Nó cho phép developer tạo một deployment stage mới với cài đặt
canarySettingsđể chỉ định % traffic (ví dụ: 10%) được chuyển hướng đến phiên bản API mới, trong khi phần còn lại vẫn dùng version cũ. - An toàn & minh bạch: Traffic được phân bổ tự động dựa trên weighted routing nội bộ, có metrics theo dõi qua CloudWatch, dễ rollback nếu có vấn đề. Không cần tool ngoài, chỉ dùng console/CLI/SDK.
- Phù hợp với "limited users" vì dựa trên traffic ratio, không cần DNS hay can thiệp phức tạp.
📋 Phân tích tất cả các phương án
Dưới đây là phân tích từng phương án một cách chi tiết, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá đúng/sai dựa trên tính đơn giản, an toàn và phù hợp với API Gateway.
-
Phương án SAI ❌:
Create a new API in API Gateway. Direct a portion of the traffic to the new API using an Amazon Route 53 weighted routing policy.
Giải thích sai: Phương án này phức tạp hơn cần thiết vì phải tạo API hoàn toàn mới (không dùng cùng một API), rồi dùng Route 53 weighted policy để split traffic – điều này yêu cầu quản lý DNS riêng, custom domain, và không minh bạch trong API Gateway. Không phải "SIMPLEST" vì thêm layer ngoài (Route 53), dễ lỗi sync và không tận dụng native canary của Gateway. (Không phù hợp best practice AWS 2026). -
Phương án SAI ❌:
Validate the new API version and promote it to production during the window of lowest expected utilization.
Giải thích sai: Đây chỉ là big bang deployment thủ công (deploy toàn bộ vào production lúc low traffic), không an toàn vì không có cơ chế split traffic đến "limited users". Nếu lỗi, toàn bộ production bị ảnh hưởng. Không minh bạch, thiếu metrics tự động, và không phải giải pháp DevOps hiện đại cho API Gateway. -
Phương án SAI ❌:
Implement an Amazon CloudWatch alarm to trigger a rollback if the observed HTTP 500 status code rate exceeds a predetermined threshold.
Giải thích sai: Phương án này chỉ là monitoring & rollback sau sự cố, không giải quyết rollout ban đầu đến limited users. CloudWatch alarm hữu ích cho safety net nhưng phải kết hợp deployment method khác (như manual), làm phức tạp hóa. Không "SIMPLEST" vì thiếu cơ chế traffic shifting native trong API Gateway. -
Phương án ĐÚNG ✅:
Use the canary release deployment option in API Gateway. Direct a percentage of the API traffic using the canarySettings setting.
Giải thích đúng: Như đã nêu ở phần trên, đây là native feature đơn giản nhất, hỗ trợcanarySettings(percent traffic, interval, data retention) qua CLI (aws apigateway create-deployment --rest-api-id <id> --stage-name prod --canary-settings '{"percentTraffic":10,"stageVariableOverrides":{"version":"v2"}}'). Theo dõi qua CloudWatch/ X-Ray, dễ scale đến 2026 với integration Lambda/ECS.
📘 Tài liệu tham khảo
- AWS Docs chính thức (cập nhật 2026): Canary release deployments in API Gateway – Chi tiết
canarySettings. - AWS Well-Architected Framework (DevOps Pillar): API Gateway Deployment Best Practices.
- AWS re:Post & Exam Prep: DOP-C02 blueprint về API management (Blue/Green & Canary).
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 CLI, hãy hỏi thêm.
What is the simplest way to do this?
- A Write a script that deletes old records; schedule the script as a cron job on an Amazon EC2 instance.
- B Add an attribute with the expiration time; enable the Time To Live feature based on that attribute.
- C Each day, create a new table to hold session data; delete the previous day's table.
- D Add an attribute with the expiration time; name the attribute ItemExpiration.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi tập trung vào một công ty đang sử dụng Amazon DynamoDB để lưu trữ thông tin session cho ứng dụng web (caching session information). Họ muốn tìm cách đơn giản nhất (simplest way) để tự động xóa (delete) các item cũ trong bảng DynamoDB mà không cần can thiệp thủ công.
📌 Vấn đề cốt lõi: DynamoDB là NoSQL database serverless, tối ưu cho throughput cao, nhưng cần cơ chế tự động dọn dẹp dữ liệu cũ (như session hết hạn) để tiết kiệm chi phí lưu trữ và hiệu suất. Giải pháp phải tự động hóa hoàn toàn, dễ triển khai, và phù hợp với best practices của AWS (cập nhật đến 2026, TTL vẫn là tính năng core của DynamoDB).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Add an attribute with the expiration time; enable the Time To Live feature based on that attribute.
Lý do chi tiết 🛠️:
- Đây là cách đơn giản nhất vì Time to Live (TTL) là tính năng native của DynamoDB, serverless và tự động 100%. Bạn chỉ cần:
- Thêm một attribute (tên tùy ý, kiểu Number hoặc String) chứa Unix epoch timestamp (giây) khi item hết hạn.
- Enable TTL trên table qua AWS Console, CLI, hoặc CDK/Terraform, chỉ định tên attribute đó.
- DynamoDB sẽ tự động xóa item trong vòng 48 giờ sau timestamp (không chính xác giây, nhưng gần real-time).
- Ưu điểm: Zero code, không tốn EC2/Lambda, tiết kiệm chi phí (chỉ tính WRU/RWU), scale tự động. Phù hợp DevOps với IaC.
- Cập nhật 2026: TTL hỗ trợ point-in-time recovery và Global Tables (multi-region).
📋 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 văn bản gốc tiếng Anh của phương án, chỉ giải thích bằng tiếng Việt với lý do đúng/sai dựa trên best practices AWS.
-
❌ SAI: Write a script that deletes old records; schedule the script as a cron job on an Amazon EC2 instance.
Giải thích: Cách này không đơn giản vì yêu cầu quản lý EC2 (provision, patch, scale), viết script scan/query/delete (tốn RCU/WCU lớn), và cron job thủ công. Dễ lỗi (throttle, cost overrun), không serverless. Phù hợp legacy, nhưng vi phạm nguyên tắc "simplest" và Well-Architected Framework (Operational Excellence). -
✅ ĐÚNG: Add an attribute with the expiration time; enable the Time To Live feature based on that attribute.
Giải thích: Như đã nêu ở trên, đây là giải pháp native, zero-maintenance. Attribute tên tùy ý (ví dụ:ttlhoặcexpiresAt), enable TTL quaUpdateTimeToLiveAPI. DynamoDB xử lý background delete miễn phí (không tính phí delete). -
❌ SAI: Each day, create a new table to hold session data; delete the previous day's table.
Giải thích: Phức tạp và lãng phí cực độ! Tạo/xóa table hàng ngày tốn thời gian (provisioned capacity, indexes), không hỗ trợ session real-time (data migration), vi phạm single table design của DynamoDB. Cost cao (table creation fees), không scale cho high-traffic web app. -
❌ SAI: Add an attribute with the expiration time; name the attribute ItemExpiration.
Giải thích: Gần đúng nhưng sai tên attribute. Theo docs AWS, khi enable TTL, bạn chỉ định tên attribute tùy ý (không bắt buộc "ItemExpiration"). Tên này không chuẩn, có thể gây nhầm lẫn với IAM policy hoặc custom logic. Phải enable TTL explicitly với tên chính xác bạn chọn – chỉ thêm attribute thôi chưa đủ.
📘 Tài liệu tham khảo (AWS Official Docs - cập nhật 2026)
- DynamoDB TTL Guide: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ttl-howitworks.html – Chi tiết cách enable, attribute requirements.
- AWS Well-Architected Framework (Reliability Pillar): Khuyến nghị TTL cho auto-cleanup.
- Exam Tip (DOP-C02): TTL thường là đáp án "simplest automated" cho DynamoDB cleanup.
Hy vọng phân tích này giúp bạn ôn thi AWS DevOps Professional hiệu quả! 🚀 Nếu cần demo code CDK enable TTL, hỏi thêm nhé!
How can a developer meet these requirements without changing the configuration of the SCM system?
- A Deploy the API Gateway REST API to all the required AWS accounts. Use the same custom domain name for all the gateway endpoints so that a single SCM webhook can be used for all events from all accounts.
- B Deploy the API Gateway REST API to all the receiver AWS accounts. Create as many SCM webhooks as the number of AWS accounts.
- C Grant permission to the central AWS account for EventBridge to access the receiver AWS accounts. Add an EventBridge event bus on the receiver AWS accounts as the targets to the existing EventBridge rule.
- D Convert the API Gateway type from REST API to HTTP API.
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 kiến trúc Event-Driven trên AWS, cụ thể là cách xử lý sự kiện (events) từ hệ thống SCM on-premises thông qua Amazon API Gateway REST API làm webhook, đẩy events vào Amazon EventBridge ở một central AWS account. Một EventBridge rule đã được cấu hình ở central account để kiểm soát deployment ứng dụng. Yêu cầu chính: Lan tỏa cùng một events đến nhiều receiver AWS accounts (các tài khoản nhận sự kiện khác), mà KHÔNG thay đổi cấu hình SCM system (tức là giữ nguyên single webhook endpoint từ SCM).
🔍 Chi tiết vấn đề:
- SCM on-premises gửi webhook đến một API Gateway endpoint duy nhất ở central account.
- Events được đẩy vào EventBridge bus ở central account.
- Cần replicate events đến EventBridge bus ở các receiver accounts để chúng có thể xử lý độc lập (ví dụ: deployment riêng).
- Ràng buộc: Không modify SCM (không tạo thêm webhook), tận dụng kiến trúc multi-account hiện đại của AWS (cross-account EventBridge).
📘 Kiến thức AWS cập nhật 2026: EventBridge hỗ trợ cross-account event routing qua resource-based policies trên event bus ở receiver accounts, cho phép central account's EventBridge put events trực tiếp vào bus của receiver mà không cần thay đổi source (API Gateway/SCM). Điều này tuân thủ EventBridge Partner Event Sources và custom buses (AWS EventBridge User Guide, phiên bản mới nhất).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Grant permission to the central AWS account for EventBridge to access the receiver AWS accounts. Add an EventBridge event bus on the receiver AWS accounts as the targets to the existing EventBridge rule.
Lý do 🛠️:
- Từ central account, chỉnh sửa EventBridge rule hiện tại để thêm targets là EventBridge buses ở các receiver accounts.
- Trên mỗi receiver account, tạo EventBridge bus (custom bus) và attach resource policy (event bus policy) grant quyền
events:PutEventscho principal từ central account (ARN của EventBridge service role hoặc account root). - Events từ SCM → API Gateway → Central EventBridge bus → Rule targets → Cross-account put vào receiver buses.
- ✅ Đúng yêu cầu: Không thay đổi SCM/API Gateway (single webhook), hỗ trợ multi-account scaling, zero-downtime.
- Hiệu suất cao: EventBridge tự động replicate events asynchronously, hỗ trợ lên đến 1000 targets/rule (tăng từ 2024).
📋 Giải thích tất cả các phương án
-
Grant permission to the central AWS account for EventBridge to access the receiver AWS accounts. Add an EventBridge event bus on the receiver AWS accounts as the targets to the existing EventBridge rule.
✅ Đúng (như giải thích trên). 🏆 Phương án tối ưu, native cross-account của EventBridge, không cần code thay đổi. -
Deploy the API Gateway REST API to all the required AWS accounts. Use the same custom domain name for all the gateway endpoints so that a single SCM webhook can be used for all events from all accounts.
❌ Sai. 🧨 Không khả thi vì custom domain name (qua Route53 hoặc ACM) phải unique per region/account; không thể share cùng domain cho multiple API Gateways cross-account mà không conflict DNS. SCM chỉ gửi đến 1 endpoint, events sẽ không replicate đúng. Phức tạp, tốn kém (multi-deploy), vi phạm no-change SCM. -
Deploy the API Gateway REST API to all the receiver AWS accounts. Create as many SCM webhooks as the number of AWS accounts.
❌ Sai. 🚫 Trực tiếp vi phạm yêu cầu "without changing the configuration of the SCM system" vì phải tạo nhiều webhooks ở SCM (một cho mỗi account), dẫn đến config thay đổi lớn. -
Convert the API Gateway type from REST API to HTTP API.
❌ Sai. 🤔 Không liên quan: HTTP API chỉ rẻ hơn, nhanh hơn REST API (payload up to 10MB vs 6MB), nhưng không giải quyết multi-account replication. Vẫn cần single endpoint, không hỗ trợ cross-account events tự động.
📚 Tài liệu tham khảo
- AWS EventBridge Cross-Account Events: docs.aws.amazon.com/eventbridge/latest/userguide/eb-cross-account.html (Cross-account targets via bus policies).
- API Gateway Webhooks: docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-enable-cors-integration.html (REST API cho webhook).
- EventBridge Best Practices Multi-Account: AWS Well-Architected Framework - Reliability Pillar (2025 update), khuyến nghị cross-bus routing cho central event ingestion.
Hy vọng phân tích này giúp bạn ôn thi DOP-C02 hiệu quả! 🚀 Nếu cần lab thực hành, dùng AWS Console để test cross-account policy.
Which AWS feature should the company use to share and access the files securely?
- A Amazon Cognito user pool
- B S3 presigned URLs
- C S3 bucket policy
- D Amazon Cognito identity pool
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi mô tả tình huống một công ty đã chuyển các file bảo mật vào Amazon S3 bucket riêng tư (private) với không có quyền truy cập công khai (no public access). Công ty muốn xây dựng ứng dụng serverless cho phép nhân viên đăng nhập và chia sẻ file an toàn với người dùng khác.
🔍 Yêu cầu chính: Tìm tính năng AWS phù hợp để chia sẻ và truy cập file một cách bảo mật.
- Bucket private nên không thể truy cập trực tiếp qua public URL.
- Cần cơ chế tạm thời, an toàn (không mở bucket public), phù hợp serverless (không server quản lý).
- Nhân viên cần xác thực (login) trước khi generate link share.
🛠️ Bối cảnh AWS: Sử dụng kiến thức cập nhật đến 2026 (AWS S3 phiên bản mới nhất hỗ trợ presigned URLs với thời hạn linh hoạt lên đến 7 ngày qua SDK/API v3, tích hợp IAM fine-grained access).
✅ Đáp án đúng: S3 presigned URLs
Lý do chọn:
S3 presigned URLs là cách tốt nhất để chia sẻ file từ private bucket một cách tạm thời và bảo mật. Nhân viên (sau khi login qua app serverless như API Gateway + Lambda + Cognito) có thể generate URL có chữ ký số (signed) với quyền cụ thể (GET/PUT), thời hạn hết hạn (ví dụ: 1 giờ). Người nhận chỉ cần click URL để download mà không cần AWS account, không làm bucket public. Hoàn hảo cho serverless, tránh rủi ro vĩnh viễn.
📈 Ưu điểm nổi bật: Tích hợp dễ với SDK (JavaScript/Python), kiểm soát granular qua IAM policy của người generate.
📋 Phân tích tất cả các phương án
Dưới đây là phân tích chi tiết từng lựa chọn, đánh dấu đúng/sai rõ ràng:
-
❌ Amazon Cognito user pool
Sai vì: Cognito User Pool chỉ dùng cho xác thực người dùng (authentication) như đăng nhập, tạo user directory (email/password/OIDC). Nó không trực tiếp chia sẻ file S3. Cần kết hợp thêm (như với Identity Pool hoặc Lambda), nhưng không phải giải pháp cốt lõi cho "share files securely". Không phù hợp standalone cho yêu cầu. -
✅ S3 presigned URLs
Đúng vì: Như giải thích trên, đây là cơ chế chuẩn AWS để cấp quyền tạm thời truy cập private object mà không thay đổi bucket policy hay public access. Serverless app dùng Lambda generate URL sau auth, đảm bảo an toàn cao (hết hạn tự động, chống replay attack). Best practice theo AWS Well-Architected Framework (Security Pillar). -
❌ S3 bucket policy
Sai vì: Bucket policy kiểm soát quyền vĩnh viễn/toàn cục trên bucket/object (dựa IP/principal/condition). Để share với "other users" cần policy phức tạp (ví dụ: allow specific emails), dễ lỗi bảo mật, không tạm thời, và không phù hợp serverless sharing cá nhân hóa. Bucket private nên policy càng khó scale cho many users. -
❌ Amazon Cognito identity pool
Sai vì: Identity Pool dùng cho xác thực hóa (authorization), map user (từ User Pool) sang IAM roles để truy cập AWS services (như S3). Nó giúp nhân viên access file sau login, nhưng không tạo link share cho người ngoài (external users). Người nhận vẫn cần AWS credentials, không đơn giản cho "share with other users".
📘 Tài liệu tham khảo
- AWS S3 Presigned URLs: Sharing objects using presigned URLs (Cập nhật 2024-2026, hỗ trợ SDK v3 với TTL dài hơn).
- Cognito User/Identity Pools: Amazon Cognito Developer Guide.
- S3 Security Best Practices: AWS Security Best Practices for S3 (Khuyến nghị presigned cho temporary access).
- Exam Prep (DOP-C02): AWS Certified DevOps Engineer Professional Official Practice (Q&A tương tự về S3 secure sharing).
Hy vọng phân tích này giúp bạn nắm vững! 🚀 Nếu cần ví dụ code Lambda generate presigned URL, hỏi thêm nhé!