Skip to content

plain-insure/terraform-provider-printone

Repository files navigation

Terraform Provider for PrintOne

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.

Features

  • 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_KEY environment variable
  • Extensible Design: Easy to extend for additional PrintOne API resources

Requirements

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the Go install command:
go install

Using the Provider

Provider Configuration

terraform {
  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"
}

Environment Variable Configuration

You can set the API key using an environment variable:

export PRINTONE_API_KEY="your-api-key"

Webhook Resource

resource "printone_webhook" "example" {
  name   = "Order Status Updates"
  url    = "https://api.example.com/webhooks/orders"
  active = true
  events = [
    "order_status_update",
    "batch_status_update"
  ]
}

Webhook Data Source

data "printone_webhook" "existing" {
  id = "webhook-id-123"
}

output "webhook_url" {
  value = data.printone_webhook.existing.url
}

Complete Example

See examples/complete-example.tf for a comprehensive example showing multiple webhooks and data sources.

API Authentication

The provider uses the PrintOne API key for authentication via the x-api-key header. You can provide the API key in two ways:

  1. Provider Configuration (not recommended for production):

    provider "printone" {
      api_key = "your-api-key"
    }
  2. Environment Variable (recommended):

    export PRINTONE_API_KEY="your-api-key"

Resources and Data Sources

Resources

  • printone_webhook: Manage PrintOne webhooks

Data Sources

  • printone_webhook: Read existing PrintOne webhooks

Adding Dependencies

This provider uses Go modules.

To add a new dependency:

go get github.com/author/dependency
go mod tidy

Then commit the changes to go.mod and go.sum.

Developing the Provider

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.

Windows ARM64 Development

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 ./tools

Command Prompt:

set GOARCH=amd64
go generate ./tools

This 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

About

Terraform Provider for Print.One

Resources

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Contributors