Continue modifying docs

This commit is contained in:
Tuan Dang
2022-11-19 10:24:39 -05:00
parent 0f6756f2f1
commit 96cbdfdaca
43 changed files with 344 additions and 101 deletions

View File

@@ -0,0 +1,31 @@
---
title: "Infisical CLI"
description: "Learn about each supported command and its flags"
---
## Background
Infisical ships with multiple commands to assist with ongoing project needs; we list these commands and give context for them below.
<Card title="Install the CLI" icon="lightbulb" href="/installCLI">
If you haven't already, install the Infisical CLI
</Card>
Note on arguments:
- [environment]: the intended environment for the given command being one of dev, staging, or prod.
- [projectId]: the project identifier found on the dashboard.
## Commands
- `login` used to set the logged in user. Your credentials are saved securely in your system key ring. Note: only one user can be logged in at a time. To change the logged in user, run the command again and overwrite the previous login.
- `init` used to link your infisical.com project to your local project. Run this command ideally at the root of your local project. You will have to run this command for each new project you create locally.
- `run` used to inject your secrets as environment variables into your application process. Example `infisical run --stage=prod -- npm run start`
- `---projectId` flag is used to link your local project to a Infisical.com project. Use this option only when you are injecting via Infisical Token instead of your login.
- `---stage` flag is used to set the environment from which your secrets are pulled from. By default, secrets from your project are pulled from the `dev`. To change to for example prod, add `--stage=prod`
### Global flags
These are flags you can add to any command
- `--domain` you may change this if you are self hosting Infisical. By default, the CLI points to Infisical.com backend. To point to your own backend, make sure to set this flag for each command you run. Example `infisical login --domain=https://mybackend.com`
- `--debug` use this flag when you want to see more logs related to the error you are receiving. By default debug logs are hidden. Example `infisical run --debug <your command>`

View File

@@ -0,0 +1,68 @@
---
title: "Infisical Token"
description: "Learn to authenticate via the CLI without in manually"
---
## Background
To authenticate the Infisical CLI in environments other than your local desktop environment, you will have to utilize the Infisical Token.
The Infisical Token is a quick and easy way to authenticate the CLI without having to type in your email and password. This is especially needed
in production environments where you cannot type in your login details.
With the Infisical Token, you can allow read only access to a particular environment (dev, prod, etc.) for a given project for a set amount of time. Once the token expires, any CLI application
that relies on it for authentication will be denied access to retrieve the related secrets.
## Generate a Infisical Token
To get started, navigate to your dashboard and select the project for which you would like to generate a Infisical Token for.
Then head over to project settings and you should see a similar page like below.
![title](./images/project_settings_page.png)
To add a new Infisical Token, press the `add new token` button. This will bring up a page like below.
![title](./images/add_new_token.png)
Enter a name to help you identify the token then choose the environment from which you would like the CLI to retrieve the secrets from. Lastly, choose a duration
for the token.
<Info>
Once the token is expired, the CLI using it will no longer be able to make requests with it.
</Info>
## Use Infisical token with CLI
Once you have generated a token, it is easy to tell the Infisical CLI to use it.
### Feeding the token to the CLI
The CLI looks out for an environment variable called `INFISICAL_TOKEN`. Setting this environment variable depends on where you run the CLI.
For example, if you are running the CLI in a Docker container, you may set the environment variable via the docker run command like so.
Docker run example:
```
docker run --env INFISICAL_TOKEN=<the token you generated>...
```
<Warning>
In the event your token is exposed, visit the project settings page again and deactivate the token to expire it immediately.
</Warning>
### Prepare `infisical run` command
Once you have exposed the `INFISICAL_TOKEN` environment variable to the environment the CLI is running in you can prepare the run command.
To have the CLI authenticate via the Infisical Token, you must provide values for flags `--stage` and `--projectId`
Example:
```
infisical run --stage=prod --projectId=<the project id for the token you generated>
```
<Info>
Notice that we do not need to run any other command such as `infisical init` or `infisical login` when we use the Infisical Token.
</Info>
To learn more about the commands and it's flags [visit](/CLI)
### Support
Lastly, if you have any questions or inquiries, shoot an email over to [support@infisical.com](mailto:support@infisical.com) so we can assist you. Alternatively, feel free to post your question or DM us on Slack here; we'd be happy to connect with you.

View File

@@ -0,0 +1,147 @@
---
title: "Installation"
---
Follow the guide for your OS below to install the CLI.
<Tabs>
<Tab title="MacOS">
Use [brew](https://brew.sh/) package manager
```bash
# install
brew install infisical/get-cli/infisical
# check version
infisical --version
```
To update:
```bash
brew upgrade infisical
```
</Tab>
<Tab title="Windows">
Use [Scoop](https://scoop.sh/) package manager
```bash
# install
scoop bucket add org https://github.com/Infisical/scoop-infisical.git
scoop install infisical
# check version
infisical --version
```
To update:
```bash
scoop update infisical
```
</Tab>
<Tab title="Alpine">
Install prerequisite
```bash
$ sudo apk add --no-cache bash sudo
```
Add Infisical repository
```bash
$ curl -1sLf \
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' \
| sudo -E bash
```
Then install CLI
```bash
$ apk update && apk add infisical
```
</Tab>
<Tab title="RedHat/CentOs/Amazon">
Add Infisical repository
```bash
$ curl -1sLf \
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.rpm.sh' \
| sudo -E bash
```
Then install CLI
```bash
$ yum install infisical
```
</Tab>
<Tab title="Debian/Ubuntu">
Add Infisical repository
```bash
$ curl -1sLf \
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.deb.sh' \
| sudo -E bash
```
Then install CLI
```
$ apt-get update && apt-get install -y infisical
```
</Tab>
</Tabs>
## Usage
Once you have the CLI installed in your system, follow the guide to login and sync your first project.
#### Login
Login to the CLI by running the following command in your terminal
```
infisical login
```
<Info>
To authenticate without logging in manually, read about [Infisical
Token](/infisicalToken)
</Info>
#### Link secrets to your project After logging in, `CD` into the root of your local
project. Then run the following command in the terminal to link your Infisical project
to your local project.
```
infisical init
```
#### Inject
To inject the secrets from the Infisical project you have selected in step 2 into your application process, run the following command.
```
infisical run -- <your application start command>
```
Example:
```
infisical run -- npm run dev
```
By default, Infisical injects secrets from your development environment. To modify from which environment your secrets are pulled from, use the --stage flag
Example:
```
infisical run --stage=prod -- npm run dev
```
You're now automatically pulling and injecting secrets as environment variables into your application!
### Support
We're constantly improving Infisical, so we'd love to get your feedback and take feature requests.
Lastly, if you have any questions or inquiries, shoot an email over to [support@infisical.com](mailto:support@infisical.com) so we can assist you. Alternatively, feel free to post your question or DM us on Slack here; we'd be happy to connect with you.