Slide 1

Slide 1 text

Terraform Provider Development Ringo De Smet Maintainer of terraform-provider-xenserver

Slide 2

Slide 2 text

Agenda • Runtime Model • Bootstrapping a plugin • Datasources & Resources • Code structuring • Testing • Distribution • Some pointers … and one more thing!

Slide 3

Slide 3 text

Runtime Model All v0.10 and up!

Slide 4

Slide 4 text

Runtime Model: tf init terraform terraform-provider-xenserver terraform-provider-mysql Download Download

Slide 5

Slide 5 text

Runtime Model: tf plan terraform terraform-provider-xenserver terraform-provider-mysql RPC RPC

Slide 6

Slide 6 text

Bootstrapping a plugin

Slide 7

Slide 7 text

Exposing all config options for the provider block supported datasources supported resources callback function to configure the provider, e.g. connection

Slide 8

Slide 8 text

Provider Initialisation

Slide 9

Slide 9 text

Provider Initialisation

Slide 10

Slide 10 text

Provider Initialisation

Slide 11

Slide 11 text

Datasources & Resources

Slide 12

Slide 12 text

Datasources

Slide 13

Slide 13 text

Datasources

Slide 14

Slide 14 text

Resources

Slide 15

Slide 15 text

Resources

Slide 16

Slide 16 text

Code structuring Split client SDK from Terraform provider sources, e.g. AWS https://github.com/aws/aws-sdk-go https://github.com/terraform-providers/terraform-provider-aws XenServer https://github.com/ringods/go-xen-api-client https://github.com/ringods/terraform-provider-xenserver

Slide 17

Slide 17 text

Testing • No unit testing • Terraform core is unit tested • Your client SDK is (or should be) tested • Acceptance Testing • Starts the provider under test • Real resources in use, possibly cost involved (AWS, …) • System Testing • kitchen-terraform • test full Terraform setups with tools like serverspec

Slide 18

Slide 18 text

Acceptance Testing

Slide 19

Slide 19 text

Acceptance Testing

Slide 20

Slide 20 text

Acceptance Testing

Slide 21

Slide 21 text

Distribution • Supported providers are automatically downloaded • Not yet so for third-party providers • Download manually • Put in ~/.terraform.d/plugins • Versioning: terraform-provider-vX.Y.Z • Support discussed in hashicorp/terraform#15252

Slide 22

Slide 22 text

Information Pointers • Terraform Internals • Terraform Providers • Terraform Provider Versioning • Chat: https://gitter.im/hashicorp-terraform/Lobby

Slide 23

Slide 23 text

How to keep 3rd party providers well maintained?

Slide 24

Slide 24 text

https://github.com/voxpupuli Community to maintain Puppet modules

Slide 25

Slide 25 text

https://github.com/chef-cookbooks Community to maintain Chef cookbooks

Slide 26

Slide 26 text

Where is the Terraform community?

Slide 27

Slide 27 text

https://github.com/terra-farm New community to maintain
 Terraform providers & modules

Slide 28

Slide 28 text

github.com/terra-farm Join us! Reach out via the issues on
 github.com/terra-farm/meta