nerdexam
Amazon

SCS-C02 · Question #139

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…

The correct answer is B. Ensure that the security group that is attached to the Lambda function allows outbound. Option B is correct because the Lambda rotation function must connect directly to the database on the EC2 instance to update credentials - that's the "setSecret" step. Since the VPC endpoint is confirmed working (Lambda can already reach Secrets Manager), the bottleneck is…

Submitted by hans_de· Mar 6, 2026Infrastructure Security

Question

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?

Options

  • AUse the AWS Management Console to edit the JSON structure of the secret in Secrets Manager
  • BEnsure that the security group that is attached to the Lambda function allows outbound
  • CUse the Secrets Manager list-secrets command in the AWS CLI to list the secret. Identify the
  • DAdd an internet gateway to the VPC. Create a NAT gateway in a public subnet. Update the VPC

How the community answered

(17 responses)
  • A
    6% (1)
  • B
    76% (13)
  • C
    6% (1)
  • D
    12% (2)

Explanation

Option B is correct because the Lambda rotation function must connect directly to the database on the EC2 instance to update credentials - that's the "setSecret" step. Since the VPC endpoint is confirmed working (Lambda can already reach Secrets Manager), the bottleneck is Lambda's security group blocking outbound traffic to the database port (e.g., 3306/5432). Even within the same subnet, security groups enforce traffic rules, so the Lambda SG must allow outbound to the EC2 database port, and the EC2 SG must allow inbound from the Lambda SG.

Why the distractors fail:

  • A - A malformed secret JSON would cause a parsing/validation error, not a database login failure. The error message points to a connectivity problem, not a data structure problem.
  • C - list-secrets only retrieves metadata about secrets; it has no effect on rotation logic or network connectivity.
  • D - A NAT gateway provides internet access for private resources, but the Lambda and EC2 are already in the same private subnet, so no internet routing is needed to communicate between them. Adding a NAT gateway wouldn't fix an intra-VPC security group block.

Memory tip: Map the error to the rotation step - "setSecret: Unable to log into database" means Lambda reached Secrets Manager but failed to reach the DB. Think: Secrets Manager VPC endpoint → Lambda outbound SG → EC2 inbound SG → Database. Work through the chain from where the confirmed-working piece ends.

Topics

#AWS Lambda#Secrets Manager#VPC Security Groups#Credential Rotation

Community Discussion

No community discussion yet for this question.

Full SCS-C02 Practice