SAP-C02 学习助手

SAP-C02 第 19 题

API Gateway Lambda CloudFront CloudWatch

题目

A company has a serverless application comprised of Amazon CloudFront, Amazon API Gateway, and AWS Lambda functions. The current deployment process of the application code is to create a new version number of the Lambda function and run an AWS CLI script to update. If the new function version has errors, another CLI script reverts by deploying the previous working version of the function. The company would like to decrease the time to deploy new versions of the application logic provided by the Lambda functions, and also reduce the time to detect and revert when errors are identified. How can this be accomplished?

中文翻译:
一家公司拥有一个由 Amazon CloudFront、Amazon API Gateway 和 AWS Lambda 函数组成的无服务器应用程序。应用程序代码的当前部署过程是创建 Lambda 函数的新版本号并运行 AWS CLI 脚本进行更新。如果新函数版本出现错误,另一个 CLI 脚本将通过部署该函数的先前工作版本来恢复。该公司希望减少部署 Lambda 函数提供的新版本应用程序逻辑的时间,并减少发现错误时检测和恢复的时间。如何才能做到这一点?

选项

A. Create and deploy nested AWS CloudFormation stacks with the parent stack consisting of the AWS CloudFront distribution and API Gateway, and the child stack containing the Lambda function. For changes to Lambda, create an AWS CloudFormation change set and deploy; if errors are triggered, revert the AWS CloudFormation change set to the previous version.

中文翻译:
创建和部署嵌套的 AWS CloudFormation 堆栈,其中父堆栈由 AWS CloudFront 分配和 API Gateway 组成,子堆栈包含 Lambda 函数。对于 Lambda 的更改,创建 AWS CloudFormation 更改集并部署;如果触发错误,请将 AWS CloudFormation 更改集恢复为之前的版本。

B. Use AWS SAM and built-in AWS CodeDeploy to deploy the new Lambda version, gradually shift traffic to the new version, and use pre-traffic and post-traffic test functions to verify code. Rollback if Amazon CloudWatch alarms are triggered.

中文翻译:
使用AWS SAM和内置的AWS CodeDeploy部署新的Lambda版本,逐步将流量转移到新版本,并使用流量前和流量后测试功能来验证代码。如果触发 Amazon CloudWatch 警报则回滚。

C. Refactor the AWS CLI scripts into a single script that deploys the new Lambda version. When deployment is completed, the script tests execute. If errors are detected, revert to the previous Lambda version.

中文翻译:
将 AWS CLI 脚本重构为部署新 Lambda 版本的单个脚本。部署完成后,将执行脚本测试。如果检测到错误,请恢复到之前的 Lambda 版本。

D. Create and deploy an AWS CloudFormation stack that consists of a new API Gateway endpoint that references the new Lambda version. Change the CloudFront origin to the new API Gateway endpoint, monitor errors and if detected, change the AWS CloudFront origin to the previous API Gateway endpoint.

中文翻译:
创建并部署一个 AWS CloudFormation 堆栈,其中包含引用新 Lambda 版本的新 API Gateway 终端节点。将 CloudFront 源更改为新的 API Gateway 终端节点,监控错误,如果检测到错误,则将 AWS CloudFront 源更改为之前的 API Gateway 终端节点。

答案

B

解析

正确答案:B 解析: 本题应选择 B。 正确选项: B. 使用AWS SAM和内置的AWS CodeDeploy部署新的Lambda版本,逐步将流量转移到新版本,并使用流量前和流量后测试功能来验证代码。如果触发 Amazon CloudWatch 警报则回滚。 选择理由: 该选项最直接地满足题干中的关键约束。做 SAP-C02 题目时,需要同时对照题干里的限定词,例如最高性能、最低运维开销、成本效益、可靠性、可扩展性、安全性、RTO/R...

登录后查看完整解析