This Terraform provider allows you to manage PrintOne API resources using Infrastructure as Code. Currently supports webhook management with an extensible design for additional resources.
- Webhook Management: Create, read, update, and delete webhooks
- API Key Authentication: Secure authentication using PrintOne API keys
- Environment Variable Support: Configure API key via
PRINTONE_API_KEYenvironment variable - Extensible Design: Easy to extend for additional PrintOne API resources
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
installcommand:
go installterraform {
required_providers {
printone = {
source = "plain-insure/printone"
}
}
}
provider "printone" {
# API key for authentication (can also use PRINTONE_API_KEY env var)
api_key = var.printone_api_key
# Optional: Custom API endpoint (defaults to https://api.print.one)
# endpoint = "https://api.print.one"
}You can set the API key using an environment variable:
export PRINTONE_API_KEY="your-api-key"resource "printone_webhook" "example" {
name = "Order Status Updates"
url = "https://api.example.com/webhooks/orders"
active = true
events = [
"order_status_update",
"batch_status_update"
]
}data "printone_webhook" "existing" {
id = "webhook-id-123"
}
output "webhook_url" {
value = data.printone_webhook.existing.url
}See examples/complete-example.tf for a comprehensive example showing multiple webhooks and data sources.
The provider uses the PrintOne API key for authentication via the x-api-key header. You can provide the API key in two ways:
-
Provider Configuration (not recommended for production):
provider "printone" { api_key = "your-api-key" }
-
Environment Variable (recommended):
export PRINTONE_API_KEY="your-api-key"
printone_webhook: Manage PrintOne webhooks
printone_webhook: Read existing PrintOne webhooks
This provider uses Go modules.
To add a new dependency:
go get github.com/author/dependency
go mod tidyThen commit the changes to go.mod and go.sum.
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.
If you're developing on Windows ARM64, you need to set the GOARCH environment variable to amd64 when running code generation commands. This is required because Terraform does not support ARM64 architecture, even though Go does. Without this setting, the compiled provider will be a different architecture than what Terraform can find.
PowerShell:
$env:GOARCH="amd64"
go generate ./toolsCommand Prompt:
set GOARCH=amd64
go generate ./toolsThis ensures the generated provider binary is compatible with Terraform's architecture requirements.
To generate or update documentation, run make generate.
In order to run the full suite of Acceptance tests, run make testacc.
Note: Acceptance tests create real resources, and often cost money to run.
make testacc