Soru

Zorluk: OrtaAWS Serverless Application Model (SAM)

A developer is using AWS Serverless Application Model (SAM) to deploy a serverless API. The application uses a Lambda function triggered by an API Gateway API (defined as an `Api` event source) to retrieve records from a database. During testing, the API Gateway endpoint returns a 502 Bad Gateway error. The Lambda function logs indicate that it executed successfully and returned the database records, but the integration failed. Additionally, the developer needs to store the database credentials securely and ensure they are rotated automatically.

Which of the following actions should the developer take to resolve the integration error and meet the security requirements? (Select TWO.)

  1. Format the Lambda function's return payload to include the statusCode, headers, and body fields.Cevap
  2. Store the database credentials in AWS Secrets Manager and configure automatic rotation for the secret.Cevap
  3. C
    Modify the API Gateway integration in the template to use a custom integration, and configure the Lambda function handler to parse the request mapping templates.
  4. D
    Store the database credentials in AWS Systems Manager Parameter Store as a SecureString, and enable the built-in Parameter Store automatic rotation feature.
  5. E
    Update the trust policy of the Lambda execution role to allow the API Gateway service principal (apigateway.amazonaws.com) to assume the role.

Cevap

Format the Lambda function's return payload to include the statusCode, headers, and body fields, and store the database credentials in AWS Secrets Manager and configure automatic rotation for the secret.
The correct options are to format the Lambda function's return payload with status code, headers, and body fields, and to store the credentials in AWS Secrets Manager with automatic rotation. Because the default SAM Api event source deploys API Gateway with Lambda proxy integration, the Lambda response must adhere to a specific structure. Additionally, Secrets Manager is the correct service to use because it supports native automated credential rotation, whereas Systems Manager Parameter Store does not.

Adım Adım Çözüm

1
Analyze the 502 Bad Gateway integration error.
The Lambda function executes successfully but the integration fails. Since AWS SAM's default Api event source configures API Gateway Lambda proxy integration, the Lambda function must return the response in a structured format containing the status code, headers, and body.
This determines how to format the Lambda function's response to satisfy API Gateway's proxy integration requirements.
2
Evaluate the database credential rotation requirement.
AWS Secrets Manager is selected because it natively supports automatic rotation of credentials, unlike AWS Systems Manager Parameter Store which requires custom implementations to achieve rotation.
This identifies the correct AWS service to store and rotate credentials securely.

Anahtar Kavram

AWS SAM templates default to API Gateway Lambda proxy integrations, requiring structured JSON responses from the backend Lambda function, and security credentials requiring rotation should be managed by AWS Secrets Manager.
Bu soruyu puanla