A developer is building a backend application on AWS Lambda that integrates with a third-party payment gateway. The integration requires an API key that is rotated automatically every 30 days. The developer needs to store the API key securely, automate its rotation, and retrieve it in the Lambda function with minimal latency. Which storage and management approach should the developer use to meet these requirements with the least operational effort?
- Store the API key in AWS Secrets Manager. Configure automated rotation in AWS Secrets Manager by writing a custom AWS Lambda rotation function, and retrieve the key in the backend Lambda function using the AWS SDK with local caching.Cevap
- BStore the API key in Systems Manager Parameter Store as a SecureString parameter. Enable the built-in Parameter Store lifecycle policy to automatically rotate the parameter every 30 days.
- CStore the API key in Systems Manager Parameter Store as a SecureString parameter. Configure an Amazon EventBridge scheduler to trigger a custom AWS Lambda function every 30 days to generate and update the Parameter Store parameter.
- DHardcode the API key directly within the backend Lambda function's handler code and use AWS CodePipeline to automatically rebuild and redeploy the function when the key is updated by the payment gateway.
Cevap
Store the API key in AWS Secrets Manager, configure automated rotation using a custom Lambda function, and retrieve the key in the backend Lambda function using the AWS SDK with local caching.
Storing the API key in AWS Secrets Manager and configuring a custom Lambda rotation function allows AWS to natively manage the rotation schedule and execution. The application Lambda function retrieves the key at runtime using the AWS SDK, and caching it locally ensures subsequent invocations do not call Secrets Manager unnecessarily, minimizing latency and API costs.
Adım Adım Çözüm
Anahtar Kavram
Automating secret rotation using AWS Secrets Manager vs manual orchestration or insecure alternatives.