What is @aws-sdk/client-secrets-manager?
The @aws-sdk/client-secrets-manager package is a client library for interacting with AWS Secrets Manager service. It allows developers to manage secrets needed in their applications without hardcoding sensitive information. The package provides functionalities such as creating, reading, updating, and deleting secrets, as well as retrieving the current value of a secret.
What are @aws-sdk/client-secrets-manager's main functionalities?
Create a Secret
This code sample demonstrates how to create a new secret in AWS Secrets Manager.
const { SecretsManagerClient, CreateSecretCommand } = require('@aws-sdk/client-secrets-manager');
const client = new SecretsManagerClient({ region: 'your-region' });
const command = new CreateSecretCommand({
Name: 'MyTestSecret',
SecretString: 'MySecretValue'
});
const run = async () => {
try {
const data = await client.send(command);
console.log(data);
} catch (error) {
console.error(error);
}
};
run();
Retrieve a Secret Value
This code sample shows how to retrieve the current value of a secret stored in AWS Secrets Manager.
const { SecretsManagerClient, GetSecretValueCommand } = require('@aws-sdk/client-secrets-manager');
const client = new SecretsManagerClient({ region: 'your-region' });
const command = new GetSecretValueCommand({
SecretId: 'MyTestSecret'
});
const run = async () => {
try {
const data = await client.send(command);
console.log(data.SecretString);
} catch (error) {
console.error(error);
}
};
run();
Update a Secret
This code sample illustrates how to update the value of an existing secret in AWS Secrets Manager.
const { SecretsManagerClient, UpdateSecretCommand } = require('@aws-sdk/client-secrets-manager');
const client = new SecretsManagerClient({ region: 'your-region' });
const command = new UpdateSecretCommand({
SecretId: 'MyTestSecret',
SecretString: 'NewSecretValue'
});
const run = async () => {
try {
const data = await client.send(command);
console.log(data);
} catch (error) {
console.error(error);
}
};
run();
Other packages similar to @aws-sdk/client-secrets-manager
node-vault
node-vault is a client library for HashiCorp Vault, a tool for managing secrets. While @aws-sdk/client-secrets-manager is specifically designed for AWS Secrets Manager, node-vault is used for interacting with Vault by HashiCorp. Both provide similar functionalities in terms of secrets management but are intended for different secret storage services.
azure-keyvault-secrets
azure-keyvault-secrets is a client library for managing secrets in Azure Key Vault. Similar to @aws-sdk/client-secrets-manager, it allows for creating, retrieving, updating, and deleting secrets. The main difference lies in the cloud provider, with azure-keyvault-secrets being specific to Azure's ecosystem.