Soru

Zorluk: Çok zorSecrets Management and Parameter Store

A developer is deploying a microservice on Amazon ECS using AWS Fargate that connects to an Amazon Aurora PostgreSQL database. The application must retrieve a database endpoint (non-sensitive configuration) and a database password (sensitive credential). The database password must be automatically rotated every 30 days. The microservice handles a very high volume of requests, so the developer must design a solution that prevents database connection failures after rotation, avoids API throttling errors, and minimizes costs. Which approach should the developer take to retrieve and manage these configurations?

  1. Store the database endpoint in Systems Manager Parameter Store as a standard parameter and the database password in AWS Secrets Manager with automatic rotation. Retrieve both values in the microservice code using the AWS SDK, cache them locally in memory with a Time-to-Live (TTL), and re-fetch them from the respective AWS services when the TTL expires.Cevap
  2. B
    Store both the database endpoint and the password as standard parameters in Systems Manager Parameter Store. Enable parameter policies to automatically rotate the password parameter every 30 days, and retrieve both values inside the microservice code on every request using the AWS SDK.
  3. C
    Store both the database endpoint and the database password in AWS Secrets Manager. Initialize the Secrets Manager SDK client in the microservice code by passing hardcoded IAM access keys and secret keys of a dedicated IAM user to bypass IAM role credential retrieval latency.
  4. D
    Store the database endpoint in Systems Manager Parameter Store and the database password in AWS Secrets Manager. Reference both the parameter and the secret in the ECS task definition as environment variables, allowing the containerized application to read them directly from the local environment.

Cevap

Store the database endpoint in Systems Manager Parameter Store as a standard parameter and the database password in AWS Secrets Manager with automatic rotation. Retrieve both values in the microservice code using the AWS SDK, cache them locally in memory with a Time-to-Live (TTL), and re-fetch them from the respective AWS services when the TTL expires.
The correct strategy combines Systems Manager Parameter Store for non-sensitive configurations and AWS Secrets Manager for sensitive credentials that need automatic rotation. Under high-throughput environments, fetching credentials on every request will cause API throttling. Caching values locally with a Time-to-Live (TTL) ensures low latency and avoids API rate limiting, while the TTL expiration guarantees that the microservice eventually fetches the new password after an automatic rotation, avoiding database connection issues.

Adım Adım Çözüm

1
Determine the appropriate storage service for each configuration type.
The database endpoint is non-sensitive configuration data, which is most cost-effective to store in Systems Manager Parameter Store. The database password is a sensitive credential requiring automatic rotation, making AWS Secrets Manager the correct choice.
Parameter Store does not charge for standard parameters, while Secrets Manager charges $0.40 per secret per month but supports automatic rotation natively.
2
Configure the rotation mechanism for the database password.
Enable automatic rotation in Secrets Manager, which uses an AWS Lambda function to update the database password in both Secrets Manager and the Aurora database.
This ensures the credentials remain secure without manual intervention.
3
Implement a caching strategy inside the microservice application code.
Use the AWS SDK to retrieve the parameters, and cache the values in memory with a reasonable Time-to-Live (TTL). When the TTL expires, the microservice makes a fresh call to the AWS APIs to refresh the cache.
Caching avoids API throttling (ProvisionedThroughputExceededException) and minimizes retrieval latency. The TTL ensures that warm containers periodically refresh their cached credentials, preventing connection failures after a rotation occurs.

Anahtar Kavram

Selecting and integrating AWS Secrets Manager and Systems Manager Parameter Store with caching to support credentials rotation in high-throughput applications.
Bu soruyu puanla