Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Latest commit

 

History

History
99 lines (71 loc) · 2.77 KB

index.md

File metadata and controls

99 lines (71 loc) · 2.77 KB

Terraform Sendgrid provider

The Terraform Sendgrid provider is used to interact with many resources supported by Sendgrid. The provider needs to be configured with the proper credentials before it can be used.

Example Usage

# Configure the provider
provider "sendgrid" {
    api_key = "SG.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

# Create a template
resource "sendgrid_template" "template"{
    name       = "my-template"
    generation = "dynamic"
}

# Create a template version
resource "sendgrid_template_version" "template_version" {
    name                   = "my-template-version"
    template_id            = sendgrid_template.template.id
    active                 = 1
    html_content           = "<%body%>"
    generate_plain_content = true
    subject                = "subject"
}

Authentication

The Sendgrid provider offers a flexible means of providing credentials for authentication. The following methods are supported, and explained below in this order:

  • Static credentials
  • Environment variables

Static credentials

Static credentials can be provided by adding api_key to the Sendgrid provider block, you can configure host and subuser too.

Usage:

provider "sendgrid" {
    api_key = "SG.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    host    = "https://api.sendgrid.com/v3"
    subuser = "username"
}

Environment variables

You can provide your credentials via SENDGRID_API_KEY. You also can set SENDGRID_HOST and SENDGRID_SUBUSER environment variables.

provider "sendgrid" {}

Usage:

$ export SENDGRID_API_KEY="SG.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
$ terraform plan

Testing

Credentials must be provided via the SENDGRID_API_KEY environment variable in order to run acceptance tests.

Datasources/Resources reference

API key Resource

Domain authentication Resource

Link branding Resource

SSO Resources

Subuser Resource

Template Resources

Unsubscribe Group Resource

WebHook Resources