How n3integration/terraform-provider-godaddy works
Project Type and Purpose
• This is a Terraform provider plugin written in Go.
• It implements the Terraform Plugin Protocol, exposing a godaddy_domain_record resource to manage GoDaddy DNS records via their REST API.
File Structure
• Top-level:
• main.go – entrypoint registering the plugin with Terraform.
• plugin/godaddy/ – provider implementation (config, schema, resource logic).
• api/ – standalone GoDaddy API client and domain-record types.
• docker/ – Dockerfile and compose for local testing/integration.
• docs/ – user-facing documentation and examples.
• Tests: integration and unit tests live alongside code (*_test.go).
• CI/CD: GitHub Actions (.github/workflows/release.yml), GoReleaser config.
Extract Key Architecture Insights from the README
• Uses environment variables or in-Terraform credentials for GoDaddy API key/secret.
• Exposes provider block and a single resource: godaddy_domain_record.
• Talks to external GoDaddy REST endpoints over HTTPS.
Main Components
a. Terraform CLI / Core
b. Terraform Plugin (the compiled terraform-provider-godaddy binary)
– gRPC interface per Terraform Plugin Protocol
– Provider initialization & schema registration
– Resource implementations (CRUD for domain records)
c. Internal GoDaddy API Client (api package)
– HTTP-based client wrapping GoDaddy REST calls
d. External GoDaddy DNS REST API
e. User’s HCL configurations & environment variables
Relationships & Interactions
1. User writes Terraform HCL → runs terraform apply.
2. Terraform Core loads the godaddy plugin binary via plugin protocol.
3. Plugin’s main.go spins up gRPC server, initializes provider (reads key/secret).
4. When Terraform needs to Create/Read/Update/Delete a godaddy_domain_record,
the plugin invokes resource handlers in plugin/godaddy/resource_dns_record.go.
5. Resource handlers call into the api/client.go, forming HTTP requests to GoDaddy’s API.
6. GoDaddy returns JSON HTTP responses → client maps to Go structs → plugin returns state to Terraform.
7. Terraform Core updates state and presents results to the user.
Architectural Patterns & Design Principles
• Separation of concerns:
• plugin/ layer: Terraform SDK glue and resource logic.
• api/ layer: pure client-SDK for GoDaddy REST API.
• Plugin Protocol Pattern: uses gRPC for IPC between Terraform Core and provider.
• Dependency injection: configuration (key, secret, optional customer) flows into client.
• Testability: local Docker Compose for integration tests, unit tests in each package.
Technologies & Frameworks to Call Out
• Go language
• Terraform Plugin SDK (gRPC-based)
• GoDaddy REST API over HTTPS
• Docker & Docker Compose (for local integration)
• GitHub Actions and GoReleaser (CI/CD)