OpenTofu

Integrate onsubmit.dev with your OpenTofu workflows for infrastructure-as-code form management.

Overview

Use onsubmit.dev's API with OpenTofu to manage form endpoints as part of your infrastructure. Pass form IDs to your deployed applications via environment variables or configuration.

Your form ID is available in the onsubmit.dev dashboard after creating a form.

API usage

Store your form ID as an OpenTofu variable and pass it to your application configuration:

hcl
variable "onsubmit_form_id" {
  description = "onsubmit.dev form ID for contact form"
  type        = string
  sensitive   = true
}

resource "aws_lambda_function" "app" {
  # ... other configuration

  environment {
    variables = {
      CONTACT_FORM_ID = var.onsubmit_form_id
    }
  }
}

HTTP provider

You can test form submission with the http provider:

hcl
data "http" "test_submission" {
  url    = "https://onsubmit.dev/f/${var.onsubmit_form_id}"
  method = "POST"

  request_headers = {
    Content-Type = "application/json"
  }

  request_body = jsonencode({
    email   = "test@example.com"
    message = "Test submission from OpenTofu"
  })
}