Skip to content

circa10a/terraform-provider-mailform

Repository files navigation

terraform-provider-mailform

This provider enables you to send physical mail, driven by terraform, via https://mailform.io

Standing on the shoulders of giants enables us to yeet mail further.

Build Status Go Report Card GitHub release (latest by date) Buy Me A Coffee

⚠️ Orders cannot be updated/deleted (cancelled). Once created,no more modifications can be made due to API limitations. Deleted resources are simply removed from state.

Usage

The provider with use the environment variable MAILFORM_API_TOKEN by default unless specified in the provider configuration.

terraform {
  required_providers {
    mailform = {
      source = "circa10a/mailform"
    }
  }
}

provider "mailform" {
  api_token = "XXX" // If not specified, will read MAILFORM_API_TOKEN environment variable
}

// Create PDF
resource "mailform_pdf" "example" {
  header   = "My Resumes"
  content  = "Some resume contents"
  filename = "./test.pdf"
}

// Convert image to pdf for postcards
resource "mailform_pdf" "example" {
  image_filename = "./test_image.jpg"
  filename       = "./test_image.pdf"
}

// Create mail order
resource "mailform_order" "example" {
  pdf_file       = mailform_pdf.example.filename
  service        = "USPS_PRIORITY"
  to_name        = "A name"
  to_address_1   = "Address 1"
  to_city        = "Seattle"
  to_state       = "WA"
  to_postcode    = "00000"
  to_country     = "US"
  from_name      = "My name"
  from_address_1 = "My Address 1"
  from_city      = "Dallas"
  from_state     = "TX"
  from_postcode  = "00000"
  from_country   = "US"
}

// Fetch order data
data "mailform_order" "example" {
  id = mailform_order.example.id
}

output "order_info" {
  value = data.mailform_order.example
}

Requirements

Building The Provider

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

Adding Dependencies

This provider uses Go modules. Please see the Go documentation for the most up to date information about using Go modules.

To add a new dependency github.com/author/dependency to your Terraform provider:

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

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

Using the provider

Fill this in for each provider

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.

To generate or update documentation, run go generate.