Generates .env
files from with Bitwarden secrets in nx monorepos.
npm i -D @codesdowork/nx-secrets-manager @bitwarden/cli
.secrets.config.json
{
"sever": "https://your-bitwarden-server.url"
}
extends?: ../.env.secure.yaml # optionally extend another config
env?:
NORMAL: variables
GO: here
secrets?:
COLLECTION_NAME:
collectionId: "your-collection-id"
prefix?: false # if the secret should be prefixed with the collection name (default: false)
vars:
- USERNAME
- PASSWORD
- OTHER_FIELD
- name: OTHER_NAMED_FIELD
field: secret_is_stored_in_field_with_this_name
nx g env-files [stages] [bw-username] [bw-password]
or
nx g @codesdowork/nx-secrets-manager:env-files [stages] [bw-username] [bw-password]
All input parameters can be omitted. They will be asked for when running the command.
When you are already logged in, the username is not needed.
The password input is hidden and can also read from the BW_PASSWORD
environment variable.
In Bitwarden, have a collection, e.g. DB
, with credentials named like the stage (e.g. DEV
, TEST
, PROD
).
Stages are comma separated and prioritized by their order, e.g., DEV,PROD
uses the DEV
stage primarily and PROD
as
fallback.