Keeper Secrets Manager Terraform plugin for accessing secrets in Terraform builds
Features
Retrieve secrets from the Keeper Vault to use in Terraform builds
Inject credentials directly into Terraform build scripts
Get Files from the Keeper Vault
Prerequisites
This page documents the Secrets Manager Terraform integration. In order to utilize this integration, you will need:
Secrets Manager addon enabled for your Keeper account
Membership in a Role with the Secrets Manager enforcement policy enabled
The Terraform integration accepts JSON and Base 64 format configurations
About
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.
Installation
Registry install
To install this provider, add the following code to your Terraform configuration and run terraform init:
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.
terraform {
required_providers {
secretsmanager = {
source = "keeper-security/secretsmanager"
version = ">= 1.0.0"
}
}
}
provider "secretsmanager" {
# Specify config contents as a string or load from file
# credential = "<CONFIG FILE CONTENTS BASE64>"
credential = file("/path/to/config.json")
}
Configuration File Contents
app_key - (Required) Application key.
client_id - (Required) Client ID.
private_key - (Required) Private key.
hostname - (Optional) By default plugin will connect to keepersecurity.com
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.
data "secretsmanager_field" "my_field" {
path = "<record UID>/field/login"
}
The field query uses the format: "<UID>/field/<field type>"
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.
To create records, Keeper Secrets Manager requires a folder UID so that it knows where to create the new records.
A folder UID can be found in the Keeper Vault or by using Keeper Commander.
The given folder must by accessible by the Keeper Secrets Manager Application being used by your Terraform plugin. The folder must also have at least one record in it before being used by Keeper Secrets Manager.
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.
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.
Each field can be configured with various settings:
Field
Accepted Value
Description
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
complexity {
length: 16
}
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.
To have Terraform regenerate a password, it needs to notice a difference in the generate field. To allow for triggering a difference, the generate field accepts both "true" and "yes" values. Change from one to the other to trigger a regeneration.
Examples
Read Credentials
This example provisions Keeper Secrets Manager, reads a login type data source, and accesses each field of the data source.