API mocks
Secrets Manager-compatible secrets
A mock of AWS Secrets Manager's AWS JSON protocol, as AWS SDK v2, AWS SDK v3 and the AWS CLI speak it. It covers:
- secrets read by name or ARN, as JSON text or binary;
- versions with
AWSCURRENTandAWSPREVIOUSstaging labels; - listing with filters, scheduled deletion and restore;
- real Signature Version 4 authentication.
Use it in place of the secrets your app loads at startup, so a test environment needs neither real AWS access nor a local secrets file. Testlie is not affiliated with Amazon Web Services, and nothing is encrypted with a real key.
Connect
Create a Secrets Manager-compatible secrets system under No-code. Requests are POST <base URL>/ with:
X-Amz-Target: secretsmanager.<Operation>;Content-Type: application/x-amz-json-1.1;- a JSON body;
- a SigV4 signature (service
secretsmanager) with the system's access key.
| Credential | Environment variable |
|---|---|
| Access key id, secret access key | AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY |
| Region | AWS_REGION (us-east-1) |
| Account id | The account in each secret's ARN |
Any region in the signature is accepted; ARNs carry the system's region.
AWS SDK v3
Set the endpoint in code, or as AWS_ENDPOINT_URL_SECRETS_MANAGER so the app's code stays as it is:
import { SecretsManagerClient, GetSecretValueCommand } from "@aws-sdk/client-secrets-manager";
const sm = new SecretsManagerClient({ endpoint: "<base URL>", region: "us-east-1" });
// or: AWS_ENDPOINT_URL_SECRETS_MANAGER=<base URL>, and new SecretsManagerClient({})
const { SecretString } = await sm.send(new GetSecretValueCommand({ SecretId: "general" }));AWS SDK v2
The v2 SDK (aws-sdk) does not read endpoint environment variables. Set the endpoint once at startup, before any client is made; every new AWS.SecretsManager() after that calls the mock, with or without arguments:
const AWS = require("aws-sdk");
if (process.env.SECRETS_MANAGER_ENDPOINT) AWS.config.update({ secretsmanager: { endpoint: process.env.SECRETS_MANAGER_ENDPOINT } });
const sm = new AWS.SecretsManager({ region: process.env.AWS_REGION });
const { SecretString } = await sm.getSecretValue({ SecretId: "general" }).promise();SECRETS_MANAGER_ENDPOINT is your app's own setting, set to the base URL. To use the system's keys for Secrets Manager only, while other AWS clients keep theirs, add credentials: { accessKeyId, secretAccessKey } next to endpoint.
AWS CLI
export AWS_ACCESS_KEY_ID=<access key id> AWS_SECRET_ACCESS_KEY=<secret access key> AWS_REGION=us-east-1
aws secretsmanager create-secret --endpoint-url <base URL> --name general \
--secret-string '{"DB_HOST":"localhost","STRIPE_KEY":"sk_test_123"}'
aws secretsmanager put-secret-value --endpoint-url <base URL> --secret-id general --secret-string file://general.json
aws secretsmanager get-secret-value --endpoint-url <base URL> --secret-id generalSeed from the dashboard
The system's page has a Seed secrets card. Paste a JSON object whose keys are secret names and whose values are the secrets: an object is stored as its JSON text, a string as it is. This is the shape of a local secrets file, so an app that read one can switch by pasting the file:
{
"general": { "DB_HOST": "localhost", "STRIPE_KEY": "sk_test_123" },
"jwt-keys": { "privateKey": "-----BEGIN PRIVATE KEY-----\n…" }
}How seeding applies:
- a new name creates the secret;
- an existing secret gets the value as a new
AWSCURRENTversion, unless it already has that value; - a secret scheduled for deletion is restored.
Owners and admins can seed, as can API keys with write access (POST /api/mocks/<mock id>/seed with { "secrets": { … } }). Each seed is in the audit log as api_mock.secrets_seeded, with the names only.
Values stay out of view: they are not shown in the system's stored objects, and the call log shows SecretString, SecretBinary and RandomPassword as ***. Read a value back with GetSecretValue or the AWS CLI.
Operations
| Secrets | CreateSecret (with SecretString or SecretBinary, Description, Tags), DescribeSecret, UpdateSecret, ListSecrets |
| Values | GetSecretValue (VersionId, VersionStage), BatchGetSecretValue (SecretIdList up to 20, or Filters), PutSecretValue (VersionStages), ListSecretVersionIds |
| Deletion | DeleteSecret (RecoveryWindowInDays 7 to 30, default 30, or ForceDeleteWithoutRecovery), RestoreSecret |
| Other | TagResource, UntagResource, GetRandomPassword |
Secret ids: SecretId takes the name, the full ARN (arn:aws:secretsmanager:<region>:<account>:secret:<name>-<6 characters>) or the ARN without its 6-character suffix. Names may contain /, as in prod/app/db.
Versions:
- each value is a version; its
VersionIdis the request'sClientRequestToken, which the SDKs fill in, so a retried call doesn't add a second version; - a new value takes
AWSCURRENT, the old current one becomesAWSPREVIOUS, and a version left without a label is dropped; PutSecretValuewith otherVersionStages, such asAWSPENDING, leavesAWSCURRENTwhere it is.
Deletion:
- a secret scheduled for deletion answers
GetSecretValue,PutSecretValueandUpdateSecretwithInvalidRequestException; DescribeSecretshows itsDeletedDate, andListSecretslists it only withIncludePlannedDeletion;RestoreSecretbrings it back;- after the recovery window, or at once with
ForceDeleteWithoutRecovery, it is gone and its name is free.
ListSecrets filters: name, description, tag-key, tag-value and all. Values are prefixes; a value starting with ! excludes. Pages of MaxResults (up to 100) with NextToken, by creation date (SortOrder).
Errors: AWS JSON errors with status 400, e.g. { "__type": "ResourceNotFoundException", "message": "Secrets Manager can't find the specified secret." }. Others are ResourceExistsException, InvalidRequestException, InvalidParameterException and LimitExceededException. A bad signature is a 403 SignatureDoesNotMatch.
Limits
These limits apply:
- 100 secrets per mock;
- 64 KB per value;
- 20 staging labels and 50 tags per secret.
Not implemented:
- rotation (
RotateSecret, rotation Lambdas),UpdateSecretVersionStage,CancelRotateSecret; - resource policies;
- replication to other regions;
- KMS encryption:
KmsKeyIdis stored and shown, nothing is encrypted.