// Create an instance of the AWS Secrets Manager client
var client = SecretManager.CreateClient();
// Create an instance of the SecretManager class
var secretManager = new SecretManager(client);
// Retrieve the value of a secret
var secretValue = secretManager.GetSecretValue("mySecretId", "mySecretKey");This class provides a way to manage secrets using AWS Secrets Manager.
client(IAmazonSecretsManager): The AWS Secrets Manager client used for managing secrets.
SecretManager(): Initializes a new instance of theSecretManagerclass using the default AWS Secrets Manager client.SecretManager(IAmazonSecretsManager client): Initializes a new instance of theSecretManagerclass using the specified AWS Secrets Manager client.
Retrieves the value of a secret identified by secretId and returns the value associated with secretKey.
secretId(string): The ID or name of the secret.secretKey(string): The key used to retrieve the secret value.
Returns:
- The secret value associated with
secretKey.
Exceptions:
KeyNotFoundException: Thrown when the specified secret key does not exist.
Creates an instance of the AWS Secrets Manager client using the region specified in the AWS_REGION environment variable or the default region (RegionEndpoint.USEast1).
Returns:
- An instance of
IAmazonSecretsManagerrepresenting the AWS Secrets Manager client.
This class provides methods for retrieving the AWS region endpoint.
DefaultRegion(RegionEndpoint): The default AWS region endpoint.
Retrieves the AWS region endpoint based on the AWS_REGION environment variable or returns the default region if the environment variable is not set.
Returns:
- The AWS region endpoint.