SCS-C02 练习题

SCS-C02 题目讲解:Secret endpoint 通,不代表数据库通

SCS-C02 练习题讲解。答案 B。日志是 setSecret unable to log into database,失败点在 Lambda→数据库登录。

SCS-C02 免费试练题 · 考证匠讲解

题目

A company is testing its incident response plan for compromised credentials. The company runs a database on an Amazon EC2 instance and stores the sensitive database credentials as a secret in AWS Secrets Manager. The secret has rotation configured with an AWS Lambda function that uses the generic rotation function template. The EC2 instance and the Lambda function are deployed in the same private subnet. The VPC has a Secrets Manager VPC endpoint. A security engineer discovers that the secret cannot rotate. The security engineer determines that the VPC endpoint is working as intended. The Amazon CloudWatch logs contain the following error: "setSecret: Unable to log into database". Which solution will resolve this error?

A. Use the AWS Management Console to edit the JSON structure of the secret in Secrets Manager so that the secret automatically conforms with the structure that the database requires.
B. Ensure that the security group that is attached to the Lambda function allows outbound connections to the EC2 instance. Ensure that the security group that is attached to the EC2 instance allows inbound connections from the security group that is attached to the Lambda function.
C. Use the Secrets Manager list-secrets command in the AWS CLI to list the secret. Identify the database credentials. Use the Secrets Manager rotate-secret command in the AWS CLI to force the immediate rotation of the secret.
D. Add an internet gateway to the VPC. Create a NAT gateway in a public subnet. Update the VPC route tables so that traffic from the Lambda function and traffic from the EC2 instance can reach the Secrets Manager public endpoint.

答案

答案 B。日志是 setSecret unable to log into database,失败点在 Lambda→数据库登录。

拆题

  • 日志是 setSecret unable to log into database,失败点在 Lambda→数据库登录。
  • 同 subnet 不会绕过 security groups;Lambda 出站与 EC2 入站要允许数据库端口。
  • 网络通后还需检查当前 secret、数据库用户权限和引擎配置,不能把所有登录失败都归为 SG。

每个选项为什么对、为什么错

  • A:修改 JSON 要依据真实格式错误,本题已指向数据库连接,不应任意改凭证字段。
  • B(正确):Lambda SG 出站与 DB EC2 SG 入站按源 SG 放行数据库端口,是最直接待查链路。
  • C:强制重试不会修复连通或认证问题,list-secrets 也不返回明文凭证。
  • D:现有 Secrets Manager endpoint 已正常,NAT 去公共 endpoint 绕路不修复数据库登录。

放到具体场景里

教学例子:Lambda 访问 Secrets Manager 成功,但访问 EC2 MySQL 3306 超时。数据库 SG 添加来源 rotation-lambda-sg 的 3306 规则,Lambda 出站允许目标。若后来日志变成 access denied for user,再检查账号与 current/pending secret,不继续扩大网络范围。

检查对象本例条件或动作结果与边界
服务读取Secrets Manager vpce已验证正常
数据库连接Lambda→EC2:3306双侧 SG
认证current/pending secret网络通后另查

遇到同类题的判断顺序

  1. 定位阶段:区分 getSecret 与 setSecret。
  2. 测试连接:检查端口和 SG。
  3. 验证凭证:确认数据库账户权限。
  4. 完成轮换:检查 staging labels 与应用登录。
结论:轮换需要秘密服务和数据库两条连接,不能只验收前一条。

参考资料

继续练这门考试

同一门考试的免费试练题都附这样的完整讲解,做完再看讲解。