Use AWS Secrets Manager secrets in API tests

If your services read their credentials from AWS Secrets Manager, your API tests should too. Copying the same keys into an API client's environment and into CI secrets creates two more places to rotate, leak and forget. The Requestarium CLI can fetch secrets straight from Secrets Manager when a run starts and use them as ordinary {{variables}}.

How it works

  1. You tell an environment which secret to read.
  2. When a run starts, the CLI fetches the secret from your machine, with your own AWS sign-in.
  3. The secret's values become variables for that run, masked in every report.

Point an environment at a secret

Add two variables to the environment, in the app or with the CLI:

Terminal
requestarium env set Staging RQ_AWS_SECRET_NAME staging/orders-api
requestarium env set Staging RQ_AWS_REGION eu-central-1
VariableMeaning
RQ_AWS_SECRET_NAMESecret name or ARN. Several, separated by commas
RQ_AWS_REGIONRegion. Defaults to the ARN's region, then AWS_REGION / AWS_DEFAULT_REGION
RQ_AWS_PROFILEAn AWS CLI profile to sign in with (optional)

Because these live on the environment, Staging and Production can point at different secrets, and switching environments switches secrets.

For a one-off run, use flags instead: --aws-secret staging/orders-api --aws-region eu-central-1.

Which variables you get

A secret that holds JSON key/value pairs, the usual kind, gives one variable per key:

JSON
{ "apiKey": "sk_live_...", "dbPassword": "..." }

→ {{apiKey}} and {{dbPassword}}. A plain-text secret becomes one variable named after the secret.

Locally: just sign in

If AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY aren't set, the CLI asks the AWS CLI v2 for your current credentials. So whatever you already use works:

Terminal
aws sso login --profile staging
requestarium run-collection "Orders API" --env Staging

In GitHub Actions: no stored keys at all

Use OpenID Connect to assume a role, so neither AWS keys nor the API key are stored in GitHub:

YAML
permissions:
  id-token: write
  contents: read

steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::123456789012:role/api-tests
      aws-region: eu-central-1
  - uses: actions/setup-node@v4
    with:
      node-version: 22
  - run: npm install -g @requestarium/cli
  - env:
      REQUESTARIUM_TOKEN: ${{ secrets.REQUESTARIUM_TOKEN }}
    run: requestarium run-collection "Orders API" --env Staging --junit results.xml

Permissions

The identity needs secretsmanager:GetSecretValue on the secret, and kms:Decrypt if the secret uses a customer-managed KMS key. Scope the role to the secrets your tests need, nothing more.

Precedence

Values from the secret manager override the environment's own values. A data file row, values set by scripts, and --var override them in turn. Secrets are fetched once per run; the MCP server keeps them for five minutes, and AI agents only ever see the variable names.

Azure and Google Cloud

The same works for Azure Key Vault (RQ_AZURE_VAULT_URL, az login or a service principal) and Google Cloud Secret Manager (RQ_GCP_PROJECT, RQ_GCP_SECRET_NAME, gcloud auth login or workload identity). Thunder Client's TC_AWS_* and TC_AZURE_VAULT_URL variables work too. Details in the CLI reference.