Merge pull request #1736 from Infisical/daniel/remove-service-tokens-docs

Feat: API Docs revamp (Service Token Deprecation)
This commit is contained in:
BlackMagiq
2024-04-30 16:49:12 -07:00
committed by GitHub
31 changed files with 1177 additions and 812 deletions
@@ -4,7 +4,7 @@ openapi: "GET /api/v2/service-token"
--- ---
<Warning> <Warning>
This endpoint will be deprecated in the near future with the removal of service tokens in Q1/Q2 2024. This endpoint is deprecated and will be removed in the future.
We recommend switching to using [identities](/documentation/platform/identities/overview) if your client supports it. We recommend switching to using [Machine Identities](/documentation/platform/identities/machine-identities).
</Warning> </Warning>
+43 -21
View File
@@ -16,36 +16,48 @@ Export environment variables from the platform into a file format.
<Accordion title="infisical export" defaultOpen="true"> <Accordion title="infisical export" defaultOpen="true">
Use this command to export environment variables from the platform into a raw file formats Use this command to export environment variables from the platform into a raw file formats
```bash ```bash
$ infisical export $ infisical export
# Export variables to a .env file # Export variables to a .env file
infisical export > .env infisical export > .env
# Export variables to a .env file (with export keyword) # Export variables to a .env file (with export keyword)
infisical export --format=dotenv-export > .env infisical export --format=dotenv-export > .env
# Export variables to a CSV file # Export variables to a CSV file
infisical export --format=csv > secrets.csv infisical export --format=csv > secrets.csv
# Export variables to a JSON file # Export variables to a JSON file
infisical export --format=json > secrets.json infisical export --format=json > secrets.json
# Export variables to a YAML file # Export variables to a YAML file
infisical export --format=yaml > secrets.yaml infisical export --format=yaml > secrets.yaml
# Render secrets using a custom template file # Render secrets using a custom template file
infisical export --template=<path to template> infisical export --template=<path to template>
``` ```
### Environment variables
### Environment variables
<Accordion title="INFISICAL_TOKEN"> <Accordion title="INFISICAL_TOKEN">
Used to fetch secrets via a [service token](/documentation/platform/token) apposed to logged in credentials. Simply, export this variable in the terminal before running this command. Used to fetch secrets via a [machine identities](/documentation/platform/identities/machine-identities) apposed to logged in credentials. Simply, export this variable in the terminal before running this command.
```bash ```bash
# Example # Example
export INFISICAL_TOKEN=st.63e03c4a97cb4a747186c71e.ed5b46a34c078a8f94e8228f4ab0ff97.4f7f38034811995997d72badf44b42ec export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=<identity-client-id> --client-secret=<identity-client-secret> --silent --plain) # --plain flag will output only the token, so it can be fed to an environment variable. --silent will disable any update messages.
``` ```
<Info>
Alternatively, you may use service tokens.
Please note, however, that service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities). They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
```bash
# Example
export INFISICAL_TOKEN=<service-token>
```
</Info>
</Accordion> </Accordion>
<Accordion title="INFISICAL_DISABLE_UPDATE_CHECK"> <Accordion title="INFISICAL_DISABLE_UPDATE_CHECK">
@@ -57,13 +69,15 @@ Export environment variables from the platform into a file format.
# Example # Example
export INFISICAL_DISABLE_UPDATE_CHECK=true export INFISICAL_DISABLE_UPDATE_CHECK=true
``` ```
</Accordion> </Accordion>
### flags ### flags
<Accordion title="--template"> <Accordion title="--template">
The `--template` flag specifies the path to the template file used for rendering secrets. When using templates, you can omit the other format flags. The `--template` flag specifies the path to the template file used for rendering secrets. When using templates, you can omit the other format flags.
```text my-template-file ```text my-template-file
{{$secrets := secret "<infisical-project-id>" "<environment-slug>" "<folder-path>"}} {{$secrets := secret "<infisical-project-id>" "<environment-slug>" "<folder-path>"}}
{{$length := len $secrets}} {{$length := len $secrets}}
{{- "{"}} {{- "{"}}
@@ -73,12 +87,13 @@ Export environment variables from the platform into a file format.
{{- end }} {{- end }}
{{- end }} {{- end }}
{{ "}" -}} {{ "}" -}}
``` ```
```bash ```bash
# Example # Example
infisical export --template="/path/to/template/file" infisical export --template="/path/to/template/file"
``` ```
</Accordion> </Accordion>
<Accordion title="--env"> <Accordion title="--env">
Used to set the environment that secrets are pulled from. Used to set the environment that secrets are pulled from.
@@ -91,6 +106,7 @@ Export environment variables from the platform into a file format.
Note: this flag only accepts environment slug names not the fully qualified name. To view the slug name of an environment, visit the project settings page. Note: this flag only accepts environment slug names not the fully qualified name. To view the slug name of an environment, visit the project settings page.
default value: `dev` default value: `dev`
</Accordion> </Accordion>
<Accordion title="--projectId"> <Accordion title="--projectId">
@@ -102,24 +118,28 @@ Export environment variables from the platform into a file format.
infisical export --projectId=XXXXXXXXXXXXXX infisical export --projectId=XXXXXXXXXXXXXX
``` ```
</Accordion> </Accordion>
<Accordion title="--expand"> <Accordion title="--expand">
Parse shell parameter expansions in your secrets (e.g., `${DOMAIN}`) Parse shell parameter expansions in your secrets (e.g., `${DOMAIN}`)
Default value: `true` Default value: `true`
</Accordion> </Accordion>
<Accordion title="--format"> <Accordion title="--format">
Format of the output file. Accepted values: `dotenv`, `dotenv-export`, `csv`, `json` and `yaml` Format of the output file. Accepted values: `dotenv`, `dotenv-export`, `csv`, `json` and `yaml`
Default value: `dotenv` Default value: `dotenv`
</Accordion> </Accordion>
<Accordion title="--secret-overriding"> <Accordion title="--secret-overriding">
Prioritizes personal secrets with the same name over shared secrets Prioritizes personal secrets with the same name over shared secrets
Default value: `true` Default value: `true`
</Accordion> </Accordion>
<Accordion title="--path"> <Accordion title="--path">
@@ -129,6 +149,7 @@ Export environment variables from the platform into a file format.
# Example # Example
infisical export --path="/path/to/folder" --env=dev infisical export --path="/path/to/folder" --env=dev
``` ```
</Accordion> </Accordion>
<Accordion title="--tags"> <Accordion title="--tags">
@@ -142,6 +163,7 @@ Export environment variables from the platform into a file format.
Note: you must reference the tag by its slug name not its fully qualified name. Go to project settings to view all tag slugs. Note: you must reference the tag by its slug name not its fully qualified name. Go to project settings to view all tag slugs.
By default, all secrets are fetched By default, all secrets are fetched
</Accordion> </Accordion>
</Accordion> </Accordion>
+49 -17
View File
@@ -11,6 +11,7 @@ description: "The command that injects your secrets into local environment"
# Example # Example
infisical run [options] -- npm run dev infisical run [options] -- npm run dev
``` ```
</Tab> </Tab>
<Tab title="Chained commands"> <Tab title="Chained commands">
@@ -20,6 +21,7 @@ description: "The command that injects your secrets into local environment"
# Example # Example
infisical run [options] --command "npm run bootstrap && npm run dev start; other-bash-command" infisical run [options] --command "npm run bootstrap && npm run dev start; other-bash-command"
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -27,27 +29,38 @@ description: "The command that injects your secrets into local environment"
Inject secrets from Infisical into your application process. Inject secrets from Infisical into your application process.
## Subcommands & flags ## Subcommands & flags
<Accordion title="infisical run" defaultOpen="true"> <Accordion title="infisical run" defaultOpen="true">
Use this command to inject secrets into your applications process Use this command to inject secrets into your applications process
```bash ```bash
$ infisical run -- <your application command> $ infisical run -- <your application command>
# Example # Example
$ infisical run -- npm run dev $ infisical run -- npm run dev
``` ```
### Environment variables
### Environment variables
<Accordion title="INFISICAL_TOKEN"> <Accordion title="INFISICAL_TOKEN">
Used to fetch secrets via a [service token](/documentation/platform/token) apposed to logged in credentials. Simply, export this variable in the terminal before running this command. Used to fetch secrets via a [machine identity](/documentation/platform/identities/machine-identities) apposed to logged in credentials. Simply, export this variable in the terminal before running this command.
```bash ```bash
# Example # Example
export INFISICAL_TOKEN=st.63e03c4a97cb4a747186c71e.ed5b46a34c078a8f94e8228f4ab0ff97.4f7f38034811995997d72badf44b42ec export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=<identity-client-id> --client-secret=<identity-client-secret> --silent --plain) # --plain flag will output only the token, so it can be fed to an environment variable. --silent will disable any update messages.
``` ```
<Info>
Alternatively, you may use service tokens.
Please note, however, that service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities). They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
```bash
# Example
export INFISICAL_TOKEN=<service-token>
```
</Info>
</Accordion> </Accordion>
<Accordion title="INFISICAL_DISABLE_UPDATE_CHECK"> <Accordion title="INFISICAL_DISABLE_UPDATE_CHECK">
@@ -59,9 +72,10 @@ Inject secrets from Infisical into your application process.
# Example # Example
export INFISICAL_DISABLE_UPDATE_CHECK=true export INFISICAL_DISABLE_UPDATE_CHECK=true
``` ```
</Accordion> </Accordion>
### Flags ### Flags
<Accordion title="--project-config-dir"> <Accordion title="--project-config-dir">
Explicitly set the directory where the .infisical.json resides. This is useful for some monorepo setups. Explicitly set the directory where the .infisical.json resides. This is useful for some monorepo setups.
@@ -70,6 +84,7 @@ Inject secrets from Infisical into your application process.
# Example # Example
infisical run --project-config-dir=/some-dir -- printenv infisical run --project-config-dir=/some-dir -- printenv
``` ```
</Accordion> </Accordion>
<Accordion title="--command"> <Accordion title="--command">
@@ -79,35 +94,51 @@ Inject secrets from Infisical into your application process.
# Example # Example
infisical run --command="npm run build && npm run dev; more-commands..." infisical run --command="npm run build && npm run dev; more-commands..."
``` ```
</Accordion> </Accordion>
<Accordion title="--token"> <Accordion title="--projectId">
If you are using a [service token](/documentation/platform/token) to authenticate, you can pass the token as a flag The project ID to fetch secrets from. This is required when using a machine identity to authenticate.
```bash ```bash
# Example # Example
infisical run --token="st.63e03c4a97cb4a747186c71e.ed5b46a34c078a8f94e8228f4ab0ff97.4f7f38034811995997d72badf44b42ec" -- npm run start infisical run --projectId=<project-id> -- npm run dev
```
</Accordion>
<Accordion title="--token">
If you are using a [machine identity](/documentation/platform/identities/machine-identities) to authenticate, you can pass the token as a flag
```bash
# Example
infisical run --token="<universal-auth-access-token>" --projectId=<project-id> -- npm run start
``` ```
You may also expose the token to the CLI by setting the environment variable `INFISICAL_TOKEN` before executing the run command. This will have the same effect as setting the token with `--token` flag You may also expose the token to the CLI by setting the environment variable `INFISICAL_TOKEN` before executing the run command. This will have the same effect as setting the token with `--token` flag
</Accordion> </Accordion>
<Accordion title="--expand"> <Accordion title="--expand">
Turn on or off the shell parameter expansion in your secrets. If you have used shell parameters in your secret(s), activating this feature will populate them before injecting them into your application process. Turn on or off the shell parameter expansion in your secrets. If you have used shell parameters in your secret(s), activating this feature will populate them before injecting them into your application process.
Default value: `true` Default value: `true`
</Accordion> </Accordion>
<Accordion title="--env"> {" "}
This is used to specify the environment from which secrets should be retrieved. The accepted values are the environment slugs defined for your project, such as `dev`, `staging`, `test`, and `prod`.
Default value: `dev` <Accordion title="--env">
</Accordion> This is used to specify the environment from which secrets should be
retrieved. The accepted values are the environment slugs defined for your
project, such as `dev`, `staging`, `test`, and `prod`. Default value: `dev`
</Accordion>
<Accordion title="--secret-overriding"> <Accordion title="--secret-overriding">
Prioritizes personal secrets with the same name over shared secrets Prioritizes personal secrets with the same name over shared secrets
Default value: `true` Default value: `true`
</Accordion> </Accordion>
<Accordion title="--tags"> <Accordion title="--tags">
@@ -121,6 +152,7 @@ Inject secrets from Infisical into your application process.
Note: you must reference the tag by its slug name not its fully qualified name. Go to project settings to view all tag slugs. Note: you must reference the tag by its slug name not its fully qualified name. Go to project settings to view all tag slugs.
By default, all secrets are fetched By default, all secrets are fetched
</Accordion> </Accordion>
<Accordion title="--path"> <Accordion title="--path">
+23 -3
View File
@@ -23,13 +23,23 @@ $ infisical secrets
### Environment variables ### Environment variables
<Accordion title="INFISICAL_TOKEN"> <Accordion title="INFISICAL_TOKEN">
Used to fetch secrets via a [service token](/documentation/platform/token) apposed to logged in credentials. Simply, export this variable in the terminal before running this command. Used to fetch secrets via a [machine identity](/documentation/platform/identities/machine-identities) apposed to logged in credentials. Simply, export this variable in the terminal before running this command.
```bash ```bash
# Example # Example
export INFISICAL_TOKEN=st.63e03c4a97cb4a747186c71e.ed5b46a34c078a8f94e8228f4ab0ff97.4f7f38034811995997d72badf44b42ec export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=<identity-client-id> --client-secret=<identity-client-secret> --silent --plain) # --plain flag will output only the token, so it can be fed to an environment variable. --silent will disable any update messages.
``` ```
<Info>
Alternatively, you may use service tokens.
Please note, however, that service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities). They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
```bash
# Example
export INFISICAL_TOKEN=<service-token>
```
</Info>
</Accordion> </Accordion>
<Accordion title="INFISICAL_DISABLE_UPDATE_CHECK"> <Accordion title="INFISICAL_DISABLE_UPDATE_CHECK">
@@ -53,6 +63,16 @@ $ infisical secrets
</Accordion> </Accordion>
<Accordion title="--projectId">
The project ID to fetch secrets from. This is required when using a machine identity to authenticate.
```bash
# Example
infisical secrets --projectId=<project-id>
```
</Accordion>
<Accordion title="--env"> <Accordion title="--env">
Used to select the environment name on which actions should be taken on Used to select the environment name on which actions should be taken on
@@ -186,7 +206,7 @@ $ infisical secrets folders
</Accordion> </Accordion>
<Accordion title="--token"> <Accordion title="--token">
Fetch folders using the Infisical service token Fetch folders using a [machine identity](/documentation/platform/identities/machine-identities) access token.
Default value: `` Default value: ``
</Accordion> </Accordion>
+19 -4
View File
@@ -3,22 +3,31 @@ title: "infisical service-token"
description: "Manage Infisical service tokens" description: "Manage Infisical service tokens"
--- ---
<Warning>
This command is deprecated and will be removed in the near future. Please
switch to using [Machine
Identities](/documentation/platform/identities/machine-identities) for
authenticating with Infisical.
</Warning>
```bash ```bash
infisical service-token create --scope=dev:/global --scope=dev:/backend --access-level=read --access-level=write infisical service-token create --scope=dev:/global --scope=dev:/backend --access-level=read --access-level=write
``` ```
## Description ## Description
The Infisical `service-token` command allows you to manage service tokens for a given Infisical project. The Infisical `service-token` command allows you to manage service tokens for a given Infisical project.
With this command, you can create, view, and delete service tokens. With this command, you can create, view, and delete service tokens.
<Accordion title="service-token create" defaultOpen="true"> <Accordion title="service-token create" defaultOpen="true">
Use this command to create a service token Use this command to create a service token
```bash ```bash
$ infisical service-token create --scope=dev:/backend/** --access-level=read --access-level=write $ infisical service-token create --scope=dev:/backend/** --access-level=read --access-level=write
``` ```
### Flags
### Flags
<Accordion title="--scope"> <Accordion title="--scope">
```bash ```bash
infisical service-token create --scope=dev:/global --scope=dev:/backend/** --access-level=read infisical service-token create --scope=dev:/global --scope=dev:/backend/** --access-level=read
@@ -34,6 +43,7 @@ With this command, you can create, view, and delete service tokens.
<Info> <Info>
The `path` can be a Glob pattern The `path` can be a Glob pattern
</Info> </Info>
</Accordion> </Accordion>
<Accordion title="--projectId"> <Accordion title="--projectId">
@@ -43,6 +53,7 @@ With this command, you can create, view, and delete service tokens.
The project ID you'd like to create the service token for. The project ID you'd like to create the service token for.
By default, the CLI will attempt to use the linked Infisical project in `.infisical.json` generated by `infisical init` command. By default, the CLI will attempt to use the linked Infisical project in `.infisical.json` generated by `infisical init` command.
</Accordion> </Accordion>
<Accordion title="--name"> <Accordion title="--name">
```bash ```bash
@@ -52,6 +63,7 @@ With this command, you can create, view, and delete service tokens.
Service token name Service token name
Default: `Service token generated via CLI` Default: `Service token generated via CLI`
</Accordion> </Accordion>
<Accordion title="--expiry-seconds"> <Accordion title="--expiry-seconds">
```bash ```bash
@@ -61,6 +73,7 @@ With this command, you can create, view, and delete service tokens.
Set the service token's expiration time in seconds from now. To never expire set to zero. Set the service token's expiration time in seconds from now. To never expire set to zero.
Default: `1 day` Default: `1 day`
</Accordion> </Accordion>
<Accordion title="--access-level"> <Accordion title="--access-level">
```bash ```bash
@@ -68,6 +81,7 @@ With this command, you can create, view, and delete service tokens.
``` ```
The type of access the service token should have. Can be `read` and or `write` The type of access the service token should have. Can be `read` and or `write`
</Accordion> </Accordion>
<Accordion title="--token-only"> <Accordion title="--token-only">
```bash ```bash
@@ -77,5 +91,6 @@ With this command, you can create, view, and delete service tokens.
When true, only the service token will be printed When true, only the service token will be printed
Default: `false` Default: `false`
</Accordion> </Accordion>
</Accordion> </Accordion>
-22
View File
@@ -1,22 +0,0 @@
---
title: "Infisical Token"
description: "How to use Infisical service token within the CLI."
---
Prerequisite: [Infisical Token and How to Generate One](/documentation/platform/token).
It's possible to use the CLI to sync environment variables without manually entering login credentials by using a service token in the prerequisite link above.
## Feeding Infisical Token to the CLI
The CLI looks out for an environment variable called the `INFISICAL_TOKEN` which you can set depending on where you run the CLI. If `INFISICAL_TOKEN` is detected by the CLI, it will authenticate and retrieve the environment variables which the token is authorized for.
A common use-case is to use the Infisical Token to fetch environment variables with Docker. More specifically, a token can be passed to a container as an environment variable for the CLI to authenticate and pull its corresponding secrets. Check out the integration guides for that:
- [Docker](../../integrations/platforms/docker)
- [Docker Compose](../../integrations/platforms/docker-compose)
<Info>
Once the token is expired, the CLI using it will no longer be able to make
requests with it.
</Info>
+188 -133
View File
@@ -1,141 +1,125 @@
--- ---
title: "Quick usage" title: "Quickstart"
description: "Manage secrets with Infisical CLI" description: "Manage secrets with Infisical CLI"
--- ---
The CLI is designed for a variety of applications, ranging from local secret management to CI/CD and production scenarios. The CLI is designed for a variety of secret management applications ranging from local development to CI/CD and production scenarios.
The distinguishing factor, however, is the authentication method used.
<Tabs> <Tabs>
<Tab title="Local development only"> <Tab title="Local development">
To use the Infisical CLI in your local development environment, simply run the command below and follow the interactive guide. In the following steps, we explore how to use the Infisical CLI to fetch back environment variables from Infisical
and inject them into your local development process.
```bash <Steps>
infisical login <Step title="Log in with the CLI">
``` Start by running the `infisical login` command to authenticate with Infisical.
<Note> ```bash
If you are in a containerized environment such as WSL 2 or Codespaces, run `infisical login -i` to avoid browser based login infisical login
</Note> ```
<Note>
If you are in a containerized environment such as WSL 2 or Codespaces, run `infisical login -i` to avoid browser based login
</Note>
</Step>
<Step title="Initialize Infisical for your project">
Next, navigate to your project and initialize Infisical.
## Initialize Infisical for your project ```bash
# navigate to your project
cd /path/to/project
```bash # initialize infisical
# navigate to your project infisical init
cd /path/to/project ```
# initialize infisical The `infisical init` command creates a `.infisical.json` file, containing [local project settings](./project-config), at the location where the command is executed.
infisical init
```
This will create `.infisical.json` file at the location the command was executed. This file contains your [local project settings](./project-config). It does not contain any sensitive data. <Note>
The `.infisical.json` file does not contain any sensitive data, so you may commit it to your git repository.
</Note>
</Step>
<Step title="Inject environment variables">
Finally, pass environment variables from Infisical into your application.
<Tabs>
<Tab title="Feed secrets to your application">
```bash
infisical run --env=dev --path=/apps/firefly -- [your application start command] # e.g. npm run dev
# example with node (nodemon)
infisical run --env=staging --path=/apps/spotify -- nodemon index.js
# example with flask
infisical run --env=prod --path=/apps/backend -- flask run
# example with spring boot - maven
infisical run --env=dev --path=/apps/ -- ./mvnw spring-boot:run --quiet
```
</Tab>
<Tab title="Feed secrets via custom aliases (advanced)">
Custom aliases can utilize secrets from Infisical. Suppose there is a custom alias `yd` in `custom.sh` that runs `yarn dev` and needs the secrets provided by Infisical.
```bash
#!/bin/sh
yd() {
yarn dev
}
```
To make the secrets available from Infisical to `yd`, you can run the following command:
```bash
infisical run --env=prod --path=/apps/reddit --command="source custom.sh && yd"
```
</Tab>
</Tabs>
View all available options for `run` command [here](./commands/run)
</Step>
</Steps>
</Tab> </Tab>
<Tab title="Staging, production & all other use case"> <Tab title="Staging, production & all other use cases">
To use Infisical for non local development scenarios, please create a [service token](../documentation/platform/token). The service token will allow you to authenticate and interact with Infisical. In the following steps, we explore how to use the Infisical CLI in a non-local development scenario
Once you have created a service token with the required permissions, you'll need to feed the token to the CLI. to fetch back environment variables and export them to a file.
<Steps>
<Step title="Create a machine identity and obtain credentials for it">
Follow the steps listed [here](/documentation/platform/identities/universal-auth) to create a machine identity and obtain a **client ID** and **client secret** for it.
</Step>
<Step title="Obtain a machine identity access token">
Run the following command to authenticate with Infisical using the **client ID** and **client secret** credentials from step 1 and set the `INFISICAL_TOKEN` environment variable to the retrieved access token.
#### Pass as flag ```bash
You may use the --token flag to set the token export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=<identity-client-id> --client-secret=<identity-client-secret> --silent --plain) # --plain flag will output only the token, so it can be fed to an environment variable. --silent will disable any update messages.
```
``` The CLI is configured to look out for the `INFISICAL_TOKEN` environment variable, so going forward any command used will be authenticated.
infisical export --token=<>
infisical secrets --token=<>
infisical run --token=<> -- npm run dev
```
#### Pass via shell environment variable Alternatively, assuming you have an access token on hand, you can also pass it directly to the CLI using the `--token` flag in conjunction with other CLI commands.
The CLI is configured to look for an environment variable named `INFISICAL_TOKEN`. If set, it'll attempt to use it for authentication.
``` <Info>
export INFISICAL_TOKEN=<> Keep in mind that the machine identity access token has a limited lifetime. It is recommended to use it only for the duration of the task at hand.
``` You can [refresh the token](./commands/token) if needed.
</Info>
</Step>
<Step title="Export environment variables back into a file">
Finally, export the environment variables from Infisical to a file of choice.
```bash
# export variables to a .env file (with export keyword)
infisical export --format=dotenv-export > .env
# export variables to a YAML file
infisical export --format=yaml > secrets.yaml
```
</Step>
</Steps>
</Tab> </Tab>
</Tabs> </Tabs>
## Inject environment variables
<Tabs>
<Tab title="Feed secrets to your application">
```bash
infisical run --env=dev --path=/apps/firefly -- [your application start command]
# example with node (nodemon)
infisical run --env=staging --path=/apps/spotify -- nodemon index.js
# example with flask
infisical run --env=prod --path=/apps/backend -- flask run
# example with spring boot - maven
infisical run --env=dev --path=/apps/ -- ./mvnw spring-boot:run --quiet
```
</Tab>
<Tab title="Feed secrets via custom aliases (advanced)">
Custom aliases can utilize secrets from Infisical. Suppose there is a custom alias `yd` in `custom.sh` that runs `yarn dev` and needs the secrets provided by Infisical.
```bash
#!/bin/sh
yd() {
yarn dev
}
```
To make the secrets available from Infisical to `yd`, you can run the following command:
```bash
infisical run --env=prod --path=/apps/reddit --command="source custom.sh && yd"
```
</Tab>
</Tabs>
View all available options for `run` command [here](./commands/run)
## Connect CLI to self hosted Infisical
<Accordion title="Optional: point CLI to self-hosted">
The CLI is set to connect to Infisical Cloud by default, but if you're running your own instance of Infisical, you can direct the CLI to it using one of the methods provided below.
#### Method 1: Use the updated CLI
Beginning with CLI version V0.4.0, it is now possible to choose between logging in through the Infisical cloud or your own self-hosted instance. Simply execute the `infisical login` command and follow the on-screen instructions.
#### Method 2: Export environment variable
You can point the CLI to the self hosted Infisical instance by exporting the environment variable `INFISICAL_API_URL` in your terminal.
<Tabs>
<Tab title="Linux/MacOs">
```bash
# Set backend host
export INFISICAL_API_URL="https://your-self-hosted-infisical.com/api"
# Remove backend host
unset INFISICAL_API_URL
```
</Tab>
<Tab title="Windows Powershell">
```bash
# Set backend host
setx INFISICAL_API_URL "https://your-self-hosted-infisical.com/api"
# Remove backend host
setx INFISICAL_API_URL ""
# NOTE: Once set or removed, please restart powershell for the change to take effect
```
</Tab>
</Tabs>
#### Method 3: Set manually on every command
Another option to point the CLI to your self hosted Infisical instance is to set it via a flag on every command you run.
```bash
# Example
infisical <any-command> --domain="https://your-self-hosted-infisical.com/api"
```
</Accordion>
## History ## History
Your terminal keeps a history with the commands you run. When you create Infisical secrets directly from your terminal, they'll stay there for a while. Your terminal keeps a history with the commands you run. When you create Infisical secrets directly from your terminal, they'll stay there for a while.
@@ -143,30 +127,101 @@ Your terminal keeps a history with the commands you run. When you create Infisic
For security and privacy concerns, we recommend you to configure your terminal to ignore those specific Infisical commands. For security and privacy concerns, we recommend you to configure your terminal to ignore those specific Infisical commands.
<Accordion title="Ignore commands"> <Accordion title="Ignore commands">
<Tabs>
<Tab title="Unix/Linux">
<Tip>
`$HOME/.profile` is pretty common but, you could place it under `$HOME/.profile.d/infisical.sh` or any profile file run at login
</Tip>
<Tabs> ```bash
<Tab title="Unix/Linux"> cat <<EOF >> $HOME/.profile && source $HOME/.profile
<Tip>
`$HOME/.profile` is pretty common but, you could place it under `$HOME/.profile.d/infisical.sh` or any profile file run at login
</Tip>
# Ignoring specific Infisical CLI commands
DEFAULT_HISTIGNORE=$HISTIGNORE
export HISTIGNORE="*infisical secrets set*:$DEFAULT_HISTIGNORE"
EOF
```
</Tab>
<Tab title="Windows">
If you're on WSL, then you can use the Unix/Linux method.
<Tip>
Here's some [documentation](https://superuser.com/a/1658331) about how to clear the terminal history, in PowerShell and CMD
</Tip>
</Tab>
</Tabs>
</Accordion>
## FAQ
<AccordionGroup>
<Accordion title="Can I connect the CLI to my self-hosted Infisical instance?">
Yes. The CLI is set to connect to Infisical Cloud by default, but if you're running your own instance of Infisical, you can direct the CLI to it using one of the methods provided below.
#### Method 1: Use the updated CLI
Beginning with CLI version V0.4.0, it is now possible to choose between logging in through the Infisical cloud or your own self-hosted instance. Simply execute the `infisical login` command and follow the on-screen instructions.
#### Method 2: Export environment variable
You can point the CLI to the self hosted Infisical instance by exporting the environment variable `INFISICAL_API_URL` in your terminal.
<Tabs>
<Tab title="Linux/MacOs">
```bash ```bash
cat <<EOF >> $HOME/.profile && source $HOME/.profile # set backend host
export INFISICAL_API_URL="https://your-self-hosted-infisical.com/api"
# Ignoring specific Infisical CLI commands # remove backend host
DEFAULT_HISTIGNORE=$HISTIGNORE unset INFISICAL_API_URL
export HISTIGNORE="*infisical secrets set*:$DEFAULT_HISTIGNORE"
EOF
``` ```
</Tab> </Tab>
<Tab title="Windows"> <Tab title="Windows Powershell">
If you're on WSL, then you can use the Unix/Linux method. ```bash
# set backend host
setx INFISICAL_API_URL "https://your-self-hosted-infisical.com/api"
<Tip> # remove backend host
Here's some [documentation](https://superuser.com/a/1658331) about how to clear the terminal history, in PowerShell and CMD setx INFISICAL_API_URL ""
</Tip>
</Tab> # NOTE: Once set or removed, please restart powershell for the change to take effect
</Tabs> ```
</Accordion>
</Tab>
</Tabs>
#### Method 3: Set manually on every command
Another option to point the CLI to your self hosted Infisical instance is to set it via a flag on every command you run.
```bash
# Example
infisical <any-command> --domain="https://your-self-hosted-infisical.com/api"
```
</Accordion>
<Accordion title="Can I use the CLI with service tokens?">
Yes. Please note, however, that service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities). They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
To use Infisical for non local development scenarios, please create a service token. The service token will allow you to authenticate and interact with Infisical. Once you have created a service token with the required permissions, you’ll need to feed the token to the CLI.
```bash
infisical export --token=<service-token>
infisical secrets --token=<service-token>
infisical run --token=<service-token> -- npm run dev
```
#### Pass via shell environment variable
The CLI is configured to look for an environment variable named `INFISICAL_TOKEN`. If set, it’ll attempt to use it for authentication.
```bash
export INFISICAL_TOKEN=<service-token>
```
</Accordion>
</AccordionGroup>
@@ -1,87 +0,0 @@
---
title: "Kubernetes"
---
The Infisical Secrets Operator fetches secrets from Infisical and saves them as Kubernetes secrets using the custom `InfisicalSecret` resource to define authentication and storage methods.
The operator updates secrets continuously and can reload dependent deployments automatically on secret changes.
Prerequisites:
- Connected to your cluster via kubectl
- Have a project with secrets ready in [Infisical Cloud](https://app.infisical.com).
- Create an [Infisical Token](/documentation/platform/token) scoped to an environment in your project in Infisical.
## Installation
Follow the instructions for either [Helm](https://helm.sh/) or [kubectl](https://github.com/kubernetes/kubectl) to install the Infisical Secrets Operator.
<Tabs>
<Tab title="Helm">
Install the Infisical Helm repository
```console
helm repo add infisical-helm-charts 'https://dl.cloudsmith.io/public/infisical/helm-charts/helm/charts/'
helm repo update
```
Install the Helm chart
```console
helm install --generate-name infisical-helm-charts/secrets-operator
```
</Tab>
<Tab title="Kubectl">
The operator will be installed in `infisical-operator-system` namespace
```
kubectl apply -f https://raw.githubusercontent.com/Infisical/infisical/main/k8-operator/kubectl-install/install-secrets-operator.yaml
```
</Tab>
</Tabs>
## Usage
**Step 1: Create Kubernetes secret containing service token**
Once you have generated the service token, create a Kubernetes secret containing the service token you generated by running the command below.
``` bash
kubectl create secret generic service-token --from-literal=infisicalToken=<your-service-token-here>
```
**Step 2: Fill out the InfisicalSecrets CRD and apply it to your cluster**
```yaml infisical-secrets-config.yaml
apiVersion: secrets.infisical.com/v1alpha1
kind: InfisicalSecret
metadata:
# Name of of this InfisicalSecret resource
name: infisicalsecret-sample
spec:
# The host that should be used to pull secrets from. If left empty, the value specified in Global configuration will be used
hostAPI: https://app.infisical.com/api
resyncInterval:
authentication:
serviceToken:
serviceTokenSecretReference:
secretName: service-token
secretNamespace: option
secretsScope:
envSlug: dev
secretsPath: "/"
managedSecretReference:
secretName: managed-secret # <-- the name of kubernetes secret that will be created
secretNamespace: default # <-- where the kubernetes secret should be created
```
```
kubectl apply -f infisical-secrets-config.yaml
```
You should now see a new kubernetes secret automatically created in the namespace you defined in the `managedSecretReference` property above.
See also:
- [Documentation for the Infisical Kubernetes Operator](../../integrations/platforms/kubernetes)
@@ -24,7 +24,7 @@ This approach offers several advantages in terms of security and management:
- **Scalability**: Dynamic secret management systems can scale more effectively to handle a large number of services and applications, as they automate much of the overhead associated with manual secret management. - **Scalability**: Dynamic secret management systems can scale more effectively to handle a large number of services and applications, as they automate much of the overhead associated with manual secret management.
Dynamic secrets are particularly useful in environments with stringent security requirements, such as cloud environments, distributed systems, and microservices architectures, where they help to manage database credentials, API keys, service tokens, and other types of secrets. Dynamic secrets are particularly useful in environments with stringent security requirements, such as cloud environments, distributed systems, and microservices architectures, where they help to manage database credentials, API keys, tokens, and other types of secrets.
## Infisical Dynamic Secret Templates ## Infisical Dynamic Secret Templates
@@ -1,5 +1,5 @@
--- ---
title: Machine Identities title: Machine Identities
description: "Learn how to use Machine Identities to programmatically interact with Infisical." description: "Learn how to use Machine Identities to programmatically interact with Infisical."
--- ---
@@ -21,18 +21,17 @@ Key Features:
A typical workflow for using identities consists of four steps: A typical workflow for using identities consists of four steps:
1. Creating the identity with a name and [role](/documentation/platform/role-based-access-controls) in Organization Access Control > Machine Identities. 1. Creating the identity with a name and [role](/documentation/platform/role-based-access-controls) in Organization Access Control > Machine Identities.
This step also involves configuring an authentication method for it such as [Universal Auth](/documentation/platform/identities/universal-auth). This step also involves configuring an authentication method for it such as [Universal Auth](/documentation/platform/identities/universal-auth).
2. Adding the identity to the project(s) you want it to have access to. 2. Adding the identity to the project(s) you want it to have access to.
3. Authenticating the identity with the Infisical API based on the configured authentication method on it and receiving a short-lived access token back. 3. Authenticating the identity with the Infisical API based on the configured authentication method on it and receiving a short-lived access token back.
4. Authenticating subsequent requests with the Infisical API using the short-lived access token. 4. Authenticating subsequent requests with the Infisical API using the short-lived access token.
<Note> <Note>
Currently, identities can only be used to make authenticated requests to the Infisical API, SDKs, Terraform, Kubernetes Operator, and Infisical Agent. They do not work with clients such as CLI, Ansible look up plugin, etc. Currently, identities can only be used to make authenticated requests to the Infisical API, SDKs, Terraform, Kubernetes Operator, and Infisical Agent. They do not work with clients such as CLI, Ansible look up plugin, etc.
Machine Identity support for the rest of the clients is planned to be released in the current quarter. Machine Identity support for the rest of the clients is planned to be released in the current quarter.
</Note>
</Note>
## Authentication Methods ## Authentication Methods
@@ -43,8 +42,16 @@ To interact with various resources in Infisical, Machine Identities are able to
## FAQ ## FAQ
<AccordionGroup> <AccordionGroup>
<Accordion title="Can I use machine identities with the CLI?">
Yes - Identities can be used with the CLI.
You can learn more about how to do this in the CLI quickstart [here](/cli/usage).
</Accordion>
<Accordion title="What is the difference between an identity and service token?"> <Accordion title="What is the difference between an identity and service token?">
A service token is a project-level authentication method that is being phased out in favor of identities. A service token is a project-level authentication method that is being deprecated in favor of identities. The service token method will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
Amongst many differences, identities provide broader access over the Infisical API, utilizes the same Amongst many differences, identities provide broader access over the Infisical API, utilizes the same
permission system as user identities, and come with a significantly larger number of configurable authentication and security features. permission system as user identities, and come with a significantly larger number of configurable authentication and security features.
@@ -17,7 +17,6 @@ Upon being added to an organization and projects, users assume a certain set of
To interact with various resources in Infisical, users are able to utilize a number of authentication methods: To interact with various resources in Infisical, users are able to utilize a number of authentication methods:
- **Email & Password**: the most common authentication method that is used for authentication into Web Dashboard and Infisical CLI. It is recommended to utilize [Multi-factor Authentication](/documentation/platform/mfa) in addition to it. - **Email & Password**: the most common authentication method that is used for authentication into Web Dashboard and Infisical CLI. It is recommended to utilize [Multi-factor Authentication](/documentation/platform/mfa) in addition to it.
- **Service Tokens**: Service tokens allow users authenticate into CLI and other clients under their own identity. For the majority of use cases, it is not a recommended approach. Instead, it is often a good idea to utilize [Machine Identities](./machine-identities) with [Universal Authentication](/documentation/platform/identities/universal-auth).
- **SSO**: Infisical natively integrates with a number of SSO identity providers like [Google](/documentation/platform/sso/google), [GitHub](/documentation/platform/sso/github), and [GitLab](/documentation/platform/sso/gitlab). - **SSO**: Infisical natively integrates with a number of SSO identity providers like [Google](/documentation/platform/sso/google), [GitHub](/documentation/platform/sso/github), and [GitLab](/documentation/platform/sso/gitlab).
- **SAML SSO**: It is also possible to set up SAML SSO integration with identity providers like [Okta](/documentation/platform/sso/okta), [Microsoft Entra ID](/documentation/platform/sso/azure) (formerly known as Azure AD), [JumpCloud](/documentation/platform/sso/jumpcloud), [Google](/documentation/platform/sso/google-saml), and more. - **SAML SSO**: It is also possible to set up SAML SSO integration with identity providers like [Okta](/documentation/platform/sso/okta), [Microsoft Entra ID](/documentation/platform/sso/azure) (formerly known as Azure AD), [JumpCloud](/documentation/platform/sso/jumpcloud), [Google](/documentation/platform/sso/google-saml), and more.
- **LDAP**: For organizations with more advanced needs, Infisical also provides user authentication with [LDAP](/documentation/platform/ldap/overview) that includes a number of LDAP providers. - **LDAP**: For organizations with more advanced needs, Infisical also provides user authentication with [LDAP](/documentation/platform/ldap/overview) that includes a number of LDAP providers.
@@ -1,38 +0,0 @@
---
title: "IP Allowlisting"
description: "Restrict access to your secrets in Infisical using trusted IPs"
---
<Warning>
IP allowlisting at the project-level is being replaced with IP allowlisting at the token-level now available with the Service Token V3 authentication method.
Instead of providing trusted IPs (specific IPs and CIDR ranges) to be applied across all service tokens,
you can now specify trusted IPs at the token-level.
</Warning>
<Info>
Note that IP Allowlisting is a paid feature.
If you're using Infisical Cloud, then it is available under the **Pro Tier**. If you're self-hosting Infisical,
then you should contact [email protected] to purchase an enterprise license to use it.
</Info>
Projects in Infisical can be configured to restrict client access to specific IP addresses or CIDR ranges. This applies to any client using service tokens and
can be useful, for example, for limiting access to traffic coming from corporate networks.
By default, each project is initialized with the `0.0.0.0/0` entry, representing all possible IPv4 addresses.
For enhanced security, we strongly recommend replacing the default entry with your client IPs to tighten access to your secrets.
<Note>
You must be a project `admin` to manage your project's IP whitelist.
</Note>
![IP whitelist](../../images/platform/ip-allowlisting/ip-allowlisting-table.png)
## Creating a trusted IP entry
To create a trusted IP entry, head over to the **IP Whitelist** tab in your project. When creating an entry,
you can specify either a specific IP address like `192.0.2.1` or a CIDR range like `2001:db8::/32`; both IPv4 and IPv6
formats are accepted.
![IP whitelist add](../../images/platform/ip-allowlisting/ip-allowlisting-modal.png)
@@ -19,7 +19,7 @@ This means that updating the value of a base secret propagates directly to other
![secret referencing](../../images/platform/secret-references-imports/secret-reference.png) ![secret referencing](../../images/platform/secret-references-imports/secret-reference.png)
Since secret referencing works by reconstructing values back on the client side, the client, be it a user or service token, fetching back secrets Since secret referencing works by reconstructing values back on the client side, the client, be it a user, service token, or a machine identity, fetching back secrets
must be permissioned access to all base and dependent secrets. must be permissioned access to all base and dependent secrets.
For example, to access some secret `A` whose values depend on secrets `B` and `C` from different scopes, a client must have `read` access to the scopes of secrets `A`, `B`, and `C`. For example, to access some secret `A` whose values depend on secrets `B` and `C` from different scopes, a client must have `read` access to the scopes of secrets `A`, `B`, and `C`.
+28 -18
View File
@@ -3,6 +3,13 @@ title: "Service Token"
description: "Infisical service tokens allow users to programmatically interact with Infisical." description: "Infisical service tokens allow users to programmatically interact with Infisical."
--- ---
<Warning>
Service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities).
They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
</Warning>
Service tokens are authentication credentials that services can use to access designated endpoints in the Infisical API to manage project resources like secrets. Service tokens are authentication credentials that services can use to access designated endpoints in the Infisical API to manage project resources like secrets.
Each service token can be provisioned scoped access to select environment(s) and path(s) within them. Each service token can be provisioned scoped access to select environment(s) and path(s) within them.
@@ -17,8 +24,8 @@ Service Token (ST) is the current widely-used authentication method for managing
Here's a few pointers to get you acquainted with it: Here's a few pointers to get you acquainted with it:
- When you create a ST, you get a token prefixed with `st`. The part after the last `.` delimiter is a symmetric key; everything - When you create a ST, you get a token prefixed with `st`. The part after the last `.` delimiter is a symmetric key; everything
before it is an access token. When authenticating with the Infisical API, it is important to send in only the access token portion before it is an access token. When authenticating with the Infisical API, it is important to send in only the access token portion
of the token. of the token.
- ST supports expiration; it gets deleted automatically upon expiration. - ST supports expiration; it gets deleted automatically upon expiration.
- ST supports provisioning `read` and/or `write` permissions broadly applied to all accessible environment(s) and path(s). - ST supports provisioning `read` and/or `write` permissions broadly applied to all accessible environment(s) and path(s).
- ST is not editable. - ST is not editable.
@@ -35,7 +42,7 @@ the token access to. Here's some guidance for each field:
- Name: A friendly name for the token. - Name: A friendly name for the token.
- Scopes: The environment(s) and path(s) the token should have access to. - Scopes: The environment(s) and path(s) the token should have access to.
- Permissions: You can indicate whether or not the token should have `read/write` access to the paths. - Permissions: You can indicate whether or not the token should have `read/write` access to the paths.
Also, note that Infisical supports [glob patterns](https://www.malikbrowne.com/blog/a-beginners-guide-glob-patterns/) when defining access scopes to path(s). Also, note that Infisical supports [glob patterns](https://www.malikbrowne.com/blog/a-beginners-guide-glob-patterns/) when defining access scopes to path(s).
- Expiration: The time when this token should be rendered inactive. - Expiration: The time when this token should be rendered inactive.
![token add](../../images/project-token-old-permissions.png) ![token add](../../images/project-token-old-permissions.png)
@@ -44,28 +51,31 @@ In the above screenshot, you can see that we are creating a token token with `re
of the `/common` path within the development environment of the project; the token expires in 6 months and can be used from any IP address. of the `/common` path within the development environment of the project; the token expires in 6 months and can be used from any IP address.
<Note> <Note>
For a deeper understanding of service tokens, it is recommended to read [this guide](https://infisical.com/docs/internals/service-tokens). For a deeper understanding of service tokens, it is recommended to read [this
guide](https://infisical.com/docs/internals/service-tokens).
</Note> </Note>
**FAQ** **FAQ**
<AccordionGroup> <AccordionGroup>
<Accordion title="Why is the Infisical API rejecting my service token?"> <Accordion title="Why is the Infisical API rejecting my service token?">
There are a few reasons for why this might happen: There are a few reasons for why this might happen:
- The service token has expired. - The service token has expired.
- The service token is insufficiently permissioned to interact with the secrets in the given environment and path. - The service token is insufficiently permissioned to interact with the secrets in the given environment and path.
- You are attempting to access a `/raw` secrets endpoint that requires your project to disable E2EE. - You are attempting to access a `/raw` secrets endpoint that requires your project to disable E2EE.
- (If using ST V3) The service token has not been activated yet. - (If using ST V3) The service token has not been activated yet.
- (If using ST V3) The service token is being used from an untrusted IP. - (If using ST V3) The service token is being used from an untrusted IP.
</Accordion>
<Accordion title="Can you provide examples for using glob patterns?">
1. `/**`: This pattern matches all folders at any depth in the directory structure. For example, it would match folders like `/folder1/`, `/folder1/subfolder/`, and so on.
2. `/*`: This pattern matches all immediate subfolders in the current directory. It does not match any folders at a deeper level. For example, it would match folders like `/folder1/`, `/folder2/`, but not `/folder1/subfolder/`. </Accordion>
<Accordion title="Can you provide examples for using glob patterns?">
1. `/**`: This pattern matches all folders at any depth in the directory structure. For example, it would match folders like `/folder1/`, `/folder1/subfolder/`, and so on.
3. `/*/*`: This pattern matches all subfolders at a depth of two levels in the current directory. It does not match any folders at a shallower or deeper level. For example, it would match folders like `/folder1/subfolder/`, `/folder2/subfolder/`, but not `/folder1/` or `/folder1/subfolder/subsubfolder/`. 2. `/*`: This pattern matches all immediate subfolders in the current directory. It does not match any folders at a deeper level. For example, it would match folders like `/folder1/`, `/folder2/`, but not `/folder1/subfolder/`.
4. `/folder1/*`: This pattern matches all immediate subfolders within the `/folder1/` directory. It does not match any folders outside of `/folder1/`, nor does it match any subfolders within those immediate subfolders. For example, it would match folders like `/folder1/subfolder1/`, `/folder1/subfolder2/`, but not `/folder2/subfolder/`. 3. `/*/*`: This pattern matches all subfolders at a depth of two levels in the current directory. It does not match any folders at a shallower or deeper level. For example, it would match folders like `/folder1/subfolder/`, `/folder2/subfolder/`, but not `/folder1/` or `/folder1/subfolder/subsubfolder/`.
</Accordion>
4. `/folder1/*`: This pattern matches all immediate subfolders within the `/folder1/` directory. It does not match any folders outside of `/folder1/`, nor does it match any subfolders within those immediate subfolders. For example, it would match folders like `/folder1/subfolder1/`, `/folder1/subfolder2/`, but not `/folder2/subfolder/`.
</Accordion>
</AccordionGroup> </AccordionGroup>
Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

+213 -70
View File
@@ -6,133 +6,276 @@ description: "How to effectively and securely manage secrets in Jenkins using In
**Objective**: Fetch secrets from Infisical to Jenkins pipelines **Objective**: Fetch secrets from Infisical to Jenkins pipelines
In this guide, we'll outline the steps to deliver secrets from Infisical to Jenkins via the Infisical CLI. In this guide, we'll outline the steps to deliver secrets from Infisical to Jenkins via the Infisical CLI.
At a high level, the Infisical CLI will be executed within your build environment and use a service token to authenticate with Infisical. At a high level, the Infisical CLI will be executed within your build environment and use a machine identity to authenticate with Infisical.
This token must be added as a Jenkins Credential and then passed to the Infisical CLI as an environment variable, enabling it to access and retrieve secrets within your workflows. This token must be added as a Jenkins Credential and then passed to the Infisical CLI as an environment variable, enabling it to access and retrieve secrets within your workflows.
Prerequisites: Prerequisites:
- Set up and add secrets to [Infisical](https://app.infisical.com). - Set up and add secrets to [Infisical](https://app.infisical.com).
- Create a [machine identity](/documentation/platform/identities/machine-identities) (Recommended), or a service token in Infisical.
- You have a working Jenkins installation with the [credentials plugin](https://plugins.jenkins.io/credentials/) installed. - You have a working Jenkins installation with the [credentials plugin](https://plugins.jenkins.io/credentials/) installed.
- You have the [Infisical CLI](/cli/overview) installed on your Jenkins executor nodes or container images. - You have the [Infisical CLI](/cli/overview) installed on your Jenkins executor nodes or container images.
<Tabs>
## Add Infisical Service Token to Jenkins <Tab title="Machine Identity (Recommended)">
## Add Infisical Machine Identity to Jenkins
After setting up your project in Infisical and installing the Infisical CLI to the environment where your Jenkins builds will run, you will need to add the Infisical Service Token to Jenkins. After setting up your project in Infisical and installing the Infisical CLI to the environment where your Jenkins builds will run, you will need to add the Infisical Machine Identity to Jenkins.
To generate a Infisical service token, follow the guide [here](/documentation/platform/token). To generate a Infisical machine identity, follow the guide [here](/documentation/platform/identities/machine-identities).
Once you have generated the token, navigate to **Manage Jenkins > Manage Credentials** in your Jenkins instance. Once you have generated the token, navigate to **Manage Jenkins > Manage Credentials** in your Jenkins instance.
![Jenkins step 1](../../images/integrations/jenkins/jenkins_1.png) ![Jenkins step 1](../../images/integrations/jenkins/jenkins_1.png)
Click on the credential store you want to store the Infisical Service Token in. In this case, we're using the default Jenkins global store. Click on the credential store you want to store the Infisical Machine Identity in. In this case, we're using the default Jenkins global store.
<Info> <Info>
Each of your projects will have a different `INFISICAL_TOKEN`. Each of your projects will have a different `INFISICAL_TOKEN`.
As a result, it may make sense to spread these out into separate credential domains depending on your use case. As a result, it may make sense to spread these out into separate credential domains depending on your use case.
</Info> </Info>
![Jenkins step 2](../../images/integrations/jenkins/jenkins_2.png) ![Jenkins step 2](../../images/integrations/jenkins/jenkins_2.png)
Now, click Add Credentials. Now, click Add Credentials.
![Jenkins step 3](../../images/integrations/jenkins/jenkins_3.png) ![Jenkins step 3](../../images/integrations/jenkins/jenkins_3.png)
Choose **Secret text** for the **Kind** option from the dropdown list and enter the Infisical Service Token in the **Secret** field. Choose **Secret text** for the **Kind** option from the dropdown list and enter the Infisical Service Token in the **Secret** field.
Although the **ID** can be any value, we'll set it to `infisical-service-token` for the sake of this guide. Although the **ID** can be any value, we'll set it to `infisical-machine-identity-client-id` and `infisical-machine-identity-client-secret` for the sake of this guide.
The description is optional and can be any text you prefer. The description is optional and can be any text you prefer.
![Jenkins step 4](../../images/integrations/jenkins/jenkins_4.png) ![Jenkins step 4](../../images/integrations/jenkins/jenkins_4_identity_id.png)
![Jenkins step 5](../../images/integrations/jenkins/jenkins_4_identity_secret.png)
When you're done, you should see a credential similar to the one below: When you're done, you should see two credentials similar to the one below:
![Jenkins step 5](../../images/integrations/jenkins/jenkins_5.png) ![Jenkins step 6](../../images/integrations/jenkins/jenkins_5_identity.png)
## Use Infisical in a Freestyle Project ## Use Infisical in a Freestyle Project
To fetch secrets with Infisical in a Freestyle Project job, you'll need to expose the credential you created above as an environment variable to the Infisical CLI. To fetch secrets with Infisical in a Freestyle Project job, you'll need to expose the credential you created above as an environment variable to the Infisical CLI.
To do so, first click **New Item** from the dashboard navigation sidebar: To do so, first click **New Item** from the dashboard navigation sidebar:
![Jenkins step 6](../../images/integrations/jenkins/jenkins_6.png) ![Jenkins step 6](../../images/integrations/jenkins/jenkins_6.png)
Enter the name of the job, choose the **Freestyle Project** option, and click **OK**. Enter the name of the job, choose the **Freestyle Project** option, and click **OK**.
![Jenkins step 7](../../images/integrations/jenkins/jenkins_7.png) ![Jenkins step 7](../../images/integrations/jenkins/jenkins_7.png)
Scroll down to the **Build Environment** section and enable the **Use secret text(s) or file(s)** option. Then click **Add** under the **Bindings** section and choose **Secret text** from the dropdown menu. Scroll down to the **Build Environment** section and enable the **Use secret text(s) or file(s)** option. Then click **Add** under the **Bindings** section and choose **Secret text** from the dropdown menu.
![Jenkins step 8](../../images/integrations/jenkins/jenkins_8.png) ![Jenkins step 8](../../images/integrations/jenkins/jenkins_8.png)
Enter `INFISICAL_TOKEN` in the **Variable** field then click the **Specific credentials** option from the Credentials section and select the credential you created earlier. Enter `INFISICAL_MACHINE_IDENTITY_CLIENT_ID` in the **Variable** field for the client ID, and `INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET` for the client secret. Then click the **Specific credentials** option from the Credentials section and select the credentials you created earlier.
In this case, we saved it as `Infisical service token` so we'll choose that from the dropdown menu. In this case, we saved it as `Infisical Machine Identity Client ID` and `Infisical Machine Identity Client Secret` so we'll choose those from the dropdown menu.
![Jenkins step 9](../../images/integrations/jenkins/jenkins_9.png) Make sure to add bindings for both the client ID and the client secret.
Scroll down to the **Build** section and choose **Execute shell** from the **Add build step** menu. ![Jenkins step 9](../../images/integrations/jenkins/jenkins_9_identity.png)
![Jenkins step 10](../../images/integrations/jenkins/jenkins_10.png) Scroll down to the **Build** section and choose **Execute shell** from the **Add build step** menu.
In the command field, you can now use the Infisical CLI to fetch secrets. ![Jenkins step 10](../../images/integrations/jenkins/jenkins_10_identity.png)
The example command below will print the secrets using the service token passed as a credential. When done, click **Save**.
``` In the command field, you can now use the Infisical CLI to fetch secrets.
infisical secrets --env=dev --path=/ The example command below will print the secrets using the service token passed as a credential. When done, click **Save**.
```
![Jenkins step 11](../../images/integrations/jenkins/jenkins_11.png) ```bash
export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=$INFISICAL_MACHINE_IDENTITY_CLIENT_ID --client-secret=$INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET --silent --plain)
infisical secrets --env dev --projectId=<your-project-id>
```
Finally, click **Build Now** from the navigation sidebar to run your new job. ![Jenkins step 11](../../images/integrations/jenkins/jenkins_11_identity.png)
<Info> Finally, click **Build Now** from the navigation sidebar to run your new job.
Running into issues? Join Infisical's [community Slack](https://infisical.com/slack) for quick support.
</Info> <Info>
Running into issues? Join Infisical's [community Slack](https://infisical.com/slack) for quick support.
</Info>
## Use Infisical in a Jenkins Pipeline ## Use Infisical in a Jenkins Pipeline
To fetch secrets using Infisical in a Pipeline job, you'll need to expose the Jenkins credential you created above as an environment variable. To fetch secrets using Infisical in a Pipeline job, you'll need to expose the Jenkins credential you created above as an environment variable.
To do so, click **New Item** from the dashboard navigation sidebar: To do so, click **New Item** from the dashboard navigation sidebar:
![Jenkins step 6](../../images/integrations/jenkins/jenkins_6.png) ![Jenkins step 6](../../images/integrations/jenkins/jenkins_6.png)
Enter the name of the job, choose the **Pipeline** option, and click OK. Enter the name of the job, choose the **Pipeline** option, and click OK.
![Jenkins step 12](../../images/integrations/jenkins/jenkins_12.png) ![Jenkins step 12](../../images/integrations/jenkins/jenkins_12.png)
Scroll down to the **Pipeline** section, paste the following into the **Script** field, and click **Save**. Scroll down to the **Pipeline** section, paste the following into the **Script** field, and click **Save**.
``` ```
pipeline { pipeline {
agent any agent any
environment { environment {
INFISICAL_TOKEN = credentials('infisical-service-token') MACHINE_IDENTITY_CLIENT_ID = credentials('infisical-machine-identity-client-id')
} MACHINE_IDENTITY_CLIENT_SECRET = credentials('infisical-machine-identity-client-secret')
stages { }
stage('Run Infisical') {
steps {
sh("infisical secrets --env=dev --path=/")
// doesn't work stages {
// sh("docker run --rm test-container infisical secrets") stage('Run Infisical') {
steps {
sh("export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=${MACHINE_IDENTITY_CLIENT_ID} --client-secret=${MACHINE_IDENTITY_CLIENT_SECRET} --silent --plain)")
sh("infisical secrets --env=dev --path=/ --projectId=<your-project-id>")
// works // doesn't work
// sh("docker run -e INFISICAL_TOKEN=${INFISICAL_TOKEN} --rm test-container infisical secrets --env=dev --path=/") // sh("docker run --rm test-container infisical secrets --projectId=<your-project-id>")
// doesn't work // works
// sh("docker-compose up -d") // sh("docker run -e INFISICAL_TOKEN=${INFISICAL_TOKEN} --rm test-container infisical secrets --env=dev --path=/ --projectId=<your-project-id>")
// works // doesn't work
// sh("INFISICAL_TOKEN=${INFISICAL_TOKEN} docker-compose up -d") // sh("docker-compose up -d")
// works
// sh("INFISICAL_TOKEN=${INFISICAL_TOKEN} docker-compose up -d")
}
}
}
}
```
</Tab>
<Tab title="Service Token (Deprecated)">
## Add Infisical Service Token to Jenkins
<Warning>
Service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities).
They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
</Warning>
After setting up your project in Infisical and installing the Infisical CLI to the environment where your Jenkins builds will run, you will need to add the Infisical Service Token to Jenkins.
To generate a Infisical service token, follow the guide [here](/documentation/platform/token).
Once you have generated the token, navigate to **Manage Jenkins > Manage Credentials** in your Jenkins instance.
![Jenkins step 1](../../images/integrations/jenkins/jenkins_1.png)
Click on the credential store you want to store the Infisical Service Token in. In this case, we're using the default Jenkins global store.
<Info>
Each of your projects will have a different `INFISICAL_TOKEN`.
As a result, it may make sense to spread these out into separate credential domains depending on your use case.
</Info>
![Jenkins step 2](../../images/integrations/jenkins/jenkins_2.png)
Now, click Add Credentials.
![Jenkins step 3](../../images/integrations/jenkins/jenkins_3.png)
Choose **Secret text** for the **Kind** option from the dropdown list and enter the Infisical Service Token in the **Secret** field.
Although the **ID** can be any value, we'll set it to `infisical-service-token` for the sake of this guide.
The description is optional and can be any text you prefer.
![Jenkins step 4](../../images/integrations/jenkins/jenkins_4.png)
When you're done, you should see a credential similar to the one below:
![Jenkins step 5](../../images/integrations/jenkins/jenkins_5.png)
## Use Infisical in a Freestyle Project
To fetch secrets with Infisical in a Freestyle Project job, you'll need to expose the credential you created above as an environment variable to the Infisical CLI.
To do so, first click **New Item** from the dashboard navigation sidebar:
![Jenkins step 6](../../images/integrations/jenkins/jenkins_6.png)
Enter the name of the job, choose the **Freestyle Project** option, and click **OK**.
![Jenkins step 7](../../images/integrations/jenkins/jenkins_7.png)
Scroll down to the **Build Environment** section and enable the **Use secret text(s) or file(s)** option. Then click **Add** under the **Bindings** section and choose **Secret text** from the dropdown menu.
![Jenkins step 8](../../images/integrations/jenkins/jenkins_8.png)
Enter `INFISICAL_TOKEN` in the **Variable** field then click the **Specific credentials** option from the Credentials section and select the credential you created earlier.
In this case, we saved it as `Infisical service token` so we'll choose that from the dropdown menu.
![Jenkins step 9](../../images/integrations/jenkins/jenkins_9.png)
Scroll down to the **Build** section and choose **Execute shell** from the **Add build step** menu.
![Jenkins step 10](../../images/integrations/jenkins/jenkins_10.png)
In the command field, you can now use the Infisical CLI to fetch secrets.
The example command below will print the secrets using the service token passed as a credential. When done, click **Save**.
```
infisical secrets --env=dev --path=/
```
![Jenkins step 11](../../images/integrations/jenkins/jenkins_11.png)
Finally, click **Build Now** from the navigation sidebar to run your new job.
<Info>
Running into issues? Join Infisical's [community Slack](https://infisical.com/slack) for quick support.
</Info>
## Use Infisical in a Jenkins Pipeline
To fetch secrets using Infisical in a Pipeline job, you'll need to expose the Jenkins credential you created above as an environment variable.
To do so, click **New Item** from the dashboard navigation sidebar:
![Jenkins step 6](../../images/integrations/jenkins/jenkins_6.png)
Enter the name of the job, choose the **Pipeline** option, and click OK.
![Jenkins step 12](../../images/integrations/jenkins/jenkins_12.png)
Scroll down to the **Pipeline** section, paste the following into the **Script** field, and click **Save**.
```
pipeline {
agent any
environment {
INFISICAL_TOKEN = credentials('infisical-service-token')
}
stages {
stage('Run Infisical') {
steps {
sh("infisical secrets --env=dev --path=/")
// doesn't work
// sh("docker run --rm test-container infisical secrets")
// works
// sh("docker run -e INFISICAL_TOKEN=${INFISICAL_TOKEN} --rm test-container infisical secrets --env=dev --path=/")
// doesn't work
// sh("docker-compose up -d")
// works
// sh("INFISICAL_TOKEN=${INFISICAL_TOKEN} docker-compose up -d")
}
} }
} }
} }
} ```
```
</Tab>
</Tabs>
The example provided above serves as an initial guide. It shows how Jenkins adds the `INFISICAL_TOKEN` environment variable, which is configured in the pipeline, into the shell for executing commands. The example provided above serves as an initial guide. It shows how Jenkins adds the `INFISICAL_TOKEN` environment variable, which is configured in the pipeline, into the shell for executing commands.
There may be instances where this doesn't work as expected in the context of running Docker commands. There may be instances where this doesn't work as expected in the context of running Docker commands.
+113 -52
View File
@@ -4,6 +4,7 @@ description: "Learn how to sync secrets from Infisical to AWS Amplify."
--- ---
Prerequisites: Prerequisites:
- Infisical Cloud account - Infisical Cloud account
- Add the secrets you wish to sync to Amplify to [Infisical Cloud](https://app.infisical.com) - Add the secrets you wish to sync to Amplify to [Infisical Cloud](https://app.infisical.com)
@@ -13,64 +14,124 @@ There are many approaches to sync secrets stored within Infisical to AWS Amplify
This approach enables you to fetch secrets from Infisical during Amplify build time. This approach enables you to fetch secrets from Infisical during Amplify build time.
<Steps> <Tabs>
<Step title="Generate a service token">
Go to your project settings in the Infisical dashboard to generate a [service token](/documentation/platform/token). This service token will allow you to authenticate and fetch secrets from Infisical. Once you have created a service token with the required permissions, you’ll need to provide the token to the CLI installed in your Docker container.
</Step>
<Step title="Set the service token as an Amplify environment variable">
![aws amplify env console](../../images/integrations/aws/integrations-amplify-env-console.png)
1. In the Amplify console, choose App Settings, and then select Environment variables.
2. In the Environment variables section, select Manage variables.
3. Under Variable, enter the key **INFISICAL_TOKEN**. For the value, enter the generated service token from the previous step.
4. Click save.
</Step>
<Step title="Install Infisical CLI to the Amplify build step">
In the prebuild phase, add the command in AWS Amplify to install the Infisical CLI.
```yaml <Tab title="Machine Identity (Recommended)">
build: <Steps>
phases: <Step title="Create a machine identity">
preBuild: Create a machine identtiy and connect it to your Infisical project. You can read more about how to use machine identities [here](/documentation/platform/identities/machine-identities). The machine identity will allow you to authenticate and fetch secrets from Infisical.
commands: </Step>
- sudo curl -1sLf 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.rpm.sh' | sudo -E bash
- sudo yum -y install infisical
```
</Step>
<Step title="Modify the build command">
You can now pull secrets from Infisical using the CLI and save them as a `.env` file. To do this, modify the build commands.
```yaml <Step title="Set the machine identity client ID and client secret as Amplify environment variables">
build: ![aws amplify env console](../../images/integrations/aws/integrations-amplify-env-console-identity.png)
phases: 1. In the Amplify console, choose App Settings, and then select Environment variables.
2. In the Environment variables section, select Manage variables.
3. Under the first Variable enter `INFISICAL_MACHINE_IDENTITY_CLIENT_ID`, and for the value, enter the client ID of the machine identity you created in the previous step.
4. Under the second Variable enter `INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET`, and for the value, enter the client secret of the machine identity you created in the previous step.
5. Click save.
</Step>
<Step title="Install Infisical CLI to the Amplify build step">
In the prebuild phase, add the command in AWS Amplify to install the Infisical CLI.
```yaml
build: build:
commands: phases:
- INFISICAL_TOKEN=${INFISICAL_TOKEN} preBuild:
- infisical export --format=dotenv > .env commands:
- <rest of the commands> - sudo curl -1sLf 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.rpm.sh' | sudo -E bash
``` - sudo yum -y install infisical
</Step> ```
</Steps> </Step>
## Sync Secrets Using AWS SSM Parameter Store <Step title="Modify the build command">
You can now pull secrets from Infisical using the CLI and save them as a `.env` file. To do this, modify the build commands.
Another approach to use secrets from Infisical in AWS Amplify is to utilize AWS Parameter Store. ```yaml
At high level, you begin by using Infisical's AWS SSM Parameter Store integration to sync secrets from Infisical to AWS SSM Parameter Store. You then instruct AWS Amplify to consume those secrets from AWS SSM Parameter Store as [environment secrets](https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html#environment-secrets). build:
phases:
build:
commands:
- INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=${INFISICAL_MACHINE_IDENTITY_CLIENT_ID} --client-secret=${INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET} --silent --plain)
- infisical export --format=dotenv > .env
- <rest of the commands>
```
</Step>
</Steps>
<Steps> </Tab>
<Step title="Follow the AWS SSM Parameter Store Integration guide">
Follow the [Infisical AWS SSM Parameter Store Integration Guide](./aws-parameter-store) to set up the integration. Pause once you reach the step where it asks you to select the path you would like to sync. <Tab title="Service Token (Deprecated)">
</Step>
<Step title="Find your Amplify App ID"> <Warning>
![amplify app id](../../images/integrations/aws/integrations-amplify-app-id.png) Service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities).
1. Open your AWS Amplify App console.
2. Go to **Actions >> View App Settings** They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
3. The App ID will be the last part of the App ARN field after the slash. </Warning>
</Step>
<Step title="Set AWS SSM Parameter Store path"> <Steps>
You need to set the path in the format `/amplify/[amplify_app_id]/[your-amplify-environment-name]` as the path option in AWS SSM Parameter Infisical Integration. <Step title="Generate a service token">
</Step> Go to your project settings in the Infisical dashboard to generate a [service token](/documentation/platform/token). This service token will allow you to authenticate and fetch secrets from Infisical. Once you have created a service token with the required permissions, you’ll need to provide the token to the CLI installed in your Docker container.
</Steps> </Step>
<Step title="Set the service token as an Amplify environment variable">
![aws amplify env console](../../images/integrations/aws/integrations-amplify-env-console.png)
1. In the Amplify console, choose App Settings, and then select Environment variables.
2. In the Environment variables section, select Manage variables.
3. Under Variable, enter the key **INFISICAL_TOKEN**. For the value, enter the generated service token from the previous step.
4. Click save.
</Step>
<Step title="Install Infisical CLI to the Amplify build step">
In the prebuild phase, add the command in AWS Amplify to install the Infisical CLI.
```yaml
build:
phases:
preBuild:
commands:
- sudo curl -1sLf 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.rpm.sh' | sudo -E bash
- sudo yum -y install infisical
```
</Step>
<Step title="Modify the build command">
You can now pull secrets from Infisical using the CLI and save them as a `.env` file. To do this, modify the build commands.
```yaml
build:
phases:
build:
commands:
- INFISICAL_TOKEN=${INFISICAL_TOKEN}
- infisical export --format=dotenv > .env
- <rest of the commands>
```
</Step>
</Steps>
## Sync Secrets Using AWS SSM Parameter Store
Another approach to use secrets from Infisical in AWS Amplify is to utilize AWS Parameter Store.
At high level, you begin by using Infisical's AWS SSM Parameter Store integration to sync secrets from Infisical to AWS SSM Parameter Store. You then instruct AWS Amplify to consume those secrets from AWS SSM Parameter Store as [environment secrets](https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html#environment-secrets).
<Steps>
<Step title="Follow the AWS SSM Parameter Store Integration guide">
Follow the [Infisical AWS SSM Parameter Store Integration Guide](./aws-parameter-store) to set up the integration. Pause once you reach the step where it asks you to select the path you would like to sync.
</Step>
<Step title="Find your Amplify App ID">
![amplify app id](../../images/integrations/aws/integrations-amplify-app-id.png)
1. Open your AWS Amplify App console.
2. Go to **Actions >> View App Settings**
3. The App ID will be the last part of the App ARN field after the slash.
</Step>
<Step title="Set AWS SSM Parameter Store path">
You need to set the path in the format `/amplify/[amplify_app_id]/[your-amplify-environment-name]` as the path option in AWS SSM Parameter Infisical Integration.
</Step>
</Steps>
</Tab>
</Tabs>
<Info> <Info>
Accessing an environment secret during a build is similar to accessing environment variables, except that environment secrets are stored in `process.env.secrets` as a JSON string. Accessing an environment secret during a build is similar to accessing
environment variables, except that environment secrets are stored in
`process.env.secrets` as a JSON string.
</Info> </Info>
+4 -1
View File
@@ -34,7 +34,9 @@ Set up the Infisical provider by specifying the `host` and `service_token`. Repl
```hcl main.tf ```hcl main.tf
provider "infisical" { provider "infisical" {
host = "https://app.infisical.com" # Only required if using self hosted instance of Infisical, default is https://app.infisical.com host = "https://app.infisical.com" # Only required if using self hosted instance of Infisical, default is https://app.infisical.com
service_token = "<>" # Get token https://infisical.com/docs/documentation/platform/token client_id = "<>"
client_secret = "<>"
service_token = "<>" # DEPRECATED, USE MACHINE IDENTITY AUTH INSTEAD
} }
``` ```
@@ -54,6 +56,7 @@ Use the `infisical_secrets` data source to fetch your secrets. In this block, yo
data "infisical_secrets" "my-secrets" { data "infisical_secrets" "my-secrets" {
env_slug = "dev" env_slug = "dev"
folder_path = "/some-folder/another-folder" folder_path = "/some-folder/another-folder"
workspace_id = "your-project-id"
} }
``` ```
+94 -31
View File
@@ -11,46 +11,109 @@ Prerequisites:
Follow this [guide](./docker) to configure the Infisical CLI for each service that you wish to inject environment variables into; you'll have to update the Dockerfile of each service. Follow this [guide](./docker) to configure the Infisical CLI for each service that you wish to inject environment variables into; you'll have to update the Dockerfile of each service.
## Generate service token <Tabs>
<Tab title="Machine Identity (Recommended)">
### Generate and configure machine identity
Generate a machine identity for each service you want to inject secrets into. You can do this by following the steps in the [Machine Identity](/documentation/platform/identities/machine-identities) guide.
Generate a unique [Infisical Token](/documentation/platform/token) for each service. ### Set the machine identity client ID and client secret as environment variables
For each service you want to inject secrets into, set two environment variable called `INFISICAL_MACHINE_IDENTITY_CLIENT_ID`, and `INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET` equal to the client ID and client secret of the machine identity(s) you created in the previous step.
## Feed service token to your Docker Compose file In the example below, we set two sets of client ID and client secret for the services.
For each service you want to inject secrets into, set an environment variable called `INFISICAL_TOKEN` equal to a unique identifier variable. For the web service we set `INFISICAL_MACHINE_IDENTITY_CLIENT_ID_FOR_WEB` and `INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET_FOR_WEB` as the client ID and client secret respectively.
In the example below, we set `INFISICAL_TOKEN_FOR_WEB` and `INFISICAL_TOKEN_FOR_API` as the `INFISICAL_TOKEN` for the services. For the API service we set `INFISICAL_MACHINE_IDENTITY_CLIENT_ID_FOR_API` and `INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET_FOR_API` as the client ID and client secret respectively.
```yaml ```yaml
# Example Docker Compose file # Example Docker Compose file
services: services:
web: web:
build: . build: .
image: example-service-1 image: example-service-1
environment: environment:
- INFISICAL_TOKEN=${INFISICAL_TOKEN_FOR_WEB} - INFISICAL_MACHINE_IDENTITY_CLIENT_ID=${INFISICAL_MACHINE_IDENTITY_CLIENT_ID_FOR_WEB}
- INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET=${INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET_FOR_WEB}
api: api:
build: . build: .
image: example-service-2 image: example-service-2
environment: environment:
- INFISICAL_TOKEN=${INFISICAL_TOKEN_FOR_API} - INFISICAL_MACHINE_IDENTITY_CLIENT_ID=${INFISICAL_MACHINE_IDENTITY_CLIENT_ID_FOR_API}
``` - INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET=${INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET_FOR_API}
## Export shell variables ```
Next, set the shell variables you defined in your compose file. This can be done manually or via your CI/CD environment. Once done, it will be used to populate the corresponding `INFISICAL_TOKEN` ### Export shell variables
in your Docker Compose file. Next, set the shell variables you defined in your compose file. This can be done manually or via your CI/CD environment. Once done, it will be used to populate the corresponding `INFISICAL_MACHINE_IDENTITY_CLIENT_ID` and `INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET` in your Docker Compose file.
```bash ```bash
#Example #Example
# Token refers to the token we generated in step 2 for this service # Token refers to the token we generated in step 2 for this service
export INFISICAL_TOKEN_FOR_WEB=<token> export INFISICAL_MACHINE_IDENTITY_CLIENT_ID_FOR_WEB=<client_id>
export INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET_FOR_WEB=<client_secret>
# Token refers to the token we generated in step 2 for this service # Token refers to the token we generated in step 2 for this service
export INFISICAL_TOKEN_FOR_API=<token> export INFISICAL_MACHINE_IDENTITY_CLIENT_ID_FOR_API=<client_id>
export INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET_FOR_API=<client_secret>
# Then run your compose file in the same terminal. # Then run your compose file in the same terminal.
docker-compose ... docker-compose ...
``` ```
</Tab>
<Tab title="Service Token (Deprecated)">
<Warning>
Service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities).
They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
</Warning>
## Generate service token
Generate a unique [Service Token](/documentation/platform/token) for each service.
## Feed service token to your Docker Compose file
For each service you want to inject secrets into, set an environment variable called `INFISICAL_TOKEN` equal to a unique identifier variable.
In the example below, we set `INFISICAL_TOKEN_FOR_WEB` and `INFISICAL_TOKEN_FOR_API` as the `INFISICAL_TOKEN` for the services.
```yaml
# Example Docker Compose file
services:
web:
build: .
image: example-service-1
environment:
- INFISICAL_TOKEN=${INFISICAL_TOKEN_FOR_WEB}
api:
build: .
image: example-service-2
environment:
- INFISICAL_TOKEN=${INFISICAL_TOKEN_FOR_API}
```
## Export shell variables
Next, set the shell variables you defined in your compose file. This can be done manually or via your CI/CD environment. Once done, it will be used to populate the corresponding `INFISICAL_TOKEN`
in your Docker Compose file.
```bash
#Example
# Token refers to the token we generated in step 2 for this service
export INFISICAL_TOKEN_FOR_WEB=<token>
# Token refers to the token we generated in step 2 for this service
export INFISICAL_TOKEN_FOR_API=<token>
# Then run your compose file in the same terminal.
docker-compose ...
```
</Tab>
</Tabs>
@@ -10,8 +10,11 @@ For this method to function as expected, you must have a bash shell (for process
## 1. Authentication ## 1. Authentication
If you are already logged in via the CLI you can skip this step. Otherwise, head to your project settings in Infisical Cloud to generate an [Infisical Token](/documentation/platform/token). The service token will allow you to authenticate and fetch secrets from Infisical. If you are already logged in via the CLI you can skip this step. Otherwise, head to your organization settings in Infisical Cloud to create a [Machine Identity](../../documentation/platform/identities/machine-identities). The machine identity will allow you to authenticate and fetch secrets from Infisical.
Once you have created a service token with the required permissions, you'll need to feed the token to the CLI. Once you have created a machine identity with the required permissions, you'll need to feed the token to the CLI.
<Info>
Please note that we highly recommend using `infisical login` for local development.
</Info>
#### Pass as flag #### Pass as flag
You may use the --token flag to set the token You may use the --token flag to set the token
@@ -27,8 +30,14 @@ The CLI is configured to look for an environment variable named `INFISICAL_TOKEN
export INFISICAL_TOKEN=<> export INFISICAL_TOKEN=<>
``` ```
You can use the `infisical login --method=universal-auth` command to directly obtain a universal auth access token and set it as an environment variable.
```bash
export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=<your-client-id> --client-secret=<your-client-secret> --silent --plain)
```
<Warning> <Warning>
In production scenarios, please to avoid using the `infisical login` command and instead use a [service token](/documentation/platform/token). In production scenarios, please to avoid using the `infisical login` command and instead use a [machine identity](../../documentation/platform/identities/machine-identities).
</Warning> </Warning>
## 2. Run your docker command with Infisical ## 2. Run your docker command with Infisical
+65 -12
View File
@@ -41,6 +41,54 @@ This is achieved by installing the Infisical CLI into your docker image and modi
Starting your service with the Infisical CLI pulls your secrets from Infisical and injects them into your service. Starting your service with the Infisical CLI pulls your secrets from Infisical and injects them into your service.
<Tabs>
<Tab title="Machine Identity (Recommended)">
```dockerfile
CMD ["infisical", "run", "--projectId", "<your-project-id>", "--", "[your service start command]"]
# example with single single command
CMD ["infisical", "run", "--projectId", "<your-project-id>", "--", "npm", "run", "start"]
# example with multiple commands
CMD ["infisical", "run", "--projectId", "<your-project-id>", "--command", "npm run start && ..."]
````
<Steps>
<Step title="Generate a machine identity">
Generate a machine identity for your project by following the steps in the [Machine Identity](/documentation/platform/identities/machine-identities) guide. The machine identity will allow you to authenticate and fetch secrets from Infisical.
</Step>
<Step title="Obtain an access token for the machine identity">
Obtain an access token for the machine identity by running the following command:
```bash
export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=<your-client-id> --client-secret=<your-client-secret> --plain --silent)
```
<Info>
Please note that the access token has a limited lifespan. The `infisical token renew` command can be used to renew the token if needed.
</Info>
</Step>
<Step title="Feed the access token to the docker container">
The last step is to give the Infisical CLI installed in your Docker container access to the access token. This will allow the CLI to fetch and inject the secrets into your application.
To feed the access token to the container, use the INFISICAL_TOKEN environment variable as shown below.
```bash
docker run --env INFISICAL_TOKEN=$INFISICAL_TOKEN [DOCKER-IMAGE]...
```
</Step>
</Steps>
</Tab>
<Tab title="Service Token (Deprecated)">
<Warning>
Service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities).
They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
</Warning>
```dockerfile ```dockerfile
CMD ["infisical", "run", "--", "[your service start command]"] CMD ["infisical", "run", "--", "[your service start command]"]
@@ -49,19 +97,24 @@ CMD ["infisical", "run", "--", "npm", "run", "start"]
# example with multiple commands # example with multiple commands
CMD ["infisical", "run", "--command", "npm run start && ..."] CMD ["infisical", "run", "--command", "npm run start && ..."]
``` ````
## Generate a service token <Steps>
<Step title="Generate a service token">
Head to your project settings in the Infisical dashboard to generate an [service token](/documentation/platform/token).
This service token will allow you to authenticate and fetch secrets from Infisical.
Once you have created a service token with the required permissions, you’ll need to feed the token to the CLI installed in your docker container.
</Step>
<Step title="Feed service token to docker container">
The last step is to give the Infisical CLI installed in your Docker container access to the service token. This will allow the CLI to fetch and inject the secrets into your application.
Head to your project settings in the Infisical dashboard to generate an [service token](/documentation/platform/token). To feed the service token to the container, use the INFISICAL_TOKEN environment variable as shown below.
This service token will allow you to authenticate and fetch secrets from Infisical.
Once you have created a service token with the required permissions, you’ll need to feed the token to the CLI installed in your docker container.
## Feed service token to docker container ```bash
The last step is to give the Infisical CLI installed in your Docker container access to the service token. This will allow the CLI to fetch and inject the secrets into your application. docker run --env INFISICAL_TOKEN=[token] [DOCKER-IMAGE]...
```
</Step>
To feed the service token to the container, use the INFISICAL_TOKEN environment variable as shown below. </Steps>
</Tab>
```bash </Tabs>
docker run --env INFISICAL_TOKEN=[token] [DOCKER-IMAGE]...
```
+237 -204
View File
@@ -1,11 +1,10 @@
--- ---
title: 'Kubernetes' title: "Kubernetes"
description: "How to use Infisical to inject secrets into Kubernetes clusters." description: "How to use Infisical to inject secrets into Kubernetes clusters."
--- ---
![title](../../images/k8-diagram.png) ![title](../../images/k8-diagram.png)
The Infisical Secrets Operator is a Kubernetes controller that retrieves secrets from Infisical and stores them in a designated cluster. The Infisical Secrets Operator is a Kubernetes controller that retrieves secrets from Infisical and stores them in a designated cluster.
It uses an `InfisicalSecret` resource to specify authentication and storage methods. It uses an `InfisicalSecret` resource to specify authentication and storage methods.
The operator continuously updates secrets and can also reload dependent deployments automatically. The operator continuously updates secrets and can also reload dependent deployments automatically.
@@ -42,66 +41,69 @@ The operator can be install via [Helm](https://helm.sh) or [kubectl](https://git
For production deployments, it is highly recommended to set the version of the Kubernetes operator manually instead of pointing to the latest version. For production deployments, it is highly recommended to set the version of the Kubernetes operator manually instead of pointing to the latest version.
Doing so will help you avoid accidental updates to the newest release which may introduce unintended breaking changes. View all application versions [here](https://hub.docker.com/r/infisical/kubernetes-operator/tags). Doing so will help you avoid accidental updates to the newest release which may introduce unintended breaking changes. View all application versions [here](https://hub.docker.com/r/infisical/kubernetes-operator/tags).
The command below will install the most recent version of the Kubernetes operator.
However, to set the version manually, download the manifest and set the image tag version of `infisical/kubernetes-operator` according to your desired version.
The command below will install the most recent version of the Kubernetes operator. Once you apply the manifest, the operator will be installed in `infisical-operator-system` namespace.
However, to set the version manually, download the manifest and set the image tag version of `infisical/kubernetes-operator` according to your desired version.
Once you apply the manifest, the operator will be installed in `infisical-operator-system` namespace.
``` ```
kubectl apply -f https://raw.githubusercontent.com/Infisical/infisical/main/k8-operator/kubectl-install/install-secrets-operator.yaml kubectl apply -f https://raw.githubusercontent.com/Infisical/infisical/main/k8-operator/kubectl-install/install-secrets-operator.yaml
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
## Sync Infisical Secrets to your cluster ## Sync Infisical Secrets to your cluster
Once you have installed the operator to your cluster, you'll need to create a `InfisicalSecret` custom resource definition (CRD). Once you have installed the operator to your cluster, you'll need to create a `InfisicalSecret` custom resource definition (CRD).
```yaml example-infisical-secret-crd.yaml ```yaml example-infisical-secret-crd.yaml
apiVersion: secrets.infisical.com/v1alpha1 apiVersion: secrets.infisical.com/v1alpha1
kind: InfisicalSecret kind: InfisicalSecret
metadata: metadata:
name: infisicalsecret-sample name: infisicalsecret-sample
labels: labels:
label-to-be-passed-to-managed-secret: sample-value label-to-be-passed-to-managed-secret: sample-value
annotations: annotations:
example.com/annotation-to-be-passed-to-managed-secret: "sample-value" example.com/annotation-to-be-passed-to-managed-secret: "sample-value"
spec: spec:
hostAPI: https://app.infisical.com/api hostAPI: https://app.infisical.com/api
resyncInterval: 10 resyncInterval: 10
authentication: authentication:
# Make sure to only have 1 authentication method defined, serviceToken/universalAuth. # Make sure to only have 1 authentication method defined, serviceToken/universalAuth.
# If you have multiple authentication methods defined, it may cause issues. # If you have multiple authentication methods defined, it may cause issues.
universalAuth: universalAuth:
secretsScope: secretsScope:
projectSlug: <project-slug> projectSlug: <project-slug>
envSlug: <env-slug> # "dev", "staging", "prod", etc.. envSlug: <env-slug> # "dev", "staging", "prod", etc..
secretsPath: "<secrets-path>" # Root is "/" secretsPath: "<secrets-path>" # Root is "/"
credentialsRef: credentialsRef:
secretName: universal-auth-credentials secretName: universal-auth-credentials
secretNamespace: default
serviceToken:
serviceTokenSecretReference:
secretName: service-token
secretNamespace: default
secretsScope:
envSlug: <env-slug>
secretsPath: <secrets-path> # Root is "/"
managedSecretReference:
secretName: managed-secret
secretNamespace: default secretNamespace: default
creationPolicy: "Orphan" ## Owner | Orphan (default)
# secretType: kubernetes.io/dockerconfigjson # Service tokens are deprecated and will be removed in the near future. Please use Machine Identities for authenticating with Infisical.
serviceToken:
serviceTokenSecretReference:
secretName: service-token
secretNamespace: default
secretsScope:
envSlug: <env-slug>
secretsPath: <secrets-path> # Root is "/"
managedSecretReference:
secretName: managed-secret
secretNamespace: default
creationPolicy: "Orphan" ## Owner | Orphan (default)
# secretType: kubernetes.io/dockerconfigjson
``` ```
### InfisicalSecret CRD properties ### InfisicalSecret CRD properties
<Accordion title="hostAPI"> <Accordion title="hostAPI">
If you are fetching secrets from a self hosted instance of Infisical set the value of `hostAPI` to If you are fetching secrets from a self hosted instance of Infisical set the value of `hostAPI` to
` https://your-self-hosted-instace.com/api` ` https://your-self-hosted-instace.com/api`
When `hostAPI` is not defined the operator fetches secrets from Infisical Cloud. When `hostAPI` is not defined the operator fetches secrets from Infisical Cloud.
<Accordion title="Advanced use case"> <Accordion title="Advanced use case">
If you have installed your Infisical instance within the same cluster as the Infisical operator, you can optionally access the Infisical backend's service directly without having to route through the public internet. If you have installed your Infisical instance within the same cluster as the Infisical operator, you can optionally access the Infisical backend's service directly without having to route through the public internet.
@@ -112,16 +114,19 @@ spec:
``` ```
Make sure to replace `<backend-svc-name>` and `<namespace>` with the appropriate values for your backend service and namespace. Make sure to replace `<backend-svc-name>` and `<namespace>` with the appropriate values for your backend service and namespace.
</Accordion> </Accordion>
</Accordion> </Accordion>
<Accordion title="resyncInterval"> <Accordion title="resyncInterval">
This property defines the time in seconds between each secret re-sync from Infisical. Shorter time between re-syncs will require higher rate limits only available on paid plans. This property defines the time in seconds between each secret re-sync from
Default re-sync interval is every 1 minute. Infisical. Shorter time between re-syncs will require higher rate limits only
available on paid plans. Default re-sync interval is every 1 minute.
</Accordion> </Accordion>
<Accordion title="authentication"> <Accordion title="authentication">
This block defines the method that will be used to authenticate with Infisical so that secrets can be fetched This block defines the method that will be used to authenticate with Infisical
so that secrets can be fetched
</Accordion> </Accordion>
<Accordion title="authentication.universalAuth"> <Accordion title="authentication.universalAuth">
@@ -145,76 +150,95 @@ Default re-sync interval is every 1 minute.
<Step title="Add reference for the Kubernetes secret containing the identity credentials"> <Step title="Add reference for the Kubernetes secret containing the identity credentials">
Once the secret is created, add the `secretName` and `secretNamespace` of the secret that was just created under `authentication.universalAuth.credentialsRef` field in the InfisicalSecret resource. Once the secret is created, add the `secretName` and `secretNamespace` of the secret that was just created under `authentication.universalAuth.credentialsRef` field in the InfisicalSecret resource.
</Step> </Step>
</Steps> </Steps>
{" "}
<Info>
Make sure to also populate the `secretsScope` field with the project slug
_`projectSlug`_, environment slug _`envSlug`_, and secrets path
_`secretsPath`_ that you want to fetch secrets from. Please see the example
below.
</Info>
<Info> ## Example
Make sure to also populate the `secretsScope` field with the project slug _`projectSlug`_, environment slug _`envSlug`_, and secrets path _`secretsPath`_ that you want to fetch secrets from. Please see the example below.
</Info> ```yaml
apiVersion: secrets.infisical.com/v1alpha1
kind: InfisicalSecret
metadata:
name: infisicalsecret-sample-crd
spec:
authentication:
universalAuth:
secretsScope:
projectSlug: <project-slug> # <-- project slug
envSlug: <env-slug> # "dev", "staging", "prod", etc..
secretsPath: "<secrets-path>" # Root is "/"
credentialsRef:
secretName: universal-auth-credentials # <-- name of the Kubernetes secret that stores our machine identity credentials
secretNamespace: default # <-- namespace of the Kubernetes secret that stores our machine identity credentials
...
```
## Example
```yaml
apiVersion: secrets.infisical.com/v1alpha1
kind: InfisicalSecret
metadata:
name: infisicalsecret-sample-crd
spec:
authentication:
universalAuth:
secretsScope:
projectSlug: <project-slug> # <-- project slug
envSlug: <env-slug> # "dev", "staging", "prod", etc..
secretsPath: "<secrets-path>" # Root is "/"
credentialsRef:
secretName: universal-auth-credentials # <-- name of the Kubernetes secret that stores our machine identity credentials
secretNamespace: default # <-- namespace of the Kubernetes secret that stores our machine identity credentials
...
```
</Accordion> </Accordion>
<Accordion title="authentication.serviceToken"> <Accordion title="authentication.serviceToken">
The service token required to authenticate with Infisical needs to be stored in a Kubernetes secret. This block defines the reference to the name and namespace of secret that stores this service token. <Warning>
Follow the instructions below to create and store the service token in a Kubernetes secrets and reference it in your CRD. Service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities).
#### 1. Generate service token They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
You can generate a [service token](../../documentation/platform/token) for an Infisical project by heading over to the Infisical dashboard then to Project Settings. </Warning>
#### 2. Create Kubernetes secret containing service token The service token required to authenticate with Infisical needs to be stored in a Kubernetes secret. This block defines the reference to the name and namespace of secret that stores this service token.
Follow the instructions below to create and store the service token in a Kubernetes secrets and reference it in your CRD.
Once you have generated the service token, you will need to create a Kubernetes secret containing the service token you generated. #### 1. Generate service token
To quickly create a Kubernetes secret containing the generated service token, you can run the command below. Make sure you replace `<your-service-token-here>` with your service token.
``` bash You can generate a [service token](../../documentation/platform/token) for an Infisical project by heading over to the Infisical dashboard then to Project Settings.
kubectl create secret generic service-token --from-literal=infisicalToken="<your-service-token-here>"
```
#### 3. Add reference for the Kubernetes secret containing service token #### 2. Create Kubernetes secret containing service token
Once the secret is created, add the name and namespace of the secret that was just created under `authentication.serviceToken.serviceTokenSecretReference` field in the InfisicalSecret resource. Once you have generated the service token, you will need to create a Kubernetes secret containing the service token you generated.
To quickly create a Kubernetes secret containing the generated service token, you can run the command below. Make sure you replace `<your-service-token-here>` with your service token.
<Info> ```bash
Make sure to also populate the `secretsScope` field with the, environment slug _`envSlug`_, and secrets path _`secretsPath`_ that you want to fetch secrets from. Please see the example below. kubectl create secret generic service-token --from-literal=infisicalToken="<your-service-token-here>"
</Info> ```
#### 3. Add reference for the Kubernetes secret containing service token
Once the secret is created, add the name and namespace of the secret that was just created under `authentication.serviceToken.serviceTokenSecretReference` field in the InfisicalSecret resource.
{" "}
<Info>
Make sure to also populate the `secretsScope` field with the, environment slug
_`envSlug`_, and secrets path _`secretsPath`_ that you want to fetch secrets
from. Please see the example below.
</Info>
## Example
```yaml
apiVersion: secrets.infisical.com/v1alpha1
kind: InfisicalSecret
metadata:
name: infisicalsecret-sample-crd
spec:
authentication:
serviceToken:
serviceTokenSecretReference:
secretName: service-token # <-- name of the Kubernetes secret that stores our service token
secretNamespace: option # <-- namespace of the Kubernetes secret that stores our service token
secretsScope:
envSlug: <env-slug> # "dev", "staging", "prod", etc..
secretsPath: <secrets-path> # Root is "/"
...
```
## Example
```yaml
apiVersion: secrets.infisical.com/v1alpha1
kind: InfisicalSecret
metadata:
name: infisicalsecret-sample-crd
spec:
authentication:
serviceToken:
serviceTokenSecretReference:
secretName: service-token # <-- name of the Kubernetes secret that stores our service token
secretNamespace: option # <-- namespace of the Kubernetes secret that stores our service token
secretsScope:
envSlug: <env-slug> # "dev", "staging", "prod", etc..
secretsPath: <secrets-path> # Root is "/"
...
```
</Accordion> </Accordion>
<Accordion title="managedSecretReference"> <Accordion title="managedSecretReference">
@@ -239,11 +263,13 @@ Creation polices allow you to control whether or not owner references should be
This is useful for tools such as ArgoCD, where every resource requires an owner reference; otherwise, it will be pruned automatically. This is useful for tools such as ArgoCD, where every resource requires an owner reference; otherwise, it will be pruned automatically.
#### Available options #### Available options
- `Orphan` (default) - `Orphan` (default)
- `Owner` - `Owner`
<Tip> <Tip>
When creation policy is set to `Owner`, the `InfisicalSecret` CRD must be in the same namespace as where the managed kubernetes secret. When creation policy is set to `Owner`, the `InfisicalSecret` CRD must be in
the same namespace as where the managed kubernetes secret.
</Tip> </Tip>
</Accordion> </Accordion>
@@ -275,8 +301,7 @@ This would result in the following managed secret to be created:
```yaml ```yaml
apiVersion: v1 apiVersion: v1
data: data: ...
...
kind: Secret kind: Secret
metadata: metadata:
annotations: annotations:
@@ -288,10 +313,11 @@ metadata:
namespace: default namespace: default
type: Opaque type: Opaque
``` ```
</Accordion> </Accordion>
### Apply the Infisical CRD to your cluster ### Apply the Infisical CRD to your cluster
Once you have configured the Infisical CRD with the required fields, you can apply it to your cluster. Once you have configured the Infisical CRD with the required fields, you can apply it to your cluster.
After applying, you should notice that the managed secret has been created in the desired namespace your specified. After applying, you should notice that the managed secret has been created in the desired namespace your specified.
@@ -314,47 +340,48 @@ kubectl get secrets -n <namespace of managed secret>
</Info> </Info>
### Using managed secret in your deployment ### Using managed secret in your deployment
Incorporating the managed secret created by the operator into your deployment can be achieved through several methods. Incorporating the managed secret created by the operator into your deployment can be achieved through several methods.
Here, we will highlight three of the most common ways to utilize it. Learn more about Kubernetes secrets [here](https://kubernetes.io/docs/concepts/configuration/secret/) Here, we will highlight three of the most common ways to utilize it. Learn more about Kubernetes secrets [here](https://kubernetes.io/docs/concepts/configuration/secret/)
<Accordion title="envFrom"> <Accordion title="envFrom">
This will take all the secrets from your managed secret and expose them to your container This will take all the secrets from your managed secret and expose them to your container
```yaml ````yaml
envFrom: envFrom:
- secretRef: - secretRef:
name: managed-secret # managed secret name name: managed-secret # managed secret name
```
Example usage in a deployment
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
envFrom:
- secretRef:
name: managed-secret # <- name of managed secret
ports:
- containerPort: 80
``` ```
</Accordion>
Example usage in a deployment
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
envFrom:
- secretRef:
name: managed-secret # <- name of managed secret
ports:
- containerPort: 80
````
</Accordion>
<Accordion title="env"> <Accordion title="env">
This will allow you to select individual secrets by key name from your managed secret and expose them to your container This will allow you to select individual secrets by key name from your managed secret and expose them to your container
@@ -368,95 +395,101 @@ Here, we will highlight three of the most common ways to utilize it. Learn more
key: SOME_SECRET_KEY # The name of the key which exists in the managed secret key: SOME_SECRET_KEY # The name of the key which exists in the managed secret
``` ```
Example usage in a deployment Example usage in a deployment
```yaml
apiVersion: apps/v1 ```yaml
kind: Deployment apiVersion: apps/v1
metadata: kind: Deployment
name: nginx-deployment metadata:
labels: name: nginx-deployment
app: nginx labels:
spec: app: nginx
replicas: 1 spec:
selector: replicas: 1
matchLabels: selector:
app: nginx matchLabels:
template: app: nginx
metadata: template:
labels: metadata:
app: nginx labels:
spec: app: nginx
containers: spec:
- name: nginx containers: - name: nginx
image: nginx:1.14.2 image: nginx:1.14.2
env: env: - name: STRIPE_API_SECRET
- name: STRIPE_API_SECRET valueFrom:
valueFrom: secretKeyRef:
secretKeyRef: name: managed-secret # <- name of managed secret
name: managed-secret # <- name of managed secret key: STRIPE_API_SECRET
key: STRIPE_API_SECRET ports: - containerPort: 80
ports:
- containerPort: 80 ```
```
</Accordion> </Accordion>
<Accordion title="volumes"> <Accordion title="volumes">
This will allow you to create a volume on your container which comprises of files holding the secrets in your managed kubernetes secret This will allow you to create a volume on your container which comprises of files holding the secrets in your managed kubernetes secret
```yaml ```yaml
volumes: volumes:
- name: secrets-volume-name # The name of the volume under which secrets will be stored - name: secrets-volume-name # The name of the volume under which secrets will be stored
secret: secret:
secretName: managed-secret # managed secret name secretName: managed-secret # managed secret name
``` ````
You can then mount this volume to the container's filesystem so that your deployment can access the files containing the managed secrets You can then mount this volume to the container's filesystem so that your deployment can access the files containing the managed secrets
```yaml
volumeMounts:
- name: secrets-volume-name
mountPath: /etc/secrets
readOnly: true
```
Example usage in a deployment ```yaml
```yaml volumeMounts:
apiVersion: apps/v1 - name: secrets-volume-name
kind: Deployment mountPath: /etc/secrets
metadata: readOnly: true
name: nginx-deployment ```
labels:
Example usage in a deployment
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx app: nginx
spec: template:
replicas: 1 metadata:
selector: labels:
matchLabels:
app: nginx app: nginx
template: spec:
metadata: containers:
labels:
app: nginx
spec:
containers:
- name: nginx - name: nginx
image: nginx:1.14.2 image: nginx:1.14.2
volumeMounts: volumeMounts:
- name: secrets-volume-name - name: secrets-volume-name
mountPath: /etc/secrets mountPath: /etc/secrets
readOnly: true readOnly: true
ports: ports:
- containerPort: 80 - containerPort: 80
volumes: volumes:
- name: secrets-volume-name - name: secrets-volume-name
secret: secret:
secretName: managed-secret # <- managed secrets secretName: managed-secret # <- managed secrets
``` ```
</Accordion> </Accordion>
## Auto redeployment ## Auto redeployment
Deployments using managed secrets don't reload automatically on updates, so they may use outdated secrets unless manually redeployed. Deployments using managed secrets don't reload automatically on updates, so they may use outdated secrets unless manually redeployed.
To address this, we added functionality to automatically redeploy your deployment when its managed secret updates. To address this, we added functionality to automatically redeploy your deployment when its managed secret updates.
### Enabling auto redeploy ### Enabling auto redeploy
To enable auto redeployment you simply have to add the following annotation to the deployment that consumes a managed secret To enable auto redeployment you simply have to add the following annotation to the deployment that consumes a managed secret
```yaml ```yaml
secrets.infisical.com/auto-reload: "true" secrets.infisical.com/auto-reload: "true"
``` ```
@@ -493,16 +526,18 @@ spec:
</Accordion> </Accordion>
## Global configuration ## Global configuration
To configure global settings that will apply to all instances of `InfisicalSecret`, you can define these configurations in a Kubernetes ConfigMap. To configure global settings that will apply to all instances of `InfisicalSecret`, you can define these configurations in a Kubernetes ConfigMap.
For example, you can configure all `InfisicalSecret` instances to fetch secrets from a single backend API without specifying the `hostAPI` parameter for each instance. For example, you can configure all `InfisicalSecret` instances to fetch secrets from a single backend API without specifying the `hostAPI` parameter for each instance.
### Available global properties ### Available global properties
| Property | Description | Default value
| -------- | ------------------------------------- |------------------------
| hostAPI | If `hostAPI` in `InfisicalSecret` instance is left empty, this value will be used | https://app.infisical.com/api
| Property | Description | Default value |
| -------- | --------------------------------------------------------------------------------- | ----------------------------- |
| hostAPI | If `hostAPI` in `InfisicalSecret` instance is left empty, this value will be used | https://app.infisical.com/api |
### Applying global configurations ### Applying global configurations
All global configurations must reside in a Kubernetes ConfigMap named `infisical-config` in the namespace `infisical-operator-system`. All global configurations must reside in a Kubernetes ConfigMap named `infisical-config` in the namespace `infisical-operator-system`.
To apply global configuration to the operator, copy the following yaml into `infisical-config.yaml` file. To apply global configuration to the operator, copy the following yaml into `infisical-config.yaml` file.
@@ -527,7 +562,6 @@ Then apply this change via kubectl by running the following
kubectl apply -f infisical-config.yaml kubectl apply -f infisical-config.yaml
``` ```
## Troubleshoot operator ## Troubleshoot operator
If the operator is unable to fetch secrets from the API, it will not affect the managed Kubernetes secret. If the operator is unable to fetch secrets from the API, it will not affect the managed Kubernetes secret.
@@ -576,7 +610,6 @@ The managed secret created by the operator will not be deleted when the operator
</Tab> </Tab>
</Tabs> </Tabs>
## Useful Articles ## Useful Articles
- [Managing secrets in OpenShift with Infisical](https://xphyr.net/post/infisical_ocp/) - [Managing secrets in OpenShift with Infisical](https://xphyr.net/post/infisical_ocp/)
+1 -1
View File
@@ -32,6 +32,6 @@ This section covers the internals of Infisical including its technical underpinn
icon="ticket" icon="ticket"
color="#000000" color="#000000"
> >
Learn best practices for utilizing Infisical service tokens. Learn best practices for utilizing Infisical service tokens. Please note that service tokens are now deprecated and will be removed entirely in the future.
</Card> </Card>
</CardGroup> </CardGroup>
+8
View File
@@ -2,6 +2,13 @@
title: "Service tokens" title: "Service tokens"
description: "Understanding service tokens and their best practices." description: "Understanding service tokens and their best practices."
--- ---
<Warning>
Service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities).
They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
</Warning>
​ ​
Many clients use service tokens to authenticate and read/write secrets from/to Infisical; they can be created in your project settings. Many clients use service tokens to authenticate and read/write secrets from/to Infisical; they can be created in your project settings.
@@ -28,6 +35,7 @@ Consider the token `st.abc.def.ghi`. Here, `st.abc.def` can be used to authentic
Note that when using service tokens via select client methods like SDK or CLI, cryptographic operations are abstracted for you that is the token is parsed and encryption/decryption operations are handled. If using service tokens with the REST API and end-to-end encryption enabled, then you will have to handle the encryption/decryption operations yourself. Note that when using service tokens via select client methods like SDK or CLI, cryptographic operations are abstracted for you that is the token is parsed and encryption/decryption operations are handled. If using service tokens with the REST API and end-to-end encryption enabled, then you will have to handle the encryption/decryption operations yourself.
​ ​
## Recommendations ## Recommendations
### Issuance ### Issuance
+9 -30
View File
@@ -32,10 +32,7 @@
"thumbsRating": true "thumbsRating": true
}, },
"api": { "api": {
"baseUrl": [ "baseUrl": ["https://app.infisical.com", "http://localhost:8080"]
"https://app.infisical.com",
"http://localhost:8080"
]
}, },
"topbarLinks": [ "topbarLinks": [
{ {
@@ -76,11 +73,7 @@
"documentation/getting-started/introduction", "documentation/getting-started/introduction",
{ {
"group": "Quickstart", "group": "Quickstart",
"pages": [ "pages": ["documentation/guides/local-development"]
"documentation/guides/local-development",
"documentation/guides/staging",
"documentation/guides/production"
]
}, },
{ {
"group": "Guides", "group": "Guides",
@@ -375,15 +368,11 @@
}, },
{ {
"group": "Build Tool Integrations", "group": "Build Tool Integrations",
"pages": [ "pages": ["integrations/build-tools/gradle"]
"integrations/build-tools/gradle"
]
}, },
{ {
"group": "", "group": "",
"pages": [ "pages": ["sdks/overview"]
"sdks/overview"
]
}, },
{ {
"group": "SDK's", "group": "SDK's",
@@ -401,9 +390,7 @@
"api-reference/overview/authentication", "api-reference/overview/authentication",
{ {
"group": "Examples", "group": "Examples",
"pages": [ "pages": ["api-reference/overview/examples/integration"]
"api-reference/overview/examples/integration"
]
} }
] ]
}, },
@@ -532,15 +519,11 @@
}, },
{ {
"group": "Service Tokens", "group": "Service Tokens",
"pages": [ "pages": ["api-reference/endpoints/service-tokens/get"]
"api-reference/endpoints/service-tokens/get"
]
}, },
{ {
"group": "Audit Logs", "group": "Audit Logs",
"pages": [ "pages": ["api-reference/endpoints/audit-logs/export-audit-log"]
"api-reference/endpoints/audit-logs/export-audit-log"
]
} }
] ]
}, },
@@ -556,9 +539,7 @@
}, },
{ {
"group": "", "group": "",
"pages": [ "pages": ["changelog/overview"]
"changelog/overview"
]
}, },
{ {
"group": "Contributing", "group": "Contributing",
@@ -582,9 +563,7 @@
}, },
{ {
"group": "Contributing to SDK", "group": "Contributing to SDK",
"pages": [ "pages": ["contributing/sdk/developing"]
"contributing/sdk/developing"
]
} }
] ]
} }