A Terraform provider for managing SendGrid (Twilio) resources, built on the Terraform Plugin Framework.
The provider is published on the Terraform Registry
as twilio-labs/sendgrid:
terraform {
required_providers {
sendgrid = {
source = "twilio-labs/sendgrid"
}
}
}
provider "sendgrid" {
# Or set the SENDGRID_API_KEY environment variable.
api_key = var.sendgrid_api_key
}See docs/guides/authentication.md for all provider configuration options (including EU data residency and On-Behalf-Of subuser access), and docs/guides/migrating-from-other-providers.md if you're coming from another SendGrid provider.
Access & Security
Account Management
Sender Authentication
Templates
Webhooks
Marketing Campaigns
Tracking & Mail Settings
sendgrid_click_tracking_settingssendgrid_open_tracking_settingssendgrid_subscription_tracking_settingssendgrid_google_analytics_settingssendgrid_address_whitelist_mail_settingssendgrid_bounce_purge_mail_settingssendgrid_footer_mail_settingssendgrid_forward_bounce_mail_settingssendgrid_forward_spam_mail_settingssendgrid_template_mail_settings
IP Management
Partner Accounts
Most resources have a matching data source of the same name. The exceptions are sendgrid_template_version,
sendgrid_ip_warmup, sendgrid_partner_account, and the account-wide Tracking & Mail Settings resources
(there's nothing to look up by ID for a singleton setting). There is also a standalone
sendgrid_partner_offerings data source. See docs/ for
full reference documentation.
Requirements:
go installOr run everything CI runs in one shot (build, vet, lint, unit tests, docs generation):
make checkSee CONTRIBUTING.md for the full workflow
Point Terraform at a locally-built copy of the provider using a
dev override
in ~/.terraformrc:
provider_installation {
dev_overrides {
"twilio-labs/sendgrid" = "/path/to/your/GOBIN"
}
direct {}
}Then set credentials via environment variables (or the equivalent provider block attributes — see docs/guides/authentication.md):
| Environment variable | Purpose |
|---|---|
SENDGRID_API_KEY |
Required. The SendGrid API key used to authenticate all requests. |
SENDGRID_API_HOST |
Optional. Defaults to https://api.sendgrid.com; set for EU regional accounts. |
SENDGRID_ON_BEHALF_OF |
Optional. Acts on behalf of a subuser or parent account on every request. |
Unit tests (no credentials required):
go test ./...Acceptance tests make real API calls against a live SendGrid account and will create/destroy real resources.
They're gated behind TF_ACC and require a real API key:
TF_ACC=1 SENDGRID_API_KEY=SG.xxxx go test ./internal/provider/... -vDocs under docs/ are generated from resource/data-source schema descriptions, examples/, and
templates/ via tfplugindocs. After changing a
schema description or adding an example, regenerate with:
go generate ./...