Preprequisites
- Signup for an envsecrets account.
- Install the CLI.
Setup
Firstly, change directory to your project root.Local Environment
In order to get comfortable, let’s first run through all commands in your local environment before we go to remote environment. Run the following commands in correct order.1
Set your secrets
2
List your secrets
3
Get your secret
DB_PASSWORD
from locally saved key-value pairs.4
Consume your secret
Example
Example
Copy and save the following contents in a file called Now inject your secrets in the process by running your script with the following command:This should ideally produce the following output:
test.sh
.If you get a permission error for your shell-script, just run:
chmod +x test.sh
Remote Environment
- To manage secrets in your remote/hosted environment, you can simply use the same aforementioned commands with
-e
or--env
. - For the purpose of this tutorial, we will use the pre-initialized/default
prod
environment that is created for your every envsecrets project.
1
Login
2
Initalize the project directory
3
Set your secrets
prod
environment.4
List your secrets
prod
environment and help you validate that your key-value pair indeed got set.You can use the
--version
flag to modify which version to list the secrets for.If you want to export the values of all the keys and not just list the keys, use:
envs export
5
Get your secret
DB_PASSWORD
in the latest secret version of your remote prod
environment.You can use the
--version
flag to modify which version to get the value from.6
Consume your secret
Example
Example
Copy and save the following contents in a file called Now inject your secrets in the process by running your script with the following command:This should ideally produce the following output:
test.sh
.If you get a permission error for your shell-script, just run:
chmod +x test.sh
prod
environment.
You can now access your secrets natively in your code.You can use the
--version
flag to modify which version to get the values from.Connect an Integration
For the sake of this tutorial, let’s connect the Github Actions integration.- Go to integrations catalog in your envsecrets dashboard and choose “Github Actions.”
- Complete the Oauth procedure that begins and grant access to all of your Github repositories to which you wish to sync your secrets.
- Go to the integrations dashboard in your envsecrets organisation and under “Github Actions” choose “Sync New Environment With Your Github Actions Account.”
- In the page that opens, select your envsecrets project, environment and your Github repository where you wish to push/sync your secrets.
- Complete and save the form.
Sync Your Secrets
From the UI
From the UI
- Navigate to the environment for which you activated the integration.
- Click on the “Sync” button.
- Choose the Github repository to which you want to sync your secrets.
- Approve the sync.
From the CLI
From the CLI
- Use the command:
envs sync --env [name-of-your-remote-environment]
- Choose the Gitlab integration.
Once your secrets are synced, it is recommended you go to your Github repository and validate the new values.