Sendgrid provider plugin for Terraform.
- Terraform. Make sure you have it installed and it's accessible from your
$PATH
. - Sendgrid
-
Install Go and configure your workspace.
-
Download this repo:
$ go get github.com/opteemister/terraform-provider-sendgrid
- Install the dependencies:
$ cd $GOPATH/src/github.com/opteemister/terraform-provider-sendgrid
$ go get
- Compile it:
$ go build -o terraform-provider-sendgrid
- Copy it to a directory:
$ sudo cp terraform-provider-sendgrid ~/.terraform/providers/
- Define new provider in terraform configuration:
~/.terraform/terraformrc
providers {
sendgrid = "~/.terraform/providers/terraform-provider-sendgrid"
}
Here's a simple Terraform file to get you started:
provider "sendgrid" {
}
resource "sendgrid_template" "first_template" {
name = "name"
}
resource "sendgrid_template_version" "first_template_version" {
name = "version name"
template_id = "${sendgrid_template.first_template.id}"
subject = "email subject"
html_content_file = "./resources/test_template.html"
plain_content_file = "./resources/test_template_plain.html"
active = true
}
For either example, save it to a .tf
file and run:
$ terraform plan
$ terraform apply
$ terraform show
provider "sendgrid" {
apiKey = "sendgrid_key"
}
apiKey
: Optional. Set the key for sendgrid account. You can set it through the ENV_VARS
resource "sendgrid_template" "my_template" {
name = "my_template"
}
name
: Required. The name of the template.
id
: The Id of the new template.
resource "sendgrid_template_version" "my_template_version" {
name = "version name"
template_id = "${sendgrid_template.first_template.id}"
subject = "email subject"
html_content_file = "./resources/test_template.html"
plain_content_file = "./resources/test_template_plain.html"
active = true
}
name
: Required. The name of the template_version.template_id
: Required. The id of the template.subject
: Required. The subject for the email template.html_content_file
: Required. Html content file path.plain_content_file
: Required. Plain text file path.active
: Optional. Boolean option if template version is active. Default true.