Thanks for your interest in contributing to the 1Password Terraform provider project! 🙌 We appreciate your time and effort. Here are some guidelines to help you get started.
Run the following command to build the 1Password Terraform provider:
go build .
This will create the terraform-provider-onepassword
binary.
To run the Go tests and check test coverage run the following command:
go test -v ./... -cover
Refer to the following sections of the Terraform's "Custom Framework Providers" tutorial to install this provider locally:
You must specify the onepassword
provider in your Terraform configuration:
terraform {
required_providers {
onepassword = {
source = "1Password/onepassword"
version = "~> 2.0.0"
}
}
}
provider "onepassword" {
service_account_token = "<1Password service account token>"
}
After copying a newly built version of the provider to the plugins directory, you need to run terraform init
again. Otherwise, Terraform returns an error.
To start debugging:
- Start a debugging session.
- Export
TF_REATTACH_PROVIDERS
. - Run Terraform normally.
You can start a debugging session in several ways:
Note: Before continuing, make sure you add the dev_overrides
block to your ~/.terraformrc
file (using "1Password/onepassword"
as the source). For instructions, refer to the Installing the provider locally.
Run the following command to build the provider without enabling optimizations:
go build -gcflags="all=-N -l" .
Run the following command to start a Delve debugging session:
dlv debug . -- --debug
Or use your IDE debugger. You can configure editors like GoLand to start a debugging session by passing the --debug
flag as a program argument.
If a debugging session was starts correctly, the provider prints the following output to stdout
:
Provider started, to attach Terraform set the TF_REATTACH_PROVIDERS env var:
TF_REATTACH_PROVIDERS='{"1Password/onepassword":{"Protocol":"grpc","Pid":3382870,"Test":true,"Addr":{"Network":"unix","String":"/tmp/plugin713096927"}}}'
Copy the line starting with TF_REATTACH_PROVIDERS
from your provider's output. You can either export this variable or prefix every Terraform command with it.
After starting a debugging session and exporting the TF_REATTACH_PROVIDERS
variable, run Terraform as usual. Any breakpoints you have set will halt execution and show you the current variable values.
Documentation is generated for the provider using terraform-plugin-docs. This plugin uses the schema Description
field in conjunction with the contents of the /templates
and /examples
folders to generate the /docs
content.
To regenerate the /docs
Markdown run:
go generate
To get your PR merged, we require you to sign your commits.
You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.
Learn how to use 1Password to sign your commits.
Follow the steps below to set up commit signing with ssh-agent
:
- Generate an SSH key and add it to ssh-agent
- Add the SSH key to your GitHub account
- Configure git to use your SSH key for commit signing
Follow the steps below to set up commit signing with gpg
:
- Generate a GPG key
- Add the GPG key to your GitHub account
- Configure git to use your GPG key for commit signing