PagerDuty Terraform Time: Write HCL in Go with hclwrite

PagerDuty Terraform Time: Write HCL in Go with hclwrite

May 25, 2022

Scott McAllister, Developer Advocate, PagerDuty

Follow our Twitch channel for more live streams: https://bit.ly/3FqonQq

Time Stamps:

0:00 - Intro

2:15 - Announcement: Terraform Quarterly Roundtable

5:45 - Intro hclwrite library

6:10 - Problem scenario that led to needing the library

11:45 - PageDuty REST API Pagination

16:20 - Write Terraform Files in Go with hclwrite

18:20 - hclwrite documentation

19:54 - PagerDuty Terraform Provider documentation

22:05 - Start stepping through Go code

25:00 - AppendNewBlock()

27:32 - SetAttributeValue()

29:00 - First run of Go code. Create `terraform` block.

33:10 - Create a resource block.

35:00 - go-cty library

37:00 - Tokens & SetAttributeRaw()

40:50 - SetAttributeTraversal()

46:57 - Using SetAttributeRaw and Tokens to build list values

51:25 - Define 50 services in a loop

53:30 - Run Go code to define all needed resources

57:00 - Run generated HCL code to configure resources in PagerDuty

Resources:
Write Terraform Files in Go with hclwrite
Create Terraform Resource References in Go with hclwrite

Join the PagerDuty Community today https://bit.ly/3aiDEEI