Secrets
Architect secrets can be anything ranging from log levels to production database credentials. Whatever they may be, there are a number of ways for these secret values to be provided, and this document will outline the available methods. We’ll assume you have registered the following two components:
From the command line, the simplest way to specify secret values for components
is by doing so directly from the deploy command. The command supports a
--secret
or -s
flag that allows you to specify the secret key and value as follows:
Using a config file
Using the --secret
flag is great for specifying values for individual
components, but doesn’t allow you to specify values for component dependencies.
In order to specify secret values for your component and it’s dependencies,
something common when generating on-demand environments, you’ll need to create a
secrets file. The Architect CLI supports two options: an Architect secrets file
in .yml format, or a .env file.
Architect secrets file
This file can then be specified directly in the deploy command to apply values to any components matching the keys in the file. The command below will deploy component, and since it has a dependency, that will automatically be deployed as well. Each component’s name matches a key in the file above so all the required secrets will be fulfilled.
The keys in the secrets file are simply patterns for matching components. Some examples are:
.env file
Architect also supports loading secrets from a .env file such as the one below. Secrets parsed from a .env file will be mapped to any component that expects the secret name. Rules for parsing a .env file can be found here and variables can be expanded during loading following the rules defined in dotenv-expand.
Deploying a component using secrets from a .env file is the same as with an
Architect secrets file. Just specify the name of the file after the
--secret-file
flag.
Using the ARC_ prefix
Environment variables set in a shell and prefixed with ARC_
will be picked up by the dev
and deploy
commands.
This means that if a component requires the secret secret_key
, setting ARC_secret_key
in the terminal from which the dev
or deploy
command is run will fulfill the value for that secret. For example:
Settings secrets this way can be useful in cases where secrets should be set, but never directly included in a secrets file or as part of a command.
From the UI
Storing environment configuration in a file is handy for local development, but not ideal for production-grade credentials. In order to provide comparable, secure support for production secrets and values, Architect Cloud allows secrets to be registered with each environment. Simply navigate to the “Secrets” tab on your environment to fill out the corresponding values:
Once filled out, each deployment to the corresponding environment will be automatically enriched with matching values.
Order of precedence
Since there are three different methods by which you can provide secrets, you may be wondering what happens if you use more than one. Architect interprets provided secret values in the following order:
--secret
flag (highest priority)--secret-file
flag- Environment secrets (lowest priority)