The OpenTofu shell plugin allows you to use 1Password to securely authenticate OpenTofu CLI with your fingerprint, Apple Watch, or system authentication, rather than storing your credentials in plaintext.
You can configure the OpenTofu plugin to provision credentials from the 1Password Shell Plugin ecosystem for use with providers such as AWS, MongoDB Atlas, or Databricks.
Requirements
- Sign up for 1Password.
- Install and sign in to 1Password for Mac or Linux.
- Install 1Password CLI 2.35.0 or later.
If you've already installed 1Password CLI, learn how to update your installation. - Connect 1Password CLI with the 1Password app.
- Install OpenTofu CLI.
The following shells are supported:
- Bash
- Zsh
- fish
Step 1: Configure your default credentials
Step 2: Source the plugins.sh file
To make the plugin available, source yourplugins.sh file. For example:
op folder may vary depending on your configuration directory. op plugin init will output a source command with the correct file path.
If this is your first time installing a shell plugin, you’ll also need to add the source command to your RC file or shell profile to persist the plugin beyond the current terminal session. For example:
Step 3: Use the CLI
Step 4: Remove imported credentials from disk
After saving your OpenTofu credentials in 1Password, you can remove all local copies you previously had stored on disk.
Next steps
1Password Shell Plugins support more than 60 third-party CLIs. To see a list of supported CLIs:Get help
Reference
Unlike most shell plugins, OpenTofu doesn't define its own set of credentials. Instead, it can provision any of the credentials you've already configured in 1Password for your other shell plugins, so you can use them within your OpenTofu project.
When you run op plugin init tofu, you choose which of your saved 1Password items to use, and 1Password provisions them automatically when you run OpenTofu commands that need them.
applydestroyimportinitplanrefreshstatetestworkspace
Thanks to @ianneub for contributing this plugin! Learn how to build your own shell plugins.