SAP-C02 学习助手

SAP-C02 第 260 题

API Gateway Lambda CloudFront S3 EBS Config WAF

题目

A company runs an unauthenticated static website (www.example.com) that includes a registration form for users. The website uses Amazon S3 for hosting and uses Amazon CloudFront as the content delivery network with AWS WAF configured. When the registration form is submitted, the website calls an Amazon API Gateway API endpoint that invokes an AWS Lambda function to process the payload and forward the payload to an external API call. During testing, a solutions architect encounters a cross-origin resource sharing (CORS) error. The solutions architect confirms that the CloudFront distribution origin has the Access-Control-Allow-Origin header set to www.example.com. What should the solutions architect do to resolve the error?

中文翻译:
一家公司运行一个未经身份验证的静态网站 (www.example.com),其中包含用户注册表单。该网站使用 Amazon S3 进行托管,并使用 Amazon CloudFront 作为配置了 AWS WAF 的内容交付网络。提交注册表单后,网站会调用 Amazon API Gateway API 终端节点,该终端节点会调用 AWS Lambda 函数来处理负载并将负载转发到外部 API 调用。在测试期间,解决方案架构师遇到跨源资源共享 (CORS) 错误。解决方案架构师确认 CloudFront 分发源的 Access-Control-Allow-Origin 标头设置为 www.example.com。解决方案架构师应该如何解决该错误?

选项

A. Change the CORS configuration on the S3 bucket. Add rules for CORS to the AllowedOrigin element for www.example.com.

中文翻译:
更改 S3 存储桶上的 CORS 配置。将 CORS 规则添加到 www.example.com 的AllowedOrigin 元素。

B. Enable the CORS setting in AWS WAF. Create a web ACL rule in which the Access-Control-Allow-Origin header is set to www.example.com.

中文翻译:
在 AWS WAF 中启用 CORS 设置。创建一个 Web ACL 规则,其中 Access-Control-Allow-Origin 标头设置为 www.example.com。

C. Enable the CORS setting on the API Gateway API endpoint. Ensure that the API endpoint is configured to return all responses that have the Access-Control-Allow-Origin header set to www.example.com. www.example.com。

中文翻译:
在 API Gateway API 端点上启用 CORS 设置。确保 API 端点配置为返回 Access-Control-Allow-Origin 标头设置为 www.example.com 的所有响应。 www.example.com。

D. Enable the CORS setting on the Lambda function. Ensure that the return code of the function has the Access-Control-Allow- Origin header set to www.example.com.

中文翻译:
在 Lambda 函数上启用 CORS 设置。确保函数的返回代码的 Access-Control-Allow-Origin 标头设置为 www.example.com。

答案

C

解析

正确答案:C 解析: 本题应选择 C。 正确选项: C. 在 API Gateway API 端点上启用 CORS 设置。确保 API 端点配置为返回 Access-Control-Allow-Origin 标头设置为 www.example.com 的所有响应。 www.example.com。 选择理由: 该选项最直接地满足题干中的关键约束。做 SAP-C02 题目时,需要同时对照题干里的限定词,例如最高性能、最低运维开销、成本效益...

登录后查看完整解析