This Terraform provider allows you to manage secrets in Phase from your Terraform configurations.
To use the latest version of the provider in your Terraform configuration, add the following terraform block:
terraform {
required_providers {
phase = {
source = "phasehq/phase"
version = "0.1.1" // replace with latest version
}
}
}
# Configure the Phase Provider
provider "phase" {
phase_token = "pss_service:v1:..." # or "pss_user:v1:..." // A Phase Service Token or a Phase User Token (PAT)
}
# Retrieve all secrets under a specific path
data "phase_secrets" "all" {
env = "development"
app_id = "your-app-id"
path = "/"
}
# Retrieve a specific secret
output "secret_keys" {
value = data.phase_secrets.all.secrets["STRIPE_KEY"]
sensitive = true
}
// Fetch all secrets
# Use secrets
output "all_secret_keys" {
value = data.phase_secrets.all.secrets
}
See the Phase Provider documentation for all the available options and data sources.
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
build
command:go build -o terraform-provider-phase
If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).
To compile the provider, run go install
. This will build the provider and put the provider binary in the $GOPATH/bin
directory.
To generate or update documentation, run go generate
.
-
Create a local plugin directory for Terraform:
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/phasehq/phase/0.1.0/$(go env GOOS)_$(go env GOARCH)
-
Move the compiled binary to the plugin directory:
mv terraform-provider-phase ~/.terraform.d/plugins/registry.terraform.io/phasehq/phase/0.1.0/$(go env GOOS)_$(go env GOARCH)
-
In your Terraform configuration, specify the local version:
terraform { required_providers { phase = { source = "registry.terraform.io/phasehq/phase" version = "0.1.0" } } }
-
Initialize terraform
terraform init
-
Run terraform plan
terraform plan
-
Initialize terraform
terraform apply
This provider is distributed under the MIT License.