Terraform Twilio provider
Перейти к файлу
childish-sambino 4cb1124dcd
docs: add details on how to use a locally-built provider (#61)
2021-07-08 15:04:16 -05:00
.github chore: update readme and issue template (#57) 2021-07-01 15:35:21 -06:00
client feat: add subaccount support for v2010 apis (#23) 2021-05-19 15:16:58 -07:00
core fix: convert ints in path params to properly be imported (#59) 2021-07-06 09:41:29 -05:00
examples docs: update examples to pull from the terraform registry (#58) 2021-07-02 07:23:27 -07:00
githooks docs: add proxy example 2021-06-24 11:29:03 -05:00
twilio fix: convert ints in path params to properly be imported (#59) 2021-07-06 09:41:29 -05:00
.gitignore fix: handle nested nil values during marshaling (#45) 2021-06-24 12:43:39 -05:00
.goreleaser.yaml Chore: remove example before hook 2021-06-30 20:49:14 -06:00
.travis.yml update slack token 2021-06-22 13:21:24 -07:00
CHANGES.md [Librarian] Regenerated @ 4e75c7be2507558854a659be2e05b171bcf7512b 2021-07-01 02:07:48 +00:00
CODE_OF_CONDUCT.md chore: update template files 2021-06-07 23:30:43 +00:00
ISSUE_TEMPLATE.md chore: update template files 2021-06-07 23:30:43 +00:00
LICENSE chore: update template files 2021-06-07 23:30:43 +00:00
Makefile docs: add details on how to use a locally-built provider (#61) 2021-07-08 15:04:16 -05:00
PULL_REQUEST_TEMPLATE.md chore: update template files 2021-06-07 23:30:43 +00:00
README.md docs: add details on how to use a locally-built provider (#61) 2021-07-08 15:04:16 -05:00
go.mod fix: convert ints in path params to properly be imported (#59) 2021-07-06 09:41:29 -05:00
go.sum Release v0.3.0 2021-06-30 20:29:03 +00:00
main.go feat: add subaccount support for v2010 apis (#23) 2021-05-19 15:16:58 -07:00
usage.md docs: Fix usage registry (#60) 2021-07-08 13:24:01 -05:00

README.md

Twilio Terraform Provider

GitHub release (latest by date including pre-releases) Terraform Registry

Project Status

⚠️ This project is currently in PILOT and under active development. If you would like to participate in the pilot, please sign up for Twilio Insiders.

Requirements

  • Terraform v0.15.x
  • Go 1.15+ (to build the provider plugin)

Resource Documentation

Documentation on the available resources that can be managed by this provider and their parameters can be found here.

Note that file upload resources are currently not available.

Building The Provider

Clone repository:

git clone git@github.com:twilio/terraform-provider-twilio

Enter the provider directory and build the provider:

make build

Installing and Using the Provider

  1. Run make install to install and build the twilio-terraform-provider.
  2. Configure the Twilio provider with your twilio credentials in your Terraform configuration file (e.g. main.tf). These can also be set via TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN environment variables.
  3. Add your resource configurations to your Terraform configuration file (e.g. main.tf).
terraform {
  required_providers {
    twilio = {
      source  = "twilio/twilio"
      version = ">=0.4.0"
    }
  }
}

# Credentials can be found at www.twilio.com/console.
provider "twilio" {
  //  account_sid defaults to TWILIO_ACCOUNT_SID env var
  //  auth_token  defaults to TWILIO_AUTH_TOKEN env var
}

resource "twilio_api_accounts_keys_v2010" "key_name" {
  friendly_name = "terraform key"
}

output "messages" {
  value = twilio_api_accounts_keys_v2010.key_name
}
  1. Run terraform init and terraform apply to initialize and apply changes to your Twilio infrastructure.

Examples

For usage examples, checkout the documentation in usage.md and the examples folder.

Developing the Provider

The boilerplate includes the following:

  • Makefile contains helper functions used to build, package and install the Twilio Terraform Provider. It's currently written for MacOS Terraform provider development, but you can change the variables at the top of the file to match your OS_ARCH.

    The install function is configured to install the provider into the ~/.terraform.d/plugins/ folder. To use the locally installed provider, prefix the source path with local in your Terraform configuration file (i.e., source = "local/twilio/twilio"). Then run terraform init to use the locally built provider.

  • examples contains sample Terraform configuration that can be used to test the Twilio provider

  • twilio contains the main provider code. This will be where the provider's resources and data source implementations will be defined.

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.15+ is required).

To compile the provider, run make build. This will build the provider and put the provider binary in the $GOPATH/bin directory.

make build
...
$GOPATH/bin/terraform-provider-twilio
...

In order to run the full suite of Acceptance tests, run make testacc. Provide your Account SID and Auth Token as environment variables to properly configure the test suite.

Note: Acceptance tests create real resources, and often cost money to run.

 make testacc ACCOUNT_SID=YOUR_ACCOUNT_SID AUTH_TOKEN=YOUR_AUTH_TOKEN

You can also specify a particular suite to run like so:

 make testacc TEST=./twilio/ ACCOUNT_SID=YOUR_ACCOUNT_SID AUTH_TOKEN=YOUR_AUTH_TOKEN

An example test file can be found here.

Debugging

First:

export TF_LOG=TRACE

then refer to the Terraform Debugging Documentation.