Terraform Provider for KSM
Keeper Secrets Manager Terraform provider for interacting with vault secrets in Terraform builds

Features
The Keeper Terraform Plugin utilizes Keeper Secrets Manager to provide access to secret credentials saved in the Keeper Vault. The Keeper Terraform plugin allows for injecting secrets directly into Terraform builds securely using Keeper's zero-knowledge infrastructure.
Retrieve secrets from the Keeper Vault to use in Terraform builds
Inject credentials directly into Terraform build scripts
Create new secrets and store them in the vault
Get Files from the Keeper Vault
Prerequisites
This page documents the Secrets Manager Terraform integration. In order to utilize this integration, you will need:
Keeper Secrets Manager access (See the Quick Start Guide for more details)
Secrets Manager add-on enabled for your Keeper account
Membership in a Role with the Secrets Manager enforcement policy enabled
A Keeper Secrets Manager Application with secrets shared to it
See the Quick Start Guide for instructions on creating an Application
An initialized Keeper Secrets Manager Configuration
The Terraform integration accepts JSON and Base 64 format configurations
Terraform 1.0.0+ (1.10.0+ required for
ephemeralresources)
Installation
Registry install
To install this provider, add the following code to your Terraform configuration and run terraform init:
Find the source code in the GitHub repository
Manual Installation
Download the latest version of the Terraform Provider for your platform from our GitHub release page and copy the archive to the corresponding Terraform plugin folder (creating any missing folders in the path). Initialize source with full provider URL: source = "github.com/keeper-security/secretsmanager"
For help on manually installing Terraform Providers, please refer to the official Terraform documentation.
Usage
Configure the Provider
The Keeper Secrets Manager provider is used to interact with the resources supported by Keeper Secrets Manager. The provider needs to be configured with Keeper credentials before it can be used.
Configuration File Contents
appKey- (Required) Application key.clientId- (Required) Client ID.privateKey- (Required) Private key.hostname- (Optional) By default the plugin connects tokeepersecurity.com
Get Secrets Using Data Sources
A data source is provided for each standard Keeper record type, which facilitates easy fetching of secret credentials.
Data sources are accessed using the following format:
For example, using a Login type record:
To access any additional custom fields or standard fields for user defined record types use secretsmanager_field data source
List of supported record types
"secretsmanager_address"
"secretsmanager_bank_account"
"secretsmanager_bank_card"
"secretsmanager_birth_certificate"
"secretsmanager_contact"
"secretsmanager_database_credentials"
"secretsmanager_driver_license"
"secretsmanager_encrypted_notes"
"secretsmanager_field"
"secretsmanager_file"
"secretsmanager_folder"
"secretsmanager_folders"
"secretsmanager_health_insurance"
"secretsmanager_login"
"secretsmanager_membership"
"secretsmanager_passport"
"secretsmanager_pam_database"
"secretsmanager_pam_directory"
"secretsmanager_pam_machine"
"secretsmanager_pam_user"
"secretsmanager_pam_remote_browser"
"secretsmanager_photo"
"secretsmanager_record"
Records (for large volume requests)
"secretsmanager_records"
"secretsmanager_server_credentials"
"secretsmanager_software_license"
"secretsmanager_ssh_keys"
"secretsmanager_ssn_card"
To see the fields available to each data source see Record Types Data Source Reference
For more information on record types see Record Types documentation and Commander usage.
Metadata Data Source
Use secretsmanager_metadata to read non-sensitive metadata about a record — uid, type, title, notes, revision, folder_uid, and is_editable — without exposing its field values.
Accessing Record Fields
To access a secret credential saved to a field in a record, access the field as part of the data source.
Access the field of a typed record data source
Use this format to access fields of a typed data resource
Example: access the password of a login type data source
Use the field data source to query any field in a record with Keeper Notation
Create a data source using the "secretsmanager_field" data source type, and specify a field query in the path property.
The field query uses the format: "<UID>/field/<field type>"
Custom Fields
Custom fields are available on standard and PAM resource types and support 27 field types with dedicated value encoding (simple strings, dates, checkboxes, and JSON-encoded objects for complex types like name or address). A type string outside this list is still accepted, but stored as plain text with no type-specific validation. For a complete list of supported record types, see the Custom Fields Reference.
Simple Types (String Value)
For simple types like text, email, URL, use a plain string value:
Complex Types (JSON Value)
For complex types like name, address, paymentCard, use jsonencode():
Field Configuration
Each custom field supports required and privacy_screen attributes:
Reading Custom Fields
Custom fields are also available as read-only attributes on all data sources and ephemeral resources. The custom block is a list. Index into it by position or iterate with for:
Each element exposes type, label, and value (a string). For complex types (name, address, paymentCard), value is a JSON-encoded object. Use jsondecode() to work with individual sub-fields.
Creating Records With Resources
Keeper provides Terraform resources for the major Keeper record types shown above. Using these resources, Keeper records can be created using the Keeper Secrets Manager Terraform plugin.
To create a record, use the resource corresponding to the record type that you would like to use.
Each record resource requires at least a folder_uid and title as well as values for each record field.
Example login resource
Using Ephemeral Resources (Terraform 1.10+)
Ephemeral resources are available for all 25 record types in Terraform 1.10 and later. Unlike data sources and resources, ephemeral data is never written to terraform.tfstate, ensuring sensitive credentials don't persist on disk.
Key Benefits:
Secrets never stored in local or remote state files
Temporary access only for the duration of your Terraform run
Full support for all record types (login, bank_account, ssh_keys, pam_machine, etc.)
Fully compatible with existing data sources and resources
Syntax: Use ephemeral instead of data:
Example: Ephemeral SSH Key Access
Custom Fields on Ephemeral Resources
All record-type ephemeral resources expose a read-only custom block, identical to data sources. Custom field values are never stored in state:
Folder UID
To create records, Keeper Secrets Manager requires a folder UID so it knows where to create new records.
A folder UID can be found in the Keeper Vault or by using Keeper Commander.
The target folder (or its parent shared folder) must be accessible by the Keeper Secrets Manager Application with Can Edit permissions.
Title
The record title.
Record Fields
The value and settings for each record field can be set in the resource. For information on the available fields per record type, see the resource definitions.
Each field is represented as an object in the resource.
Example login field
Setting Field Values
Use the value field to set the intended value for each field. The format of fields can differ, for example the login field type takes a string, while the name field takes an object with "first", "middle" and "last" fields.
For reference of each field's value format see the resource documentation.
Setting Field Settings
Each field can be configured with various settings:
label
string
The field label
required
boolean
if True, the field will be considered required by the Keeper Vault
privacy_screen
boolean
if True, the field will be hidden in the Keeper Vault
Password Field
The password field has some special features.
Password Generation
Records created using the Terraform plugin can have a password generated automatically. To have the plugin generate a password, do not provide a value field to the password, and instead use generate = "true"
The password generation can be configured to generate a password of a specified length using the complexity field
The complexity block also accepts caps, lowercase, digits, and special (minimum counts per character class), and special_set, which constrains which special characters the generator draws from:
Additionally, password fields have an extra configuration setting: enforce_generation which when true will make the Keeper Vault enforce that the password can only be generated and not set by a user.
SSH Key Generation
The secretsmanager_ssh_keys resource can automatically generate an SSH key pair. To trigger generation, omit the key pair value and set generate = "true" on the key_pair field:
PAM Machine and PAM User resources also support generating a private PEM key via the private_pem_key field using the same generate / key_type / key_bits pattern.
Examples
Read Credentials
This example provisions Keeper Secrets Manager, reads a login type data source, and accesses each field of the data source.
Create a Keeper Record
Create PAM Records
Read PAM Data Source Outputs
For more examples, check out the examples folder in the source code.
Optimization
The secretsmanager_records data source allows you to fetch multiple Keeper Secrets Manager records in a single API call, significantly reducing API requests and improving performance when dealing with many secrets.
Fetch by UIDs (most efficient):
Fetch by exact titles:
Fetch by regex pattern:
Accessing results by UID:
Records are available as a list via records, or as a UID-indexed map via records_by_uid. Each records_by_uid value is a JSON-encoded string. Use jsondecode() to access individual fields:
Last updated

