How watonomous/terraform-provider-email works
Project Type and Purpose
• This is a Terraform “provider” plugin written in Go.
• Its sole purpose is to implement a Terraform resource that sends emails via SMTP when Terraform applies a configuration.
File Structure
• Top-level files:
• main.go – entry point registering the provider plugin
• go.mod / go.sum – Go module definitions
• Makefile / .goreleaser.yml – build, test, release automation
• terraform-registry-manifest.json – Terraform Registry metadata
• email/:
• provider.go – constructs the Provider schema, configuration (SMTP host, port, credentials)
• resource_email.go – implements the “email” resource’s Create/Read/Update/Delete logic via SMTP
• provider_test.go – unit tests for provider functions
• docs/, examples/ – user documentation and sample Terraform configs
• tools/ – helper utilities used in CI or code generation
README for Insights
• Uses HashiCorp Terraform Plugin SDK
• Tests with a local SMTP server (rnwood/smtp4dev) in acceptance tests
• Generates docs via go generate
Main Components & Interactions
a. Terraform Core
– CLI + engine that parses .tf files, initializes providers, and drives plan/apply.
b. Provider Plugin (this project’s binary)
– Exposes gRPC endpoints via HashiCorp go-plugin.
– Defines the Provider and the “email” resource.
– Uses Go’s net/smtp or a similar SMTP client to connect to an SMTP server.
c. External SMTP Server
– Real SMTP or test SMTP (smtp4dev) that accepts email messages.
d. User Terraform Configuration
– example/main.tf invoking the “email” resource with parameters (to, from, subject, body).
Architectural Patterns & Principles
• Plugin Architecture (hashicorp/go-plugin) – decouples Terraform Core from provider implementation.
• Resource CRUD model – each Terraform resource implements Create, Read, Update, Delete operations in code.
• Configuration-driven design – all SMTP settings are passed via Terraform resource or provider block.
• Separation of concerns:
• Provider schema & configuration (provider.go)
• Resource implementation (resource_email.go)
• Documentation & examples (docs/, examples/)
• Automation & CI (Makefile, .github/workflows, .goreleaser.yml)
Detailed Element Checklist
• Component labels: “Terraform CLI”, “Terraform Engine”, “Email Provider Plugin”
• Optional note on code-generation step (go generate ./... → docs)
• User’s Terraform files driving Terraform Core
• The provider plugin’s internal decomposition (schema, resource logic, SMTP client)
• External SMTP service interaction
• CI/CD automation surrounding build, test, and release