infisical bootstrap
Automate the initial setup of a new Infisical instance for headless deployment and infrastructure-as-code workflows
Description
The infisical bootstrap
command is used when deploying Infisical in automated environments where manual UI setup is not feasible. Itβs ideal for:
- Containerized deployments in Kubernetes or Docker environments
- Infrastructure-as-code pipelines with Terraform or similar tools
- Continuous deployment workflows
- DevOps automation scenarios
The command initializes a fresh Infisical instance by creating an admin user, organization, and instance admin machine identity, enabling subsequent programmatic configuration without human intervention.
This command creates an instance admin machine identity with the highest level of privileges. The returned token should be treated with the utmost security, similar to a root credential. Unauthorized access to this token could compromise your entire Infisical instance.
Flags
--domain
--domain
The URL of your Infisical instance. This can be set using the INFISICAL_API_URL
environment variable.
This flag is required.
--email
Email address for the admin user account that will be created. This can be set using the INFISICAL_ADMIN_EMAIL
environment variable.
This flag is required.
--password
--password
Password for the admin user account. This can be set using the INFISICAL_ADMIN_PASSWORD
environment variable.
This flag is required.
--organization
--organization
Name of the organization that will be created within the instance. This can be set using the INFISICAL_ADMIN_ORGANIZATION
environment variable.
This flag is required.
--ignore-if-bootstrapped
--ignore-if-bootstrapped
Whether to continue without error if the instance has already been bootstrapped. Useful for idempotent automation scripts.
This flag is optional and defaults to false
.
--output
--output
The type of output format for the bootstrap command. Supports k8-secret
for Kubernetes secret integration. This flag is optional and defaults to "".
When using k8-secret
, the command will create or update a Kubernetes secret directly in your cluster. Note that this option requires the command to be executed from within a Kubernetes pod with appropriate service account permissions.
--k8-secret-template
--k8-secret-template
The template to use for rendering the Kubernetes secret data/stringData section. Required when using --output=k8-secret
. The template uses Go template syntax and has access to the bootstrap response data.
Available template functions:
encodeBase64
: Base64 encode a string
Available data fields:
.Identity.Credentials.Token
: The machine identity token.Identity.ID
: The identity ID.Identity.Name
: The identity name.Organization.ID
: The organization ID.Organization.Name
: The organization name.Organization.Slug
: The organization slug.User.Email
: The admin user email.User.ID
: The admin user ID.User.FirstName
: The admin user first name.User.LastName
: The admin user last name
This flag is required when using k8-secret
output.
--k8-secret-name
--k8-secret-name
The name of the Kubernetes secret to create or update. Required when using --output=k8-secret
.
This flag is required when using k8-secret
output.
--k8-secret-namespace
--k8-secret-namespace
The namespace where the Kubernetes secret should be created or updated. Required when using --output=k8-secret
.
This flag is required when using k8-secret
output.
Response
JSON Output (Default)
The command returns a JSON response with details about the created user, organization, and machine identity:
Kubernetes Secret Output
When using --output=k8-secret
, the command creates or updates a Kubernetes secret in your cluster and logs the operation result. This is particularly useful for automated bootstrapping scenarios such as Kubernetes Jobs, GitOps workflows, or when you need to immediately store the admin credentials for use by other applications in your cluster.
Kubernetes Integration
Prerequisites for k8-secret Output
When running with --output=k8-secret
, the command must be executed from within a Kubernetes pod with proper service account permissions. The command automatically:
- Reads the service account token from
/var/run/secrets/kubernetes.io/serviceaccount/token
- Reads the CA certificate from
/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
- Gets the Kubernetes API server URL from environment variables (
KUBERNETES_SERVICE_HOST
andKUBERNETES_SERVICE_PORT_HTTPS
)
Required RBAC Permissions
Your service account needs the following permissions:
Usage with Automation
For automation purposes, you can extract just the machine identity token from the response:
This extracts only the token, which can be captured in a variable or piped to other commands.
Example: Capture Token in a Variable
Notes
- The bootstrap process can only be performed once on a fresh Infisical instance
- All core flags (domain, email, password, organization) are required for the bootstrap process to complete successfully
- Security controls prevent privilege escalation: instance admin identities cannot be managed by non-instance admin users and identities
- The generated admin user account can be used to log in via the UI if needed
- When using
k8-secret
output, the command must run within a Kubernetes pod with proper service account permissions - The
--ignore-if-bootstrapped
flag is useful for making bootstrap scripts idempotent