Skip to main content
With the 1Password Terraform provider , you can reference, create, or update items in your vaults using a 1Password Connect Server, a 1Password Service Account, or the 1Password desktop app.

Requirements

Get started

To use the 1Password Terraform provider with a Connect server:
  1. Specify the Connect server token. You can set this value with the OP_CONNECT_TOKEN environment variable or with the connect_token field in the provider configuration.
  2. Specify the Connect server hostname, URL, or IP address. You can set this value with the OP_CONNECT_HOST environment variable or with the connect_url field in the provider configuration.

Reference

The following sections contain reference information for the 1Password Terraform provider:

Configuration

The 1Password Terraform provider has fields you must set before you can use it with a 1Password Connect server, service account, or the 1Password desktop app. The following table describes each field. You can use the following environment variables to specify configuration values.

Configuration examples

The following code blocks show configuration examples.
The following examples use environment variables. Make sure to set the environment variables beforehand or use plain text.
The following example shows a provider configuration using a Connect server:
connect-example.tf

Resources

The 1Password Terraform provider has the following resources:

Item resource

The onepassword_item resource represents a 1Password item. You can import a onepassword_item with the following syntax:
Schema
The following tables describe the onepassword_item resource schema.

password_recipe

Password recipes can only be added to Login and Password items.
The nested schema for the password_recipe field:

section

The nested schema for the section field:

section_map

The nested schema for the section_map field:

section.field

The nested schema for the section.field field:

field_map

The nested schema for the field_map field:

section.field.password_recipe

Password recipes can only be added to Login and Password items.
The nested schema for the section.field.password_recipe field:
Example
The following code block shows an example usage of the onepassword_item resource.
resource.tf

Data sources

The 1Password Terraform provider has the following data sources:

Item data source

Use the onepassword_item data source to get details of a 1Password item. You can identify an item by its vault UUID and either the item’s title or UUID.
Schema
The following tables describe the onepassword_item resource schema.

section

The nested schema for the section field:

section.field

The nested schema for the section.field field:
Example
The following example shows how to use the onepassword_item data source.
data-source.tf

Vault data source

Use the onepassword_vault data source to get details of a vault. You can identify a vault with the vault name or UUID.
Schema
The following tables describe the onepassword_vault resource schema.

Environment data source

Use the onepassword_environment data source to read variables from a 1Password Environment. Identify an environment by its ID.
This data source is only supported with service account or desktop app authentication. It isn’t available with 1Password Connect.
Schema
The following tables describe the onepassword_environment resource schema.

metadata

The nested schema for the metadata field:
Example
The following example shows how to use the onepassword_environment data source.
data-source.tf

Ephemeral resources

The 1Password Terraform provider has the following ephemeral resources:

Item ephemeral resource

The onepassword_item ephemeral resource represents a 1Password item. Use it to retrieve item values without storing them in Terraform state. This is useful for providing sensitive values to write-only arguments or other ephemeral contexts.
Schema

Example

Learn more