Skip to main content

AWS Secrets Manager

With this integration you can store, manage, and retrieve, secrets in Amazon Web Services Secrets Manager.

Credential configuration

To fill the form params you need the Access key id and the Secret access key of the Programatic access user you want to use. This user needs the permissions to have access to Secrets Manager to work properly. If you need to create the user, you can see how to do it here.

In the extra options field you can pass any of the params you can find here.

Here you have an example of a filled credential configuration form in YepCode:

AWS Secrets Manager snippets available in YepCode editor

note

The title is the triggering text for YepCode to autocomplete the script

Integration

New integration from credential
const awsSecretsManagerClient = yepcode.integration.awsSecretsManager("credential-slug");
New integration from plain authentication data
const { SecretsManagerClient } = require("@aws-sdk/client-secrets-manager");

const awsSecretsManagerClient = new SecretsManagerClient({
credentials: {
accessKeyId: "accessKeyId",
secretAccessKey: "secretAccessKey",
},
});

Create secret

Create secret
const { CreateSecretCommand } = require("@aws-sdk/client-secrets-manager");

const createSecretCommand = new CreateSecretCommand({
Name: "secret-name",
SecretString: "secret-to-store",
});

awsSecretsManagerClient.send(createSecretCommand).then((response) => {
console.log(`Created secret with name ${response.Name}`);
}).catch(console.error);

List secrets

List secrets
const { ListSecretsCommand } = require("@aws-sdk/client-secrets-manager");

const listSecretsCommand = new ListSecretsCommand({});

awsSecretsManagerClient.send(listSecretsCommand).then((response) => {
const secrets = response.SecretList;
secrets.forEach((secret) => console.log(`Found secret with name ${secret.Name}`));
}).catch(console.error);

Get secret value

Get secret value
const { GetSecretValueCommand } = require("@aws-sdk/client-secrets-manager");

const getSecretValueCommand = new GetSecretValueCommand({
SecretId: "secret-name-or-ARN"
});

awsSecretsManagerClient.send(getSecretValueCommand).then((response) => {
// Secret value comes in response.SecretString or response.SecretBinary
// If you store other types of secrets different than key value pairs,
// then it will come as a JSON string

}).catch(console.error);

Delete secret

Delete secret
const { DeleteSecretCommand } = require("@aws-sdk/client-secrets-manager");

const deleteSecretCommand = new DeleteSecretCommand({
SecretId: "secret-name-or-ARN"
});

awsSecretsManagerClient.send(deleteSecretCommand).then((response) => {
console.log(`Deleted secret with name ${response.Name}`);
}).catch(console.error);